LCOV - code coverage report
Current view: top level - flamenco/runtime/tests - fd_solfuzz_private.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 45 0.0 %
Date: 2026-06-01 09:39:41 Functions: 0 40 0.0 %

          Line data    Source code
       1             : #ifndef HEADER_fd_src_flamenco_runtime_tests_fd_solfuzz_private_h
       2             : #define HEADER_fd_src_flamenco_runtime_tests_fd_solfuzz_private_h
       3             : 
       4             : /* fd_solfuzz_private.h contains internal components for the solfuzz
       5             :    Protobuf shim. */
       6             : 
       7             : #include "fd_solfuzz.h"
       8             : #include "../../features/fd_features.h"
       9             : #include "../../../ballet/nanopb/pb_encode.h"
      10             : #include "../../../ballet/nanopb/pb_decode.h"
      11             : #include "generated/context.pb.h"
      12             : 
      13             : FD_PROTOTYPES_BEGIN
      14             : 
      15             : /* Creates / overwrites an account in funk given an input account state.
      16             :    On success, loads the account into acc.  Optionally, reject any
      17             :    zero-lamport accounts from being loaded in. */
      18             : int
      19             : fd_solfuzz_pb_load_account( fd_runtime_t *                    runtime,
      20             :                             fd_accdb_user_t *                 accdb,
      21             :                             fd_funk_txn_xid_t const *         xid,
      22             :                             fd_exec_test_acct_state_t const * state,
      23             :                             ulong                             acc_idx );
      24             : 
      25             : /* Restores the fee rate governor in the bank from the given protobuf
      26             :    fee rate governor. */
      27             : void
      28             : fd_solfuzz_pb_restore_fee_rate_governor( fd_bank_t *                              bank,
      29             :                                          fd_exec_test_fee_rate_governor_t const * fee_rate_governor );
      30             : 
      31             : /* Restores the epoch schedule in the bank from the given protobuf
      32             :    epoch schedule. */
      33             : void
      34             : fd_solfuzz_pb_restore_epoch_schedule( fd_bank_t *                           bank,
      35             :                                       fd_exec_test_epoch_schedule_t const * epoch_schedule );
      36             : 
      37             : /* Initializes the blockhash queue in the bank from the given protobuf
      38             :    blockhash queue entries. */
      39             : void
      40             : fd_solfuzz_pb_restore_blockhash_queue( fd_bank_t *                                    bank,
      41             :                                        fd_exec_test_blockhash_queue_entry_t const *   entries,
      42             :                                        ulong                                          entries_cnt );
      43             : 
      44             : /* Retrieves the slot number from the clock sysvar account within the
      45             :    given account states list.  Throws FD_LOG_ERR if the clock sysvar
      46             :    is not found or is malformed. */
      47             : ulong
      48             : fd_solfuzz_pb_get_slot( fd_exec_test_acct_state_t const * acct_states,
      49             :                         ulong                             acct_states_cnt );
      50             : 
      51             : /* Activates features in the runtime given an input feature set.  Fails
      52             :    if a passed-in feature is unknown / not supported. */
      53             : int
      54             : fd_solfuzz_pb_restore_features( fd_features_t *                    features,
      55             :                                 fd_exec_test_feature_set_t const * feature_set );
      56             : 
      57             : /* Due to how Firedancer's VM CU accounting works, when
      58             :    virtual_address_space_adjustments is enabled and execution
      59             :    fails with the CU meter exhausted, we cannot compare the data
      60             :    region of the accounts with Agave. This function clears the
      61             :    data field on each captured account in this case. */
      62             : void
      63             : fd_solfuzz_direct_mapping_handle_cu_exhaustion( fd_solfuzz_runner_t *       runner,
      64             :                                                 ulong                       cu_avail,
      65             :                                                 int                         has_err,
      66             :                                                 fd_exec_test_acct_state_t * accounts,
      67             :                                                 pb_size_t                   accounts_cnt );
      68             : 
      69             : /* Create feature accounts for all active features in the given feature
      70             :    set, with an activation slot of 0.  Skip any feature whose pubkey
      71             :    already appears in acct_states so the caller-supplied state wins
      72             :    (matches solfuzz-agave's accounts_to_store filter). */
      73             : void
      74             : fd_solfuzz_pb_create_feature_accounts( fd_accdb_user_t *                  accdb,
      75             :                                        fd_funk_txn_xid_t const *          xid,
      76             :                                        fd_exec_test_feature_set_t const * feature_set,
      77             :                                        fd_exec_test_acct_state_t const *  acct_states,
      78             :                                        pb_size_t                          acct_states_count );
      79             : 
      80             : typedef ulong( exec_test_run_pb_fn_t )( fd_solfuzz_runner_t *,
      81             :                                         void const *,
      82             :                                         void **,
      83             :                                         void *,
      84             :                                         ulong );
      85             : 
      86             : static inline void
      87             : fd_solfuzz_pb_execute_wrapper( fd_solfuzz_runner_t *   runner,
      88             :                                void const *            input,
      89             :                                void **                 output,
      90           0 :                                exec_test_run_pb_fn_t * exec_test_run_fn ) {
      91           0 :   ulong out_bufsz = 100000000;  /* 100 MB */
      92           0 :   void * out0 = fd_spad_alloc( runner->spad, 1UL, out_bufsz );
      93           0 :   FD_TEST( out_bufsz <= fd_spad_alloc_max( runner->spad, 1UL ) );
      94             : 
      95           0 :   ulong out_used = exec_test_run_fn( runner, input, output, out0, out_bufsz );
      96           0 :   if( FD_UNLIKELY( !out_used ) ) {
      97           0 :     *output = NULL;
      98           0 :   }
      99           0 : }
     100             : 
     101             : /* Utils */
     102             : 
     103             : static FD_FN_UNUSED void *
     104             : sol_compat_decode_lenient( void *               decoded,
     105             :                            uchar const *        in,
     106             :                            ulong                in_sz,
     107           0 :                            pb_msgdesc_t const * decode_type ) {
     108           0 :   pb_istream_t istream = pb_istream_from_buffer( in, in_sz );
     109           0 :   int decode_ok = pb_decode_ex( &istream, decode_type, decoded, PB_DECODE_NOINIT );
     110           0 :   if( !decode_ok ) {
     111           0 :     pb_release( decode_type, decoded );
     112           0 :     return NULL;
     113           0 :   }
     114           0 :   return decoded;
     115           0 : }
     116             : 
     117             : static FD_FN_UNUSED void *
     118             : sol_compat_decode( void *               decoded,
     119             :                    uchar const *        in,
     120             :                    ulong                in_sz,
     121           0 :                    pb_msgdesc_t const * decode_type ) {
     122           0 :   pb_istream_t istream = pb_istream_from_buffer( in, in_sz );
     123           0 :   int decode_ok = pb_decode_ex( &istream, decode_type, decoded, PB_DECODE_NOINIT );
     124           0 :   if( !decode_ok ) {
     125           0 :     pb_release( decode_type, decoded );
     126           0 :     return NULL;
     127           0 :   }
     128           0 :   ulong size;
     129           0 :   if( FD_UNLIKELY( !pb_get_encoded_size( &size, decode_type, decoded ) ) ) {
     130           0 :     pb_release( decode_type, decoded );
     131           0 :     return NULL;
     132           0 :   }
     133           0 :   if( FD_UNLIKELY( size != in_sz ) ) {
     134           0 :     pb_release( decode_type, decoded );
     135           0 :     return NULL;
     136           0 :   }
     137           0 :   return decoded;
     138           0 : }
     139             : 
     140             : static FD_FN_UNUSED void const *
     141             : sol_compat_encode( uchar *              out,
     142             :                    ulong *              out_sz,
     143             :                    void const *         to_encode,
     144           0 :                    pb_msgdesc_t const * encode_type ) {
     145           0 :   pb_ostream_t ostream = pb_ostream_from_buffer( out, *out_sz );
     146           0 :   int encode_ok = pb_encode( &ostream, encode_type, to_encode );
     147           0 :   if( !encode_ok ) {
     148           0 :     return NULL;
     149           0 :   }
     150           0 :   *out_sz = ostream.bytes_written;
     151           0 :   return to_encode;
     152           0 : }
     153             : 
     154             : FD_PROTOTYPES_END
     155             : 
     156             : #endif /* HEADER_fd_src_flamenco_runtime_tests_fd_solfuzz_private_h */

Generated by: LCOV version 1.14