LCOV - code coverage report
Current view: top level - app/shared - fd_config.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 1 0.0 %
Date: 2026-08-04 05:20:02 Functions: 0 0 -

          Line data    Source code
       1             : #ifndef HEADER_fd_src_app_shared_fd_config_h
       2             : #define HEADER_fd_src_app_shared_fd_config_h
       3             : 
       4             : #include "../../disco/topo/fd_topo.h"
       5             : #include "../../ballet/base58/fd_base58.h"
       6             : 
       7             : #include <net/if.h>
       8             : 
       9           0 : #define NAME_SZ                     (256UL)
      10             : #define AFFINITY_SZ                 (256UL)
      11             : #define CONFIGURE_STAGE_COUNT       ( 24UL)
      12             : #define GOSSIP_TILE_ENTRYPOINTS_MAX ( 16UL)
      13             : #define IP4_PORT_STR_MAX            ( 22UL)
      14             : 
      15             : struct fd_configh {
      16             :   char dynamic_port_range[ 32 ];
      17             : 
      18             :   struct {
      19             :     char  ledger[ PATH_MAX ];
      20             :     char  accounts_path[ PATH_MAX ];
      21             :     ulong authorized_voter_paths_cnt;
      22             :     char  authorized_voter_paths[ 16 ][ PATH_MAX ];
      23             :   } paths;
      24             : 
      25             :   struct {
      26             :     char solana_metrics_config[ 512 ];
      27             :   } reporting;
      28             : 
      29             :   struct {
      30             :     uint  limit_size;
      31             :     ulong account_indexes_cnt;
      32             :     char  account_indexes[ 4 ][ 32 ];
      33             :     ulong account_index_include_keys_cnt;
      34             :     char  account_index_include_keys[ 32 ][ FD_BASE58_ENCODED_32_SZ ];
      35             :     ulong account_index_exclude_keys_cnt;
      36             :     char  account_index_exclude_keys[ 32 ][ FD_BASE58_ENCODED_32_SZ ];
      37             :     int   enable_accounts_disk_index;
      38             :     char  accounts_index_path[ PATH_MAX ];
      39             :     char  accounts_hash_cache_path[ PATH_MAX ];
      40             :     int   require_tower;
      41             :     char  snapshot_archive_format[ 10 ];
      42             :   } ledger;
      43             : 
      44             :   struct {
      45             :     int    port_check;
      46             :   } gossip;
      47             : 
      48             :   struct {
      49             :     int    snapshot_fetch;
      50             :     int    genesis_fetch;
      51             :     int    poh_speed_test;
      52             :     char   expected_genesis_hash[ FD_BASE58_ENCODED_32_SZ ];
      53             :     uint   wait_for_supermajority_at_slot;
      54             :     char   expected_bank_hash[ FD_BASE58_ENCODED_32_SZ ];
      55             :     int    wait_for_vote_to_start_leader;
      56             :     ulong  hard_fork_at_slots_cnt;
      57             :     uint   hard_fork_at_slots[ 32 ];
      58             :     ulong  known_validators_cnt;
      59             :     char   known_validators[ 16 ][ 256 ];
      60             :     int    os_network_limits_test;
      61             :   } consensus;
      62             : 
      63             :   struct {
      64             :     ushort port;
      65             :     int    extended_tx_metadata_storage;
      66             :     int    full_api;
      67             :     int    private;
      68             :     char   bind_address[ 16 ];
      69             :     char   public_address[ IP4_PORT_STR_MAX ];
      70             :     int    transaction_history;
      71             :     int    only_known;
      72             :     int    pubsub_enable_block_subscription;
      73             :     int    pubsub_enable_vote_subscription;
      74             :     int    bigtable_ledger_storage;
      75             :   } rpc;
      76             : 
      77             :   struct {
      78             :     int  enabled;
      79             :     int  incremental_snapshots;
      80             :     uint full_snapshot_interval_slots;
      81             :     uint incremental_snapshot_interval_slots;
      82             :     uint minimum_snapshot_download_speed;
      83             :     uint maximum_snapshot_download_abort;
      84             :     uint maximum_full_snapshots_to_retain;
      85             :     uint maximum_incremental_snapshots_to_retain;
      86             :     char path[ PATH_MAX ];
      87             :     char incremental_path[ PATH_MAX ];
      88             :   } snapshots;
      89             : 
      90             :   struct {
      91             :     uint bank_tile_count;
      92             :     uint resolh_tile_count;
      93             :     char agave_affinity[ AFFINITY_SZ ];
      94             :     uint agave_unified_scheduler_handler_threads;
      95             :   } layout;
      96             : };
      97             : 
      98             : typedef struct fd_configh fd_configh_t;
      99             : 
     100             : struct fd_configf {
     101             :   struct {
     102             :     ulong max_accounts;
     103             :     ulong cache_size_gib;
     104             :   } accounts;
     105             : 
     106             :   struct {
     107             :     int  enable_block_production;
     108             :     uint sign_tile_count;
     109             :     uint gossvf_tile_count;
     110             :     uint resolv_tile_count;
     111             :     uint execle_tile_count;
     112             :     uint execrp_tile_count;
     113             :   } layout;
     114             : 
     115             :   struct {
     116             :     ulong max_live_slots;
     117             :     ulong max_fork_width;
     118             : 
     119             :     struct {
     120             :       ulong heap_size_mib;
     121             :       ulong mean_cache_entry_size;
     122             :     } program_cache;
     123             :   } runtime;
     124             : 
     125             :   struct {
     126             :     char host[ 256 ];
     127             :   } gossip;
     128             : 
     129             :   struct {
     130             :     char wait_for_supermajority_with_bank_hash[ FD_BASE58_ENCODED_32_SZ ];
     131             :   } consensus;
     132             : 
     133             :   struct {
     134             :     struct {
     135             :       uint max_local_full_effective_age;
     136             :       uint max_local_incremental_age;
     137             : 
     138             :       struct {
     139             :         int   allow_any;
     140             :         ulong allow_list_cnt;
     141             :         char  allow_list[ FD_TOPO_SNAPSHOTS_GOSSIP_LIST_MAX ][ FD_BASE58_ENCODED_32_SZ ];
     142             :         ulong block_list_cnt;
     143             :         char  block_list[ FD_TOPO_SNAPSHOTS_GOSSIP_LIST_MAX ][ FD_BASE58_ENCODED_32_SZ ];
     144             :       } gossip;
     145             : 
     146             :       ulong servers_cnt;
     147             :       char  servers[ FD_TOPO_SNAPSHOTS_SERVERS_MAX ][ 128 ];
     148             :     } sources;
     149             : 
     150             :     int  incremental_snapshots;
     151             :     int  genesis_download;
     152             :     uint max_full_snapshots_to_keep;
     153             :     uint max_incremental_snapshots_to_keep;
     154             :     uint max_retry_abort;
     155             :     uint min_download_speed_mibs;
     156             :     ulong wait_for_peers_timeout_seconds;
     157             :   } snapshots;
     158             : 
     159             :   struct {
     160             :     int hard_fork_fatal;
     161             :     int fixed_fec_sets;
     162             :     struct {
     163             :       int validate_genesis_hash;
     164             :     } genesis;
     165             : 
     166             :     struct {
     167             :       char  format[ 16 ];
     168             :       char  path[ PATH_MAX ];
     169             :       ulong end_slot;
     170             :     } ledger_input;
     171             : 
     172             :     struct {
     173             :       char  affinity[ AFFINITY_SZ ];
     174             :       ulong root_distance;
     175             :     } backtest;
     176             : 
     177             :     struct {
     178             :       char affinity[ AFFINITY_SZ ];
     179             :     } forktest;
     180             :   } development;
     181             : 
     182             :   struct {
     183             :     char path[ PATH_MAX ];
     184             :   } capctx;
     185             : 
     186             :   struct {
     187             :     ulong authorized_voter_paths_cnt;
     188             :     char  authorized_voter_paths[ 16 ][ PATH_MAX ];
     189             :   } paths;
     190             : 
     191             : };
     192             : 
     193             : typedef struct fd_configf fd_configf_t;
     194             : 
     195             : struct fd_config_net {
     196             :   char auto_level[ 12 ]; /* "standard" or "minimal" */
     197             : 
     198             :   char provider[ 8 ]; /* "xdp" or "socket" */
     199             : 
     200             :   char interface[ IF_NAMESIZE ];
     201             :   char bind_address[ 16 ];
     202             :   uint bind_address_parsed;
     203             :   uint ip_addr;
     204             : 
     205             :   uint ingress_buffer_size;
     206             : 
     207             :   struct {
     208             :     char xdp_mode[ 8 ]; /* "drv", "skb" or "auto" */
     209             :     int  xdp_zero_copy; /* true/false or "auto" */
     210             :     char poll_mode[ 16 ]; /* "prefbusy", "softirq" or "auto" */
     211             : 
     212             :     uint xdp_rx_queue_size;
     213             :     uint xdp_tx_queue_size;
     214             :     uint flush_timeout_micros;
     215             :     char rss_queue_mode[ 16 ]; /* "simple", "dedicated", or "auto" */
     216             :     int  listen_gre;
     217             :     int  native_bond; /* true/false or "auto" */
     218             :   } xdp;
     219             : 
     220             :   struct {
     221             :     uint receive_buffer_size;
     222             :     uint send_buffer_size;
     223             :   } socket;
     224             : };
     225             : typedef struct fd_config_net fd_config_net_t;
     226             : 
     227             : struct fd_config {
     228             :   char name[ NAME_SZ ];
     229             :   char user[ 256 ];
     230             :   char hostname[ FD_LOG_NAME_MAX ];
     231             : 
     232             :   int telemetry;
     233             : 
     234             :   double tick_per_ns_mu;
     235             :   double tick_per_ns_sigma;
     236             : 
     237             :   long boot_timestamp_nanos;
     238             : 
     239             :   fd_topo_t topo;
     240             : 
     241             :   char cluster[ 32 ];
     242             :   int is_live_cluster;
     243             : 
     244             :   uint uid;
     245             :   uint gid;
     246             : 
     247             :   int is_firedancer;
     248             :   int is_dev;
     249             :   int has_user_config;
     250             :   union {
     251             :     fd_configh_t frankendancer;
     252             :     fd_configf_t firedancer;
     253             :   };
     254             : 
     255             :   /* The name of the action being executed (e.g. "run", "dev",
     256             :      "backtest").  Populated by fd_main before topo_init runs. */
     257             :   char action[ 16 ];
     258             : 
     259             :   struct {
     260             :     char base[ PATH_MAX ];
     261             :     char identity_key[ PATH_MAX ];
     262             :     char vote_account[ PATH_MAX ];
     263             :     char snapshots[ PATH_MAX ];
     264             :     char genesis[ PATH_MAX ];
     265             :     char accounts[ PATH_MAX ];
     266             :     char shredb[ PATH_MAX ];
     267             :     char guidb[ PATH_MAX ];
     268             :   } paths;
     269             : 
     270             :   struct {
     271             :     char path[ PATH_MAX ];
     272             :     char colorize[ 6 ];
     273             :     int  colorize1;
     274             :     char level_logfile[ 8 ];
     275             :     int  level_logfile1;
     276             :     char level_stderr[ 8 ];
     277             :     int  level_stderr1;
     278             :     char level_flush[ 8 ];
     279             :     int  level_flush1;
     280             : 
     281             :     /* File descriptor used for logging to the log file.  Stashed
     282             :        here for easy communication to child processes. */
     283             :     int  log_fd;
     284             :   } log;
     285             : 
     286             :   /* Necessary to output auto config's decisions/observed system info
     287             :      to log file, since auto config runs before the log file is setup. */
     288             :   char auto_config_log[ 512 ];
     289             : 
     290             :   struct {
     291             :     ushort expected_shred_version;
     292             :     char   expected_genesis_hash[ FD_BASE58_ENCODED_32_SZ ];
     293             : 
     294             :     int wait_for_vote_to_start_leader;
     295             :   } consensus;
     296             : 
     297             :   struct {
     298             :     ulong         entrypoints_cnt;
     299             :     char          entrypoints[ GOSSIP_TILE_ENTRYPOINTS_MAX ][ 262 ];
     300             :     ushort        port;
     301             :   } gossip;
     302             : 
     303             :   struct {
     304             :     char affinity[ AFFINITY_SZ ];
     305             :     char blocklist_cores[ AFFINITY_SZ ];
     306             : 
     307             :     uint net_tile_count;
     308             :     uint quic_tile_count;
     309             :     uint verify_tile_count;
     310             :     uint shred_tile_count;
     311             :   } layout;
     312             : 
     313             :   struct {
     314             :     char  gigantic_page_mount_path[ PATH_MAX ];
     315             :     char  huge_page_mount_path[ PATH_MAX ];
     316             :     char  normal_page_mount_path[ PATH_MAX ];
     317             :     char  mount_path[ PATH_MAX ];
     318             :     char  max_page_size[ 16 ];
     319             :     ulong gigantic_page_threshold_mib;
     320             :   } hugetlbfs;
     321             : 
     322             :   fd_config_net_t net;
     323             : 
     324             :   struct {
     325             :     int sandbox;
     326             :     int no_clone;
     327             :     int no_agave;
     328             :     int bootstrap;
     329             : 
     330             :     char core_dump[ 16 ];
     331             :     int core_dump_level;
     332             : 
     333             :     struct {
     334             :       int allow_private_address;
     335             :     } gossip;
     336             : 
     337             :     struct {
     338             :       ulong hashes_per_tick;
     339             :       ulong target_tick_duration_micros;
     340             :       ulong ticks_per_slot;
     341             :       ulong fund_initial_accounts;
     342             :       ulong fund_initial_amount_lamports;
     343             :       ulong vote_account_stake_lamports;
     344             :       int   warmup_epochs;
     345             :     } genesis;
     346             : 
     347             :     struct {
     348             :       uint  benchg_tile_count;
     349             :       uint  benchs_tile_count;
     350             :       char  affinity[ AFFINITY_SZ ];
     351             :       int   larger_max_cost_per_block;
     352             :       int   larger_shred_limits_per_block;
     353             :       ulong disable_blockstore_from_slot;
     354             :       int   disable_status_cache;
     355             :     } bench;
     356             : 
     357             :     struct {
     358             :       char ssl_key_log_file[ PATH_MAX ];
     359             :       uint buffer_size_kib;
     360             :       uint ssl_heap_size_mib;
     361             :     } bundle;
     362             : 
     363             :     struct {
     364             :       int report_shreds;
     365             :       int report_transactions;
     366             :       int report_transaction_diffs;
     367             :     } event;
     368             : 
     369             :     struct {
     370             :       char affinity[ AFFINITY_SZ ];
     371             :       char fake_dst_ip[ 16 ];
     372             :     } pktgen;
     373             : 
     374             :     struct {
     375             :       char affinity[ AFFINITY_SZ ];
     376             :     } udpecho;
     377             : 
     378             :     struct {
     379             :       char affinity[ AFFINITY_SZ ];
     380             :     } snapshot_load;
     381             : 
     382             :     struct {
     383             :       int websocket_compression;
     384             :     } gui;
     385             : 
     386             :     struct {
     387             :       ulong partition_size_gib;
     388             :     } accdb;
     389             : 
     390             :     struct {
     391             :       int min_size;
     392             :     } hugetlbfs;
     393             :   } development;
     394             : 
     395             :   struct {
     396             :     struct {
     397             :       ulong max_routes;
     398             :       ulong max_peer_routes;
     399             :       ulong max_neighbors;
     400             :     } netlink;
     401             : 
     402             :     struct {
     403             :       ulong max_entries;
     404             :     } gossip;
     405             : 
     406             :     struct {
     407             :       ushort regular_transaction_listen_port;
     408             :       ushort quic_transaction_listen_port;
     409             : 
     410             :       uint txn_reassembly_count;
     411             :       uint max_concurrent_connections;
     412             :       uint max_concurrent_handshakes;
     413             :       uint idle_timeout_millis;
     414             :       uint ack_delay_millis;
     415             :       int  retry;
     416             : 
     417             :       char ssl_key_log_file[ PATH_MAX ];
     418             :     } quic;
     419             : 
     420             :     struct {
     421             :       ushort txsend_src_port;
     422             :     } txsend;
     423             : 
     424             :     struct {
     425             :       uint signature_cache_size;
     426             :       uint receive_buffer_size;
     427             :       uint mtu;
     428             :     } verify;
     429             : 
     430             :     struct {
     431             :       uint signature_cache_size;
     432             :     } dedup;
     433             : 
     434             :     struct {
     435             :       int  enabled;
     436             :       char url[ 256 ];
     437             :       char tls_domain_name[ 256 ];
     438             :       char tip_distribution_program_addr[ FD_BASE58_ENCODED_32_SZ ];
     439             :       char tip_payment_program_addr[ FD_BASE58_ENCODED_32_SZ ];
     440             :       char tip_distribution_authority[ FD_BASE58_ENCODED_32_SZ ];
     441             :       uint commission_bps;
     442             :       ulong keepalive_interval_millis;
     443             :       int   tls_cert_verify;
     444             :     } bundle;
     445             : 
     446             :     struct {
     447             :       uint  max_pending_transactions;
     448             :       int   use_consumed_cus;
     449             :       char  schedule_strategy[ 16 ];
     450             :       int   schedule_strategy_enum;
     451             :       ulong account_blocklist_cnt;
     452             :       char  account_blocklist[ FD_PACK_ACCT_BLOCKLIST_MAX ][ FD_BASE58_ENCODED_32_SZ ];
     453             :     } pack;
     454             : 
     455             :     struct {
     456             :       int lagged_consecutive_leader_start;
     457             :     } pohh;
     458             : 
     459             :     struct {
     460             :       uint   max_pending_shred_sets;
     461             :       ushort shred_listen_port;
     462             :       ulong  additional_shred_destinations_retransmit_cnt;
     463             :       char   additional_shred_destinations_retransmit[ FD_TOPO_ADTL_DESTS_MAX ][ sizeof("255.255.255.255:65536") ];
     464             :       ulong  additional_shred_destinations_leader_cnt;
     465             :       char   additional_shred_destinations_leader[ FD_TOPO_ADTL_DESTS_MAX ][ sizeof("255.255.255.255:65536") ];
     466             :     } shred;
     467             : 
     468             :     struct {
     469             :       char   prometheus_listen_address[ 16 ];
     470             :       ushort prometheus_listen_port;
     471             :     } metric;
     472             : 
     473             :     struct {
     474             :       char url[ 256 ];
     475             :     } event;
     476             : 
     477             :     struct {
     478             :       int    enabled;
     479             :       char   gui_listen_address[ 16 ];
     480             :       ushort gui_listen_port;
     481             :       ulong  max_http_connections;
     482             :       ulong  max_websocket_connections;
     483             :       ulong  max_http_request_length;
     484             :       ulong  send_buffer_size_mb;
     485             :       ulong  db_size_gib;
     486             :     } gui;
     487             : 
     488             :     struct {
     489             :       int    enabled;
     490             :       char   rpc_listen_address[ 16 ];
     491             :       ushort rpc_listen_port;
     492             :       ulong  max_http_connections;
     493             :       ulong  max_websocket_connections;
     494             :       ulong  max_http_request_length;
     495             :       ulong  send_buffer_size_mb;
     496             :       int    delay_startup;
     497             :     } rpc;
     498             : 
     499             :     struct {
     500             :       ushort repair_client_listen_port;
     501             :       ulong  slot_max;
     502             :     } repair;
     503             : 
     504             :     struct {
     505             :       int    enabled;
     506             :       ushort repair_serve_listen_port;
     507             :       ulong  shred_storage_limit_gib;
     508             :     } rserve;
     509             : 
     510             :     struct {
     511             :       ulong max_transaction_lookahead_buffer_size;
     512             :       ulong enable_features_cnt;
     513             :       char  enable_features[ 16 ][ FD_BASE58_ENCODED_32_SZ ];
     514             :     } replay;
     515             : 
     516             :   } tiles;
     517             :   struct {
     518             :     ulong capture_start_slot;
     519             :     char  dump_proto_dir[ PATH_MAX ];
     520             :     char  dump_syscall_name_filter[ PATH_MAX ];
     521             :     char  dump_instr_program_id_filter[ FD_BASE58_ENCODED_32_SZ ];
     522             :     char  solcap_capture[ PATH_MAX ];
     523             :     int   recent_only;
     524             :     ulong recent_slots_per_file;
     525             :     int   dump_syscall_to_pb;
     526             :     int   dump_instr_to_pb;
     527             :     int   dump_txn_to_pb;
     528             :     int   dump_txn_as_fixture;
     529             :     int   dump_block_to_pb;
     530             :   } capture;
     531             : };
     532             : 
     533             : typedef struct fd_config fd_config_t;
     534             : typedef struct fd_config config_t;
     535             : 
     536             : FD_PROTOTYPES_BEGIN
     537             : 
     538             : /* fd_config_load() loads a fd_config_t object from the contents of a
     539             :    configuration file.  This is not a simple transformation of the file,
     540             :    and involves multiple steps.  The default configuration file is
     541             :    loaded first, and then the user configuration file (if non-NULL) is
     542             :    loaded and overlaid on top of it.
     543             : 
     544             :    The resulting raw configuration is then transformed to a full config
     545             :    object by doing various parsing, validation, and filling in of extra
     546             :    data from the operating system.
     547             : 
     548             :    This function will not return on error, and will print an error
     549             :    message and exit the process.  On success, the config object will be
     550             :    returned as a fully filled in, validated, and ready to use object. */
     551             : 
     552             : void
     553             : fd_config_load( int           is_firedancer,
     554             :                 int           is_local_cluster,
     555             :                 char const *  default_config,
     556             :                 ulong         default_config_sz,
     557             :                 char const *  override_config,
     558             :                 char const *  override_config_path,
     559             :                 ulong         override_config_sz,
     560             :                 char const *  user_config,
     561             :                 ulong         user_config_sz,
     562             :                 char const *  user_config_path,
     563             :                 fd_config_t * config,
     564             :                 int           dev );
     565             : 
     566             : /* Create a memfd and write the raw underlying bytes of the provided
     567             :    config struct into it.  On success returns a file descriptor
     568             :    representing the memfd.  On failure, returns -1 and errno will be
     569             :    set appropriately.
     570             : 
     571             :    The memfd is created with flags of 0.  The caller of the function can
     572             :    use it to pass a loaded config struct to child processes that are
     573             :    spawned with `execve(2)`, which would otherwise not be able to share
     574             :    memory with the forking process. */
     575             : 
     576             : int
     577             : fd_config_to_memfd( fd_config_t const * config );
     578             : 
     579             : FD_PROTOTYPES_END
     580             : 
     581             : #endif /* HEADER_fd_src_app_shared_fd_config_h */

Generated by: LCOV version 1.14