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-12-01 04:32:29 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 "../../ballet/ed25519/fd_ed25519_verifier.h"
       8             : #include "sysvar/fd_sysvar_rent.h"
       9             : 
      10             : /* https://github.com/anza-xyz/agave/blob/v2.3.1/svm/src/account_loader.rs#L40-L47 */
      11        3303 : #define FD_TRANSACTION_ACCOUNT_BASE_SIZE  (64UL)
      12         693 : #define FD_ADDRESS_LOOKUP_TABLE_BASE_SIZE (8248UL)
      13             : 
      14        5049 : #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         576 : #define FD_EXEC_CU_UPDATE( ctx, cost ) do {                   \
      19         576 :   fd_exec_instr_ctx_t * _ctx = (ctx);                         \
      20         576 :   int err = fd_executor_consume_cus( _ctx->txn_out, (cost) ); \
      21         576 :   if( FD_UNLIKELY( err ) ) return err;                        \
      22         576 :   } while(0)
      23             : 
      24             : // https://github.com/anza-xyz/agave/blob/2e6ca8c1f62db62c1db7f19c9962d4db43d0d550/sdk/src/fee.rs#L82
      25        1446 : #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_sanitize_txn_v1_config( fd_txn_in_t const * txn_in,
      41             :                                     fd_txn_out_t *      txn_out );
      42             : 
      43             : int
      44             : fd_executor_verify_transaction( fd_bank_t const *   bank,
      45             :                                 fd_txn_in_t const * txn_in,
      46             :                                 fd_txn_out_t *      txn_out );
      47             : 
      48             : int
      49             : fd_executor_check_transactions( fd_runtime_t *      runtime,
      50             :                                 fd_bank_t *         bank,
      51             :                                 fd_txn_in_t const * txn_in,
      52             :                                 fd_txn_out_t *      txn_out );
      53             : 
      54             : /* fd_executor_txn_verify verifies the signatures of the txn_cnt
      55             :    parsed transactions txns[i] together with verifier (their total
      56             :    signature count is in [1,FD_ED25519_VERIFIER_SIG_MAX], asserted).
      57             :    Returns FD_RUNTIME_EXECUTE_SUCCESS if every signature verifies and
      58             :    FD_RUNTIME_TXN_ERR_SIGNATURE_FAILURE otherwise. */
      59             : int
      60             : fd_executor_txn_verify( fd_ed25519_verifier_t *  verifier,
      61             :                         fd_txn_p_t const * const txns[], /* txn_cnt */
      62             :                         ulong                    txn_cnt );
      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             : /* fd_execute_instr creates a new fd_exec_instr_ctx_t and performs
      73             :    instruction processing.  Returns an error code in
      74             :    FD_EXECUTOR_INSTR_{ERR_{...},SUCCESS}.
      75             : 
      76             :    instr_info must remain valid for the transaction.  The caller allocates
      77             :    it from runtime->instr.trace and increments runtime->instr.trace_length
      78             :    before calling fd_execute_instr. */
      79             : 
      80             : int
      81             : fd_execute_instr( 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             :                   fd_instr_info_t *   instr_info );
      86             : 
      87             : /*
      88             :   Execute the given transaction.
      89             : 
      90             :   Makes changes to the accounts DB. */
      91             : int
      92             : fd_execute_txn( 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_calculate_fee computes the execution (signature) and
      98             :    priority fees.  Compute unit limits must already be sanitized. */
      99             : 
     100             : void
     101             : fd_executor_calculate_fee( fd_txn_out_t const * txn_out,
     102             :                            fd_txn_t const *     txn_descriptor,
     103             :                            uchar const *        payload,
     104             :                            ulong *              ret_execution_fee,
     105             :                            ulong *              ret_priority_fee );
     106             : 
     107             : int
     108             : fd_executor_validate_transaction_fee_payer( fd_bank_t *         bank,
     109             :                                             fd_txn_in_t const * txn_in,
     110             :                                             fd_txn_out_t *      txn_out );
     111             : 
     112             : int
     113             : fd_executor_setup_accounts_for_txn( 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             : void
     119             : fd_executor_setup_accounts_for_txn_bundle( fd_runtime_t *      runtime,
     120             :                                            fd_txn_in_t const * txn_in,
     121             :                                            fd_txn_out_t *      txn_out );
     122             : 
     123             : int
     124             : fd_executor_setup_txn_alut_account_keys( fd_runtime_t *      runtime,
     125             :                                          fd_bank_t *         bank,
     126             :                                          fd_txn_in_t const * txn_in,
     127             :                                          fd_txn_out_t *      txn_out );
     128             : 
     129             : /* fd_executor_instr_strerror converts an FD_EXECUTOR_INSTR_ERR_{...}
     130             :    code into a human readable cstr.  The lifetime of the returned
     131             :    pointer is infinite and the call itself is thread safe.  The
     132             :    returned pointer is always to a non-NULL cstr. */
     133             : 
     134             : FD_FN_CONST char const *
     135             : fd_executor_instr_strerror( int err );
     136             : 
     137             : int
     138             : fd_executor_load_transaction_accounts( fd_bank_t *         bank,
     139             :                                        fd_txn_in_t const * txn_in,
     140             :                                        fd_txn_out_t *      txn_out );
     141             : 
     142             : int
     143             : fd_executor_validate_account_locks( fd_txn_out_t const * txn_out );
     144             : 
     145             : int
     146             : fd_executor_consume_cus( fd_txn_out_t * txn_out,
     147             :                          ulong          cus );
     148             : 
     149             : /* We expose these only for the fuzzing harness.
     150             :    Normally you shouldn't be invoking these manually. */
     151             : int
     152             : fd_instr_stack_push( fd_runtime_t *      runtime,
     153             :                      fd_bank_t const *   bank,
     154             :                      fd_txn_in_t const * txn_in,
     155             :                      fd_txn_out_t *      txn_out,
     156             :                      fd_instr_info_t *   instr );
     157             : 
     158             : int
     159             : fd_instr_stack_pop( fd_runtime_t *          runtime,
     160             :                     fd_txn_out_t *          txn_out,
     161             :                     fd_instr_info_t const * instr );
     162             : 
     163             : int
     164             : fd_execute_instr_end( fd_exec_instr_ctx_t *   instr_ctx,
     165             :                       fd_instr_info_t const * instr,
     166             :                       int                     instr_exec_result );
     167             : 
     168             : FD_PROTOTYPES_END
     169             : 
     170             : #endif /* HEADER_fd_src_flamenco_runtime_fd_executor_h */

Generated by: LCOV version 1.14