LCOV - code coverage report
Current view: top level - app/shared - fd_config_parse.c (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 362 404 89.6 %
Date: 2025-03-20 12:08:36 Functions: 9 9 100.0 %

          Line data    Source code
       1             : #include "fd_config_parse.h"
       2             : 
       3             : FD_IMPORT_BINARY( fdctl_default_config, "src/app/fdctl/config/default.toml" );
       4             : FD_IMPORT_BINARY( fdctl_default_firedancer_config, "src/app/fdctl/config/default-firedancer.toml" );
       5             : 
       6             : /* Pod query utils ****************************************************/
       7             : 
       8             : static int
       9             : fdctl_cfg_get_cstr_( char *                out,
      10             :                      ulong                 out_sz,
      11             :                      fd_pod_info_t const * info,
      12         282 :                      char const *          path ) {
      13         282 :   if( FD_UNLIKELY( info->val_type != FD_POD_VAL_TYPE_CSTR ) ) {
      14           0 :     FD_LOG_WARNING(( "invalid value for `%s`", path ));
      15           0 :     return 0;
      16           0 :   }
      17         282 :   char const * str = info->val;
      18         282 :   ulong        sz  = strlen( str ) + 1;
      19         282 :   if( FD_UNLIKELY( sz > out_sz ) ) {
      20           0 :     FD_LOG_WARNING(( "`%s`: too long (max %ld)", path, (long)out_sz-1L ));
      21           0 :     return 0;
      22           0 :   }
      23         282 :   fd_memcpy( out, str, sz );
      24         282 :   return 1;
      25         282 : }
      26             : 
      27             : #define fdctl_cfg_get_cstr( out, out_sz, info, path ) \
      28           6 :   fdctl_cfg_get_cstr_( *out, out_sz, info, path )
      29             : 
      30             : static int
      31             : fdctl_cfg_get_ulong( ulong *               out,
      32             :                      ulong                 out_sz FD_PARAM_UNUSED,
      33             :                      fd_pod_info_t const * info,
      34         318 :                      char const *          path ) {
      35             : 
      36         318 :   ulong num;
      37         318 :   switch( info->val_type ) {
      38         318 :   case FD_POD_VAL_TYPE_LONG:
      39         318 :     fd_ulong_svw_dec( (uchar const *)info->val, &num );
      40         318 :     long snum = fd_long_zz_dec( num );
      41         318 :     if( snum < 0L ) {
      42           0 :       FD_LOG_WARNING(( "`%s` cannot be negative", path ));
      43           0 :       return 0;
      44           0 :     }
      45         318 :     num = (ulong)snum;
      46         318 :     break;
      47           0 :   case FD_POD_VAL_TYPE_ULONG:
      48           0 :     fd_ulong_svw_dec( (uchar const *)info->val, &num );
      49           0 :     break;
      50           0 :   default:
      51           0 :     FD_LOG_WARNING(( "invalid value for `%s`", path ));
      52           0 :     return 0;
      53         318 :   }
      54             : 
      55         318 :   *out = num;
      56         318 :   return 1;
      57         318 : }
      58             : 
      59             : static int
      60             : fdctl_cfg_get_uint( uint *                out,
      61             :                     ulong                 out_sz FD_PARAM_UNUSED,
      62             :                     fd_pod_info_t const * info,
      63         186 :                     char const *          path ) {
      64         186 :   ulong num;
      65         186 :   if( FD_UNLIKELY( !fdctl_cfg_get_ulong( &num, sizeof(num), info, path ) ) ) return 0;
      66         186 :   if( num > UINT_MAX ) {
      67           0 :     FD_LOG_WARNING(( "`%s` is out of bounds (%lx)", path, num ));
      68           0 :     return 0;
      69           0 :   }
      70         186 :   *out = (uint)num;
      71         186 :   return 1;
      72         186 : }
      73             : 
      74             : static int
      75             : fdctl_cfg_get_ushort( ushort *              out,
      76             :                       ulong                 out_sz FD_PARAM_UNUSED,
      77             :                       fd_pod_info_t const * info,
      78          48 :                       char const *          path ) {
      79          48 :   ulong num;
      80          48 :   if( FD_UNLIKELY( !fdctl_cfg_get_ulong( &num, sizeof(num), info, path ) ) ) return 0;
      81          48 :   if( num > USHORT_MAX ) {
      82           0 :     FD_LOG_WARNING(( "`%s` is out of bounds (%lx)", path, num ));
      83           0 :     return 0;
      84           0 :   }
      85          48 :   *out = (ushort)num;
      86          48 :   return 1;
      87          48 : }
      88             : 
      89             : static int
      90             : fdctl_cfg_get_bool( int *                 out,
      91             :                     ulong                 out_sz FD_PARAM_UNUSED,
      92             :                     fd_pod_info_t const * info,
      93         204 :                     char const *          path ) {
      94         204 :   if( FD_UNLIKELY( info->val_type != FD_POD_VAL_TYPE_INT ) ) {
      95           0 :     FD_LOG_WARNING(( "invalid value for `%s`", path ));
      96           0 :     return 0;
      97           0 :   }
      98         204 :   ulong u; fd_ulong_svw_dec( (uchar const *)info->val, &u );
      99         204 :   *out = fd_int_zz_dec( (uint)u );
     100         204 :   return 1;
     101         204 : }
     102             : 
     103             : /* Find leftover ******************************************************/
     104             : 
     105             : /* fdctl_pod_find_leftover recursively searches for non-subpod keys in
     106             :    pod.  Prints to the warning log if it finds any.  Used to detect
     107             :    config keys that were not recognized by fdctl.  Returns 0 if no
     108             :    leftover key was found.  Otherwise, returns a non-zero number of
     109             :    segments of the leftover key.  The key can be reassembled by joining
     110             :    stack[0] .. stack[depth-1].
     111             : 
     112             :    Not thread safe (uses global buffer). */
     113             : 
     114           3 : # define FDCTL_CFG_MAX_DEPTH (16)
     115             : 
     116             : static ulong
     117             : fdctl_pod_find_leftover_recurse( uchar *       pod,
     118             :                                  char const ** stack,
     119         195 :                                  ulong         depth ) {
     120             : 
     121         195 :   if( FD_UNLIKELY( depth+1 >= FDCTL_CFG_MAX_DEPTH ) ) {
     122           0 :     FD_LOG_WARNING(( "configuration file has too many nested keys" ));
     123           0 :     return depth;
     124           0 :   }
     125             : 
     126         375 :   for( fd_pod_iter_t iter = fd_pod_iter_init( pod ); !fd_pod_iter_done( iter ); iter = fd_pod_iter_next( iter ) ) {
     127         183 :     fd_pod_info_t info = fd_pod_iter_info( iter );
     128         183 :     stack[ depth ] = info.key;
     129         183 :     depth++;
     130         183 :     if( FD_LIKELY( info.val_type == FD_POD_VAL_TYPE_SUBPOD ) ) {
     131         180 :       ulong sub_depth = fdctl_pod_find_leftover_recurse( (uchar *)info.val, stack, depth );
     132         180 :       if( FD_UNLIKELY( sub_depth ) ) return sub_depth;
     133         180 :     } else {
     134           3 :       return depth;
     135           3 :     }
     136         180 :     depth--;
     137         180 :   }
     138             : 
     139         192 :   return 0;
     140         195 : }
     141             : 
     142             : static int
     143          15 : fdctl_pod_find_leftover( uchar * pod ) {
     144             : 
     145          15 :   static char const * stack[ FDCTL_CFG_MAX_DEPTH ];
     146          15 :   ulong depth = fdctl_pod_find_leftover_recurse( pod, stack, 0UL );
     147          15 :   if( FD_LIKELY( !depth ) ) return 1;
     148             : 
     149           3 :   static char path[ 64*FDCTL_CFG_MAX_DEPTH + 4 ];
     150           3 :   char * c   = fd_cstr_init( path );
     151           3 :   char * end = path + 64*FDCTL_CFG_MAX_DEPTH - 1;
     152           6 :   for( ulong j=0UL; j<depth; j++ ) {
     153           3 :     char const * key     = stack[j];
     154           3 :     ulong        key_len = strlen( key );
     155           3 :     if( c+key_len+1 >= end ) {
     156           0 :       c = fd_cstr_append_text( c, "...", 3UL );
     157           0 :       break;
     158           0 :     }
     159           3 :     c = fd_cstr_append_text( c, key, key_len );
     160           3 :     c = fd_cstr_append_char( c, '.' );
     161           3 :   }
     162           3 :   c -= 1;
     163           3 :   fd_cstr_fini( c );
     164             : 
     165           3 :   FD_LOG_WARNING(( "Config file contains unrecognized key `%s`", path ));
     166           3 :   return 0;
     167          15 : }
     168             : 
     169             : /* Converter **********************************************************/
     170             : 
     171             : config_t *
     172             : fdctl_pod_to_cfg( config_t * config,
     173          15 :                   uchar *    pod ) {
     174             : 
     175          15 : # define CFG_POP( type, cfg_path )                                     \
     176        2580 :   do {                                                                 \
     177        2580 :     char const * key = #cfg_path;                                      \
     178        2580 :     fd_pod_info_t info[1];                                             \
     179        2580 :     if( fd_pod_query( pod, key, info ) ) break;                        \
     180        2580 :     if( FD_UNLIKELY( !fdctl_cfg_get_##type( &config->cfg_path, sizeof(config->cfg_path), \
     181         798 :         info, key ) ) )                                                \
     182         798 :       return NULL;                                                     \
     183         798 :     fd_pod_remove( pod, key );                                         \
     184         798 :   } while(0)
     185             : 
     186          15 : # define CFG_POP_ARRAY( type, cfg_path )                               \
     187         105 :   do {                                                                 \
     188         105 :     char const * key = #cfg_path;                                      \
     189         105 :     fd_pod_info_t info[1];                                             \
     190         105 :     if( fd_pod_query( pod, key, info ) ) break;                        \
     191         105 :     if( FD_UNLIKELY( info->val_type!=FD_POD_VAL_TYPE_SUBPOD ) ) {      \
     192           0 :       FD_LOG_WARNING(( "`%s`: expected array", key ));                 \
     193           0 :       return NULL;                                                     \
     194           0 :     }                                                                  \
     195          48 :     ulong  arr_len = sizeof( config->cfg_path ) / sizeof( config->cfg_path[ 0 ] ); \
     196          48 :     ulong  j       = 0UL;                                              \
     197          54 :     for( fd_pod_iter_t iter = fd_pod_iter_init( info->val ); !fd_pod_iter_done( iter ); iter = fd_pod_iter_next( iter ) ) { \
     198           6 :       if( FD_UNLIKELY( j>=arr_len ) ) {                                \
     199           0 :         FD_LOG_WARNING(( "`%s`: too many values (max %lu)", key, arr_len )); \
     200           0 :         return NULL;                                                   \
     201           0 :       }                                                                \
     202           6 :       fd_pod_info_t sub_info = fd_pod_iter_info( iter );               \
     203           6 :       fdctl_cfg_get_##type( &config->cfg_path[j], sizeof(config->cfg_path[j]), &sub_info, key ); \
     204           6 :       j++;                                                             \
     205           6 :     }                                                                  \
     206          48 :     config->cfg_path ## _cnt = j;                                      \
     207          48 :     fd_pod_remove( pod, key );                                         \
     208          48 :   } while(0)
     209             : 
     210          15 :   CFG_POP      ( cstr,   name                                             );
     211          15 :   CFG_POP      ( cstr,   user                                             );
     212          15 :   CFG_POP      ( cstr,   scratch_directory                                );
     213          15 :   CFG_POP      ( cstr,   dynamic_port_range                               );
     214             : 
     215          15 :   CFG_POP      ( cstr,   log.path                                         );
     216          15 :   CFG_POP      ( cstr,   log.colorize                                     );
     217          15 :   CFG_POP      ( cstr,   log.level_logfile                                );
     218          15 :   CFG_POP      ( cstr,   log.level_stderr                                 );
     219          15 :   CFG_POP      ( cstr,   log.level_flush                                  );
     220             : 
     221          15 :   CFG_POP      ( cstr,   reporting.solana_metrics_config                  );
     222             : 
     223          15 :   CFG_POP      ( cstr,   ledger.path                                      );
     224          15 :   CFG_POP      ( cstr,   ledger.accounts_path                             );
     225          15 :   CFG_POP      ( uint,   ledger.limit_size                                );
     226          15 :   CFG_POP_ARRAY( cstr,   ledger.account_indexes                           );
     227          15 :   CFG_POP_ARRAY( cstr,   ledger.account_index_include_keys                );
     228          15 :   CFG_POP_ARRAY( cstr,   ledger.account_index_exclude_keys                );
     229          15 :   CFG_POP      ( cstr,   ledger.accounts_index_path                       );
     230          15 :   CFG_POP      ( cstr,   ledger.accounts_hash_cache_path                  );
     231          15 :   CFG_POP      ( bool,   ledger.require_tower                             );
     232          15 :   CFG_POP      ( cstr,   ledger.snapshot_archive_format                   );
     233             : 
     234          15 :   CFG_POP_ARRAY( cstr,   gossip.entrypoints                               );
     235          15 :   CFG_POP      ( bool,   gossip.port_check                                );
     236          15 :   CFG_POP      ( ushort, gossip.port                                      );
     237          15 :   CFG_POP      ( cstr,   gossip.host                                      );
     238             : 
     239          15 :   CFG_POP      ( cstr,   consensus.identity_path                          );
     240          15 :   CFG_POP      ( cstr,   consensus.vote_account_path                      );
     241          15 :   CFG_POP_ARRAY( cstr,   consensus.authorized_voter_paths                 );
     242          15 :   CFG_POP      ( bool,   consensus.snapshot_fetch                         );
     243          15 :   CFG_POP      ( bool,   consensus.genesis_fetch                          );
     244          15 :   CFG_POP      ( bool,   consensus.poh_speed_test                         );
     245          15 :   CFG_POP      ( cstr,   consensus.expected_genesis_hash                  );
     246          15 :   CFG_POP      ( uint,   consensus.wait_for_supermajority_at_slot         );
     247          15 :   CFG_POP      ( cstr,   consensus.expected_bank_hash                     );
     248          15 :   CFG_POP      ( ushort, consensus.expected_shred_version                 );
     249          15 :   CFG_POP      ( bool,   consensus.wait_for_vote_to_start_leader          );
     250          15 :   CFG_POP_ARRAY( uint,   consensus.hard_fork_at_slots                     );
     251          15 :   CFG_POP_ARRAY( cstr,   consensus.known_validators                       );
     252          15 :   CFG_POP      ( bool,   consensus.os_network_limits_test                 );
     253             : 
     254          15 :   CFG_POP      ( ushort, rpc.port                                         );
     255          15 :   CFG_POP      ( bool,   rpc.full_api                                     );
     256          15 :   CFG_POP      ( bool,   rpc.private                                      );
     257          15 :   CFG_POP      ( cstr,   rpc.bind_address                                 );
     258          15 :   CFG_POP      ( bool,   rpc.transaction_history                          );
     259          15 :   CFG_POP      ( bool,   rpc.extended_tx_metadata_storage                 );
     260          15 :   CFG_POP      ( bool,   rpc.only_known                                   );
     261          15 :   CFG_POP      ( bool,   rpc.pubsub_enable_block_subscription             );
     262          15 :   CFG_POP      ( bool,   rpc.pubsub_enable_vote_subscription              );
     263          15 :   CFG_POP      ( bool,   rpc.bigtable_ledger_storage                      );
     264             : 
     265          15 :   CFG_POP      ( bool,   snapshots.enabled                                );
     266          15 :   CFG_POP      ( bool,   snapshots.incremental_snapshots                  );
     267          15 :   CFG_POP      ( uint,   snapshots.full_snapshot_interval_slots           );
     268          15 :   CFG_POP      ( uint,   snapshots.incremental_snapshot_interval_slots    );
     269          15 :   CFG_POP      ( uint,   snapshots.minimum_snapshot_download_speed        );
     270          15 :   CFG_POP      ( uint,   snapshots.maximum_full_snapshots_to_retain       );
     271          15 :   CFG_POP      ( uint,   snapshots.maximum_incremental_snapshots_to_retain);
     272          15 :   CFG_POP      ( cstr,   snapshots.path                                   );
     273          15 :   CFG_POP      ( cstr,   snapshots.incremental_path                       );
     274             : 
     275          15 :   CFG_POP      ( cstr,   layout.affinity                                  );
     276          15 :   CFG_POP      ( cstr,   layout.agave_affinity                            );
     277          15 :   CFG_POP      ( uint,   layout.agave_unified_scheduler_handler_threads   );
     278          15 :   CFG_POP      ( uint,   layout.net_tile_count                            );
     279          15 :   CFG_POP      ( uint,   layout.quic_tile_count                           );
     280          15 :   CFG_POP      ( uint,   layout.resolv_tile_count                         );
     281          15 :   CFG_POP      ( uint,   layout.verify_tile_count                         );
     282          15 :   CFG_POP      ( uint,   layout.bank_tile_count                           );
     283          15 :   CFG_POP      ( uint,   layout.shred_tile_count                          );
     284             : 
     285          15 :   CFG_POP      ( cstr,   hugetlbfs.mount_path                             );
     286          15 :   CFG_POP      ( cstr,   hugetlbfs.max_page_size                          );
     287          15 :   CFG_POP      ( ulong,  hugetlbfs.gigantic_page_threshold_mib            );
     288             : 
     289          15 :   CFG_POP      ( cstr,   tiles.net.interface                              );
     290          15 :   CFG_POP      ( cstr,   tiles.net.xdp_mode                               );
     291          15 :   CFG_POP      ( bool,   tiles.net.xdp_zero_copy                          );
     292          15 :   CFG_POP      ( uint,   tiles.net.xdp_rx_queue_size                      );
     293          15 :   CFG_POP      ( uint,   tiles.net.xdp_tx_queue_size                      );
     294          15 :   CFG_POP      ( uint,   tiles.net.flush_timeout_micros                   );
     295          15 :   CFG_POP      ( uint,   tiles.net.send_buffer_size                       );
     296             : 
     297          15 :   CFG_POP      ( ulong,  tiles.netlink.max_routes                         );
     298          15 :   CFG_POP      ( ulong,  tiles.netlink.max_neighbors                      );
     299             : 
     300          15 :   CFG_POP      ( ushort, tiles.quic.regular_transaction_listen_port       );
     301          15 :   CFG_POP      ( ushort, tiles.quic.quic_transaction_listen_port          );
     302          15 :   CFG_POP      ( uint,   tiles.quic.txn_reassembly_count                  );
     303          15 :   CFG_POP      ( uint,   tiles.quic.max_concurrent_connections            );
     304          15 :   CFG_POP      ( uint,   tiles.quic.max_concurrent_handshakes             );
     305          15 :   CFG_POP      ( uint,   tiles.quic.idle_timeout_millis                   );
     306          15 :   CFG_POP      ( uint,   tiles.quic.ack_delay_millis                      );
     307          15 :   CFG_POP      ( bool,   tiles.quic.retry                                 );
     308             : 
     309          15 :   CFG_POP      ( uint,   tiles.verify.signature_cache_size                );
     310          15 :   CFG_POP      ( uint,   tiles.verify.receive_buffer_size                 );
     311          15 :   CFG_POP      ( uint,   tiles.verify.mtu                                 );
     312             : 
     313          15 :   CFG_POP      ( uint,   tiles.dedup.signature_cache_size                 );
     314             : 
     315          15 :   CFG_POP      ( bool,   tiles.bundle.enabled                             );
     316          15 :   CFG_POP      ( cstr,   tiles.bundle.url                                 );
     317          15 :   CFG_POP      ( cstr,   tiles.bundle.tls_domain_name                     );
     318          15 :   CFG_POP      ( cstr,   tiles.bundle.tip_distribution_program_addr       );
     319          15 :   CFG_POP      ( cstr,   tiles.bundle.tip_payment_program_addr            );
     320          15 :   CFG_POP      ( cstr,   tiles.bundle.tip_distribution_authority          );
     321          15 :   CFG_POP      ( uint,   tiles.bundle.commission_bps                      );
     322             : 
     323          15 :   CFG_POP      ( uint,   tiles.pack.max_pending_transactions              );
     324          15 :   CFG_POP      ( bool,   tiles.pack.use_consumed_cus                      );
     325             : 
     326          15 :   CFG_POP      ( bool,   tiles.poh.lagged_consecutive_leader_start        );
     327             : 
     328          15 :   CFG_POP      ( uint,   tiles.shred.max_pending_shred_sets               );
     329          15 :   CFG_POP      ( ushort, tiles.shred.shred_listen_port                    );
     330             : 
     331          15 :   CFG_POP      ( cstr,   tiles.metric.prometheus_listen_address           );
     332          15 :   CFG_POP      ( ushort, tiles.metric.prometheus_listen_port              );
     333             : 
     334          15 :   CFG_POP      ( bool,   tiles.gui.enabled                                );
     335          15 :   CFG_POP      ( cstr,   tiles.gui.gui_listen_address                     );
     336          15 :   CFG_POP      ( ushort, tiles.gui.gui_listen_port                        );
     337          15 :   CFG_POP      ( ulong,  tiles.gui.max_http_connections                   );
     338          15 :   CFG_POP      ( ulong,  tiles.gui.max_websocket_connections              );
     339          15 :   CFG_POP      ( ulong,  tiles.gui.max_http_request_length                );
     340          15 :   CFG_POP      ( ulong,  tiles.gui.send_buffer_size_mb                    );
     341             : 
     342          15 :   CFG_POP      ( bool,   development.sandbox                              );
     343          15 :   CFG_POP      ( bool,   development.no_clone                             );
     344          15 :   CFG_POP      ( bool,   development.core_dump                            );
     345          15 :   CFG_POP      ( bool,   development.no_agave                             );
     346          15 :   CFG_POP      ( bool,   development.bootstrap                            );
     347             : 
     348          15 :   CFG_POP      ( cstr,   development.net.provider                         );
     349             : 
     350          15 :   CFG_POP      ( bool,   development.netns.enabled                        );
     351          15 :   CFG_POP      ( cstr,   development.netns.interface0                     );
     352          15 :   CFG_POP      ( cstr,   development.netns.interface0_mac                 );
     353          15 :   CFG_POP      ( cstr,   development.netns.interface0_addr                );
     354          15 :   CFG_POP      ( cstr,   development.netns.interface1                     );
     355          15 :   CFG_POP      ( cstr,   development.netns.interface1_mac                 );
     356          15 :   CFG_POP      ( cstr,   development.netns.interface1_addr                );
     357             : 
     358          15 :   CFG_POP      ( bool,   development.gossip.allow_private_address         );
     359             : 
     360          15 :   CFG_POP      ( ulong,  development.genesis.hashes_per_tick              );
     361          15 :   CFG_POP      ( ulong,  development.genesis.target_tick_duration_micros  );
     362          15 :   CFG_POP      ( ulong,  development.genesis.ticks_per_slot               );
     363          15 :   CFG_POP      ( ulong,  development.genesis.fund_initial_accounts        );
     364          15 :   CFG_POP      ( ulong,  development.genesis.fund_initial_amount_lamports );
     365          15 :   CFG_POP      ( ulong,  development.genesis.vote_account_stake_lamports  );
     366          15 :   CFG_POP      ( bool,   development.genesis.warmup_epochs                );
     367             : 
     368          15 :   CFG_POP      ( uint,   development.bench.benchg_tile_count              );
     369          15 :   CFG_POP      ( uint,   development.bench.benchs_tile_count              );
     370          15 :   CFG_POP      ( cstr,   development.bench.affinity                       );
     371          15 :   CFG_POP      ( bool,   development.bench.larger_max_cost_per_block      );
     372          15 :   CFG_POP      ( bool,   development.bench.larger_shred_limits_per_block  );
     373          15 :   CFG_POP      ( ulong,  development.bench.disable_blockstore_from_slot   );
     374          15 :   CFG_POP      ( bool,   development.bench.disable_status_cache           );
     375             : 
     376          15 :   CFG_POP      ( cstr,   development.pktgen.affinity                      );
     377          15 :   CFG_POP      ( cstr,   development.pktgen.fake_dst_ip                   );
     378             : 
     379             :   /* Firedancer-only configuration */
     380             : 
     381          15 :   CFG_POP      ( uint,   layout.exec_tile_count                           );
     382             : 
     383          15 :   CFG_POP      ( ulong,  blockstore.shred_max                             );
     384          15 :   CFG_POP      ( ulong,  blockstore.block_max                             );
     385          15 :   CFG_POP      ( ulong,  blockstore.idx_max                               );
     386          15 :   CFG_POP      ( ulong,  blockstore.txn_max                               );
     387          15 :   CFG_POP      ( ulong,  blockstore.alloc_max                             );
     388          15 :   CFG_POP      ( cstr,   blockstore.file                                  );
     389          15 :   CFG_POP      ( cstr,   blockstore.checkpt                               );
     390          15 :   CFG_POP      ( cstr,   blockstore.restore                               );
     391             : 
     392          15 :   CFG_POP      ( bool,   consensus.vote                                   );
     393             : 
     394          15 :   CFG_POP      ( ushort, tiles.repair.repair_intake_listen_port           );
     395          15 :   CFG_POP      ( ushort, tiles.repair.repair_serve_listen_port            );
     396          15 :   CFG_POP      ( cstr,   tiles.repair.good_peer_cache_file                );
     397             : 
     398          15 :   CFG_POP      ( cstr,   tiles.replay.capture                             );
     399          15 :   CFG_POP      ( cstr,   tiles.replay.funk_checkpt                        );
     400          15 :   CFG_POP      ( ulong,  tiles.replay.funk_rec_max                        );
     401          15 :   CFG_POP      ( ulong,  tiles.replay.funk_sz_gb                          );
     402          15 :   CFG_POP      ( ulong,  tiles.replay.funk_txn_max                        );
     403          15 :   CFG_POP      ( cstr,   tiles.replay.funk_file                           );
     404          15 :   CFG_POP      ( cstr,   tiles.replay.genesis                             );
     405          15 :   CFG_POP      ( cstr,   tiles.replay.incremental                         );
     406          15 :   CFG_POP      ( cstr,   tiles.replay.slots_replayed                      );
     407          15 :   CFG_POP      ( cstr,   tiles.replay.snapshot                            );
     408          15 :   CFG_POP      ( cstr,   tiles.replay.status_cache                        );
     409          15 :   CFG_POP      ( ulong,  tiles.replay.tpool_thread_count                  );
     410          15 :   CFG_POP      ( cstr,   tiles.replay.cluster_version                     );
     411          15 :   CFG_POP      ( cstr,   tiles.replay.tower_checkpt                       );
     412             : 
     413          15 :   CFG_POP      ( cstr,   tiles.store_int.slots_pending                    );
     414          15 :   CFG_POP      ( cstr,   tiles.store_int.shred_cap_archive                );
     415          15 :   CFG_POP      ( cstr,   tiles.store_int.shred_cap_replay                 );
     416          15 :   CFG_POP      ( ulong,  tiles.store_int.shred_cap_end_slot               );
     417             : 
     418          15 :   CFG_POP      ( ulong,  tiles.batch.full_interval                        );
     419          15 :   CFG_POP      ( ulong,  tiles.batch.incremental_interval                 );
     420          15 :   CFG_POP      ( cstr,   tiles.batch.out_dir                              );
     421          15 :   CFG_POP      ( ulong,  tiles.batch.hash_tpool_thread_count              );
     422             : 
     423          15 :   CFG_POP      ( bool,   tiles.restart.in_wen_restart                     );
     424          15 :   CFG_POP      ( cstr,   tiles.restart.wen_restart_coordinator            );
     425          15 :   CFG_POP      ( cstr,   tiles.restart.genesis_hash                       );
     426             : 
     427          15 : # undef CFG_POP
     428          15 : # undef CFG_ARRAY
     429             : 
     430          15 :   if( FD_UNLIKELY( !fdctl_pod_find_leftover( pod ) ) ) return NULL;
     431          12 :   return config;
     432          15 : }
     433             : 
     434             : void
     435           6 : fdctl_cfg_validate( config_t * cfg ) {
     436             : 
     437         120 : # define CFG_HAS_NON_EMPTY( key ) do {             \
     438         120 :     if( !strnlen( cfg->key, sizeof(cfg->key) ) ) { \
     439           0 :       FD_LOG_ERR(( "missing `%s`", #key ));        \
     440           0 :     }                                              \
     441         120 :   } while(0)
     442             : 
     443         198 : # define CFG_HAS_NON_ZERO( key ) do {                         \
     444         198 :     if( !cfg->key ) { FD_LOG_ERR(( "missing `%s`", #key )); } \
     445         198 :   } while(0)
     446             : 
     447          12 : # define CFG_HAS_POW2( key ) do {                        \
     448          12 :     ulong value = (ulong)( cfg -> key );                 \
     449          12 :     if( !value || !fd_ulong_is_pow2( value ) ) {         \
     450           0 :       FD_LOG_ERR(( "`%s` must be a power of 2", #key )); \
     451           0 :     }                                                    \
     452          12 :   } while(0)
     453             : 
     454           6 :   CFG_HAS_NON_EMPTY( name );
     455           6 :   CFG_HAS_NON_EMPTY( scratch_directory );
     456           6 :   CFG_HAS_NON_EMPTY( dynamic_port_range );
     457             : 
     458           6 :   CFG_HAS_NON_EMPTY( log.colorize );
     459           6 :   CFG_HAS_NON_EMPTY( log.level_logfile );
     460           6 :   CFG_HAS_NON_EMPTY( log.level_stderr );
     461           6 :   CFG_HAS_NON_EMPTY( log.level_flush );
     462             : 
     463           6 :   CFG_HAS_NON_EMPTY( ledger.snapshot_archive_format );
     464             : 
     465           6 :   CFG_HAS_NON_ZERO( gossip.port );
     466             : 
     467           6 :   CFG_HAS_NON_ZERO( snapshots.full_snapshot_interval_slots );
     468           6 :   CFG_HAS_NON_ZERO( snapshots.incremental_snapshot_interval_slots );
     469           6 :   CFG_HAS_NON_ZERO( snapshots.minimum_snapshot_download_speed );
     470             : 
     471           6 :   CFG_HAS_NON_EMPTY( layout.affinity );
     472           6 :   CFG_HAS_NON_EMPTY( layout.agave_affinity );
     473           6 :   CFG_HAS_NON_ZERO ( layout.net_tile_count );
     474           6 :   CFG_HAS_NON_ZERO ( layout.quic_tile_count );
     475           6 :   CFG_HAS_NON_ZERO ( layout.resolv_tile_count );
     476           6 :   CFG_HAS_NON_ZERO ( layout.verify_tile_count );
     477           6 :   CFG_HAS_NON_ZERO ( layout.bank_tile_count );
     478           6 :   CFG_HAS_NON_ZERO ( layout.shred_tile_count );
     479             : 
     480           6 :   CFG_HAS_NON_EMPTY( hugetlbfs.mount_path );
     481           6 :   CFG_HAS_NON_EMPTY( hugetlbfs.max_page_size );
     482             : 
     483           6 :   CFG_HAS_NON_EMPTY( tiles.net.xdp_mode );
     484           6 :   CFG_HAS_POW2     ( tiles.net.xdp_rx_queue_size );
     485           6 :   CFG_HAS_POW2     ( tiles.net.xdp_tx_queue_size );
     486           6 :   CFG_HAS_NON_ZERO ( tiles.net.send_buffer_size );
     487             : 
     488           6 :   CFG_HAS_NON_ZERO( tiles.netlink.max_routes    );
     489           6 :   CFG_HAS_NON_ZERO( tiles.netlink.max_neighbors );
     490             : 
     491           6 :   CFG_HAS_NON_ZERO( tiles.quic.regular_transaction_listen_port );
     492           6 :   CFG_HAS_NON_ZERO( tiles.quic.quic_transaction_listen_port );
     493           6 :   CFG_HAS_NON_ZERO( tiles.quic.max_concurrent_connections );
     494           6 :   CFG_HAS_NON_ZERO( tiles.quic.txn_reassembly_count );
     495           6 :   CFG_HAS_NON_ZERO( tiles.quic.max_concurrent_handshakes );
     496           6 :   CFG_HAS_NON_ZERO( tiles.quic.idle_timeout_millis );
     497             : 
     498           6 :   CFG_HAS_NON_ZERO( tiles.verify.signature_cache_size );
     499           6 :   CFG_HAS_NON_ZERO( tiles.verify.receive_buffer_size );
     500             : 
     501           6 :   CFG_HAS_NON_ZERO( tiles.dedup.signature_cache_size );
     502             : 
     503           6 :   CFG_HAS_NON_ZERO( tiles.pack.max_pending_transactions );
     504             : 
     505           6 :   CFG_HAS_NON_ZERO( tiles.shred.max_pending_shred_sets );
     506           6 :   CFG_HAS_NON_ZERO( tiles.shred.shred_listen_port );
     507             : 
     508           6 :   CFG_HAS_NON_ZERO( tiles.metric.prometheus_listen_port );
     509             : 
     510           6 :   CFG_HAS_NON_ZERO( tiles.gui.gui_listen_port );
     511             : 
     512           6 :   if( strcmp( cfg->development.net.provider, "xdp" ) &&
     513           6 :       strcmp( cfg->development.net.provider, "socket" ) ) {
     514           0 :     FD_LOG_ERR(( "invalid `development.net.provider`: must be \"xdp\" or \"socket\"" ));
     515           0 :   }
     516             : 
     517           6 :   CFG_HAS_NON_EMPTY( development.netns.interface0 );
     518           6 :   CFG_HAS_NON_EMPTY( development.netns.interface0_mac );
     519           6 :   CFG_HAS_NON_EMPTY( development.netns.interface0_addr );
     520           6 :   CFG_HAS_NON_EMPTY( development.netns.interface1 );
     521           6 :   CFG_HAS_NON_EMPTY( development.netns.interface1_mac );
     522           6 :   CFG_HAS_NON_EMPTY( development.netns.interface1_addr );
     523             : 
     524           6 :   CFG_HAS_NON_ZERO( development.genesis.target_tick_duration_micros );
     525           6 :   CFG_HAS_NON_ZERO( development.genesis.ticks_per_slot );
     526           6 :   CFG_HAS_NON_ZERO( development.genesis.fund_initial_accounts );
     527           6 :   CFG_HAS_NON_ZERO( development.genesis.fund_initial_amount_lamports );
     528             : 
     529           6 :   CFG_HAS_NON_ZERO ( development.bench.benchg_tile_count );
     530           6 :   CFG_HAS_NON_ZERO ( development.bench.benchs_tile_count );
     531           6 :   CFG_HAS_NON_EMPTY( development.bench.affinity );
     532             : 
     533           6 : # undef CFG_HAS_NON_EMPTY
     534           6 : # undef CFG_HAS_NON_ZERO
     535           6 : # undef CFG_HAS_POW2
     536           6 : }

Generated by: LCOV version 1.14