LCOV - code coverage report
Current view: top level - flamenco/runtime/tests - fd_solfuzz_private.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 18 20 90.0 %
Date: 2026-11-26 02:16:43 Functions: 11 52 21.2 %

          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 "generated/context.pb.h"
      10             : 
      11             : FD_PROTOTYPES_BEGIN
      12             : 
      13             : static inline ulong
      14             : fd_solfuzz_hash( void const * data,
      15      629934 :                  ulong        data_sz ) {
      16      629934 :   return data_sz ? fd_hash( 0UL, data, data_sz ) : 0UL;
      17      629934 : }
      18             : 
      19             : /* Returns the account data carried by an input account state, or NULL if
      20             :    the account state carries a hash of its data instead. */
      21             : static inline fd_pb_bytes_array_t const *
      22     1410040 : fd_solfuzz_acct_data( fd_exec_test_acct_state_t const * acct ) {
      23     1410040 :   if( acct->which_data_repr!=FD_EXEC_TEST_ACCT_STATE_DATA_TAG ) return NULL;
      24     1284767 :   return acct->data_repr.data;
      25     1410040 : }
      26             : 
      27             : /* Stores the hash of the given account data in an effects account
      28             :    state. */
      29             : static inline void
      30             : fd_solfuzz_acct_set_data_hash( fd_exec_test_acct_state_t * acct,
      31             :                                void const *                data,
      32      539648 :                                ulong                       data_sz ) {
      33      539648 :   acct->which_data_repr     = FD_EXEC_TEST_ACCT_STATE_DATA_HASH_TAG;
      34      539648 :   acct->data_repr.data_hash = fd_solfuzz_hash( data, data_sz );
      35      539648 : }
      36             : 
      37             : /* Creates / overwrites an account in the accdb given an input account
      38             :    state.  On success, loads the account into acc.  Optionally, reject
      39             :    any zero-lamport accounts from being loaded in. */
      40             : int
      41             : fd_solfuzz_pb_load_account( fd_runtime_t *                    runtime,
      42             :                             fd_accdb_t *                      accdb,
      43             :                             fd_accdb_fork_id_t                fork_id,
      44             :                             fd_exec_test_acct_state_t const * state,
      45             :                             ulong                             acc_idx );
      46             : 
      47             : /* Restores the fee rate governor in the bank from the given protobuf
      48             :    fee rate governor. */
      49             : void
      50             : fd_solfuzz_pb_restore_fee_rate_governor( fd_bank_t *                              bank,
      51             :                                          fd_exec_test_fee_rate_governor_t const * fee_rate_governor );
      52             : 
      53             : /* Initializes the blockhash queue in the bank from the given protobuf
      54             :    blockhash queue entries. */
      55             : void
      56             : fd_solfuzz_pb_restore_blockhash_queue( fd_bank_t *                                    bank,
      57             :                                        fd_exec_test_blockhash_queue_entry_t const *   entries,
      58             :                                        ulong                                          entries_cnt );
      59             : 
      60             : /* Retrieves the slot number from the clock sysvar account within the
      61             :    given account states list.  Throws FD_LOG_ERR if the clock sysvar
      62             :    is not found or is malformed. */
      63             : ulong
      64             : fd_solfuzz_pb_get_slot( fd_exec_test_acct_state_t const * acct_states,
      65             :                         ulong                             acct_states_cnt );
      66             : 
      67             : /* Activates features in the runtime given an input feature set.  Fails
      68             :    if a passed-in feature is unknown / not supported. */
      69             : int
      70             : fd_solfuzz_pb_restore_features( fd_features_t *                    features,
      71             :                                 fd_exec_test_feature_set_t const * feature_set );
      72             : 
      73             : /* Due to how Firedancer's VM CU accounting works, when execution
      74             :    fails with the CU meter exhausted, we cannot compare the data
      75             :    region of the accounts with Agave. This function clears the
      76             :    data field on each captured account in this case. */
      77             : void
      78             : fd_solfuzz_direct_mapping_handle_cu_exhaustion( ulong                       cu_avail,
      79             :                                                 int                         has_err,
      80             :                                                 fd_exec_test_acct_state_t * accounts,
      81             :                                                 uint                   accounts_cnt );
      82             : 
      83             : /* Create feature accounts for all active features in the given feature
      84             :    set, with an activation slot of 0.  Skip any feature whose pubkey
      85             :    already appears in acct_states so the caller-supplied state wins
      86             :    (matches solfuzz-agave's accounts_to_store filter). */
      87             : void
      88             : fd_solfuzz_pb_create_feature_accounts( fd_accdb_t *                       accdb,
      89             :                                        fd_accdb_fork_id_t                 fork_id,
      90             :                                        fd_exec_test_feature_set_t const * feature_set,
      91             :                                        fd_exec_test_acct_state_t const *  acct_states,
      92             :                                        uint                          acct_states_count );
      93             : 
      94             : typedef ulong( exec_test_run_pb_fn_t )( fd_solfuzz_runner_t *,
      95             :                                         void const *,
      96             :                                         void **,
      97             :                                         void *,
      98             :                                         ulong );
      99             : 
     100             : static inline void
     101             : fd_solfuzz_pb_execute_wrapper( fd_solfuzz_runner_t *   runner,
     102             :                                void const *            input,
     103             :                                void **                 output,
     104       68017 :                                exec_test_run_pb_fn_t * exec_test_run_fn ) {
     105       68017 :   ulong out_bufsz = 100000000;  /* 100 MB */
     106       68017 :   void * out0 = fd_spad_alloc( runner->spad, 1UL, out_bufsz );
     107       68017 :   FD_TEST( out_bufsz <= fd_spad_alloc_max( runner->spad, 1UL ) );
     108             : 
     109       68017 :   ulong out_used = exec_test_run_fn( runner, input, output, out0, out_bufsz );
     110       68017 :   if( FD_UNLIKELY( !out_used ) ) {
     111           0 :     *output = NULL;
     112           0 :   }
     113       68017 : }
     114             : 
     115             : FD_PROTOTYPES_END
     116             : 
     117             : #endif /* HEADER_fd_src_flamenco_runtime_tests_fd_solfuzz_private_h */

Generated by: LCOV version 1.14