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: 2025-03-20 12:08:36 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 "fd_cap_chk.h"
       5             : #include "../../disco/topo/fd_topo.h"
       6             : #include "../../util/net/fd_net_headers.h" /* fd_ip4_port_t */
       7             : 
       8             : #include <net/if.h>
       9             : #include <linux/limits.h>
      10             : 
      11             : #define NAME_SZ 256
      12             : #define AFFINITY_SZ 256
      13           0 : #define CONFIGURE_STAGE_COUNT 12
      14             : 
      15             : union fdctl_args {
      16             :   struct {
      17             :     char  tile_name[ 7UL ];
      18             :     ulong kind_id;
      19             :     int   pipe_fd;
      20             :   } run1;
      21             : 
      22             :   struct {
      23             :     long dt_min;
      24             :     long dt_max;
      25             :     long duration;
      26             :     uint seed;
      27             :     double ns_per_tic;
      28             :     int drain_output_fd;
      29             :     int with_bench;
      30             :     int with_sankey;
      31             :   } monitor;
      32             : 
      33             :   struct {
      34             :     int                      command;
      35             :     struct configure_stage * stages[ CONFIGURE_STAGE_COUNT ];
      36             :   } configure;
      37             : 
      38             :   struct {
      39             :     int     require_tower;
      40             :     int     force;
      41             :     uchar * keypair;
      42             :   } set_identity;
      43             : 
      44             :   struct {
      45             :     int  parent_pipefd;
      46             :     int  monitor;
      47             :     int  no_configure;
      48             :     int  no_init_workspaces;
      49             :     int  no_agave;
      50             :     char debug_tile[ 32 ];
      51             :   } dev;
      52             : 
      53             :   struct {
      54             :     char tile_name[ 7UL ];
      55             :     int  no_configure;
      56             :   } dev1;
      57             : 
      58             :   struct {
      59             :     ulong cmd;
      60             :     char  file_path[ 256 ];
      61             :   } keys;
      62             : 
      63             :   struct {
      64             :     const char * payload_base64;
      65             :     ulong  count;
      66             :     const char * dst_ip;
      67             :     ushort dst_port;
      68             :   } txn;
      69             : 
      70             :   struct {
      71             :     char link_name[ 64UL ];
      72             :     char pcap_path[ 256UL ];
      73             :   } dump;
      74             : 
      75             :   struct {
      76             :     char name[ 13UL ];
      77             :   } flame;
      78             : 
      79             :   struct {
      80             :     char    affinity[ AFFINITY_SZ ];
      81             :     uint    tpu_ip;
      82             :     uint    rpc_ip;
      83             :     ushort  tpu_port;
      84             :     ushort  rpc_port;
      85             :     ulong   accounts;
      86             :     ulong   connections;
      87             :     ulong   benchg;
      88             :     ulong   benchs;
      89             :     int     no_quic;
      90             :     int     transaction_mode;
      91             :     float   contending_fraction;
      92             :     float   cu_price_spread;
      93             :   } load; /* also used by bench */
      94             : 
      95             :   struct {
      96             :     int event;
      97             :     int dump; /* whether the user requested --dump */
      98             :   } quic_trace;
      99             : };
     100             : 
     101             : typedef union fdctl_args args_t;
     102             : 
     103             : struct fd_config {
     104             :   char name[ NAME_SZ ];
     105             :   char user[ 256 ];
     106             :   char hostname[ FD_LOG_NAME_MAX ];
     107             : 
     108             :   double tick_per_ns_mu;
     109             :   double tick_per_ns_sigma;
     110             : 
     111             :   fd_topo_t topo;
     112             : 
     113             :   char cluster[ 32 ];
     114             :   int is_live_cluster;
     115             : 
     116             :   uint uid;
     117             :   uint gid;
     118             : 
     119             :   char scratch_directory[ PATH_MAX ];
     120             : 
     121             :   char dynamic_port_range[ 32 ];
     122             : 
     123             :   struct {
     124             :     char path[ PATH_MAX ];
     125             :     char colorize[ 6 ];
     126             :     int  colorize1;
     127             :     char level_logfile[ 8 ];
     128             :     int  level_logfile1;
     129             :     char level_stderr[ 8 ];
     130             :     int  level_stderr1;
     131             :     char level_flush[ 8 ];
     132             :     int  level_flush1;
     133             : 
     134             :     /* File descriptor used for logging to the log file.  Stashed
     135             :        here for easy communication to child processes. */
     136             :     int  log_fd;
     137             : 
     138             :     /* Shared memfd_create file descriptor where the first 4
     139             :        bytes are the lock object for log sequencing.  Kind of
     140             :        gross to stash this in here. */
     141             :     int  lock_fd;
     142             :   } log;
     143             : 
     144             :   struct {
     145             :     char solana_metrics_config[ 512 ];
     146             :   } reporting;
     147             : 
     148             :   struct {
     149             :     char  path[ PATH_MAX ];
     150             :     char  accounts_path[ PATH_MAX ];
     151             :     uint  limit_size;
     152             :     ulong account_indexes_cnt;
     153             :     char  account_indexes[ 4 ][ 32 ];
     154             :     ulong account_index_include_keys_cnt;
     155             :     char  account_index_include_keys[ 32 ][ FD_BASE58_ENCODED_32_SZ ];
     156             :     ulong account_index_exclude_keys_cnt;
     157             :     char  account_index_exclude_keys[ 32 ][ FD_BASE58_ENCODED_32_SZ ];
     158             :     char  accounts_index_path[ PATH_MAX ];
     159             :     char  accounts_hash_cache_path[ PATH_MAX ];
     160             :     int   require_tower;
     161             :     char  snapshot_archive_format[ 10 ];
     162             :   } ledger;
     163             : 
     164             :   struct {
     165             : #   define FD_CONFIG_GOSSIP_ENTRYPOINTS_MAX 16
     166             :     ulong  entrypoints_cnt;
     167             :     char   entrypoints[ FD_CONFIG_GOSSIP_ENTRYPOINTS_MAX ][ 262 ];
     168             :     ulong         resolved_entrypoints_cnt;
     169             :     fd_ip4_port_t resolved_entrypoints[ FD_CONFIG_GOSSIP_ENTRYPOINTS_MAX ];
     170             :     int    port_check;
     171             :     ushort port;
     172             :     char   host[ 256 ];
     173             :   } gossip;
     174             : 
     175             :   struct {
     176             :     int    vote;
     177             :     char   identity_path[ PATH_MAX ];
     178             :     char   vote_account_path[ PATH_MAX ];
     179             :     ulong  authorized_voter_paths_cnt;
     180             :     char   authorized_voter_paths[ 16 ][ PATH_MAX ];
     181             :     int    snapshot_fetch;
     182             :     int    genesis_fetch;
     183             :     int    poh_speed_test;
     184             :     char   expected_genesis_hash[ FD_BASE58_ENCODED_32_SZ ];
     185             :     uint   wait_for_supermajority_at_slot;
     186             :     char   expected_bank_hash[ FD_BASE58_ENCODED_32_SZ ];
     187             :     ushort expected_shred_version;
     188             :     int    wait_for_vote_to_start_leader;
     189             :     ulong  hard_fork_at_slots_cnt;
     190             :     uint   hard_fork_at_slots[ 32 ];
     191             :     ulong  known_validators_cnt;
     192             :     char   known_validators[ 16 ][ 256 ];
     193             :     int    os_network_limits_test;
     194             :   } consensus;
     195             : 
     196             :   struct {
     197             :     ushort port;
     198             :     int    full_api;
     199             :     int    private;
     200             :     char   bind_address[ 16 ];
     201             :     int    transaction_history;
     202             :     int    extended_tx_metadata_storage;
     203             :     int    only_known;
     204             :     int    pubsub_enable_block_subscription;
     205             :     int    pubsub_enable_vote_subscription;
     206             :     int    bigtable_ledger_storage;
     207             :   } rpc;
     208             : 
     209             :   struct {
     210             :     int  enabled;
     211             :     int  incremental_snapshots;
     212             :     uint full_snapshot_interval_slots;
     213             :     uint incremental_snapshot_interval_slots;
     214             :     uint minimum_snapshot_download_speed;
     215             :     uint maximum_full_snapshots_to_retain;
     216             :     uint maximum_incremental_snapshots_to_retain;
     217             :     char path[ PATH_MAX ];
     218             :     char incremental_path[ PATH_MAX ];
     219             :   } snapshots;
     220             : 
     221             :   struct {
     222             :     char affinity[ AFFINITY_SZ ];
     223             :     char agave_affinity[ AFFINITY_SZ ];
     224             : 
     225             :     uint agave_unified_scheduler_handler_threads;
     226             :     uint net_tile_count;
     227             :     uint quic_tile_count;
     228             :     uint resolv_tile_count;
     229             :     uint verify_tile_count;
     230             :     uint bank_tile_count;
     231             :     uint shred_tile_count;
     232             :     uint exec_tile_count; /* TODO: redundant ish with bank tile cnt */
     233             :   } layout;
     234             : 
     235             :   struct {
     236             :     char gigantic_page_mount_path[ PATH_MAX ];
     237             :     char huge_page_mount_path[ PATH_MAX ];
     238             :     char mount_path[ PATH_MAX ];
     239             :     char max_page_size[ 16 ];
     240             :     ulong gigantic_page_threshold_mib;
     241             :   } hugetlbfs;
     242             : 
     243             :   struct {
     244             :     ulong shred_max;
     245             :     ulong block_max;
     246             :     ulong idx_max;
     247             :     ulong txn_max;
     248             :     ulong alloc_max;
     249             :     char  file[PATH_MAX];
     250             :     char  checkpt[PATH_MAX];
     251             :     char  restore[PATH_MAX];
     252             :   } blockstore;
     253             : 
     254             :   struct {
     255             :     int sandbox;
     256             :     int no_clone;
     257             :     int core_dump;
     258             :     int no_agave;
     259             :     int bootstrap;
     260             :     uint debug_tile;
     261             : 
     262             :     struct {
     263             :       char provider[ 8 ];
     264             :     } net;
     265             : 
     266             :     struct {
     267             :       int  enabled;
     268             :       char interface0     [ 16 ];
     269             :       char interface0_mac [ 32 ];
     270             :       char interface0_addr[ 16 ];
     271             :       char interface1     [ 16 ];
     272             :       char interface1_mac [ 32 ];
     273             :       char interface1_addr[ 16 ];
     274             :     } netns;
     275             : 
     276             :     struct {
     277             :       int allow_private_address;
     278             :     } gossip;
     279             : 
     280             :     struct {
     281             :       ulong hashes_per_tick;
     282             :       ulong target_tick_duration_micros;
     283             :       ulong ticks_per_slot;
     284             :       ulong fund_initial_accounts;
     285             :       ulong fund_initial_amount_lamports;
     286             :       ulong vote_account_stake_lamports;
     287             :       int   warmup_epochs;
     288             :     } genesis;
     289             : 
     290             :     struct {
     291             :       uint  benchg_tile_count;
     292             :       uint  benchs_tile_count;
     293             :       char  affinity[ AFFINITY_SZ ];
     294             :       int   larger_max_cost_per_block;
     295             :       int   larger_shred_limits_per_block;
     296             :       ulong disable_blockstore_from_slot;
     297             :       int   disable_status_cache;
     298             :     } bench;
     299             : 
     300             :     struct {
     301             :       char affinity[ AFFINITY_SZ ];
     302             :       char fake_dst_ip[ 16 ];
     303             :     } pktgen;
     304             :   } development;
     305             : 
     306             :   struct {
     307             :     struct {
     308             :       char   interface[ IF_NAMESIZE ];
     309             :       uint   ip_addr;
     310             :       char   xdp_mode[ 8 ];
     311             :       int    xdp_zero_copy;
     312             : 
     313             :       uint xdp_rx_queue_size;
     314             :       uint xdp_tx_queue_size;
     315             :       uint flush_timeout_micros;
     316             : 
     317             :       uint send_buffer_size;
     318             :     } net;
     319             : 
     320             :     struct {
     321             :       ulong max_routes;
     322             :       ulong max_neighbors;
     323             :     } netlink;
     324             : 
     325             :     struct {
     326             :       ushort regular_transaction_listen_port;
     327             :       ushort quic_transaction_listen_port;
     328             : 
     329             :       uint txn_reassembly_count;
     330             :       uint max_concurrent_connections;
     331             :       uint max_concurrent_handshakes;
     332             :       uint idle_timeout_millis;
     333             :       uint ack_delay_millis;
     334             :       int  retry;
     335             : 
     336             :     } quic;
     337             : 
     338             :     struct {
     339             :       uint signature_cache_size;
     340             :       uint receive_buffer_size;
     341             :       uint mtu;
     342             :     } verify;
     343             : 
     344             :     struct {
     345             :       uint signature_cache_size;
     346             :     } dedup;
     347             : 
     348             :     struct {
     349             :       int  enabled;
     350             :       char url[ 256 ];
     351             :       char tls_domain_name[ 256 ];
     352             :       char tip_distribution_program_addr[ FD_BASE58_ENCODED_32_SZ ];
     353             :       char tip_payment_program_addr[ FD_BASE58_ENCODED_32_SZ ];
     354             :       char tip_distribution_authority[ FD_BASE58_ENCODED_32_SZ ];
     355             :       uint commission_bps;
     356             :     } bundle;
     357             : 
     358             :     struct {
     359             :       uint max_pending_transactions;
     360             :       int  use_consumed_cus;
     361             :     } pack;
     362             : 
     363             :     struct {
     364             :       int lagged_consecutive_leader_start;
     365             :     } poh;
     366             : 
     367             :     struct {
     368             :       uint   max_pending_shred_sets;
     369             :       ushort shred_listen_port;
     370             :     } shred;
     371             : 
     372             :     struct {
     373             :       char   prometheus_listen_address[ 16 ];
     374             :       ushort prometheus_listen_port;
     375             :     } metric;
     376             : 
     377             :     struct {
     378             :       int    enabled;
     379             :       char   gui_listen_address[ 16 ];
     380             :       ushort gui_listen_port;
     381             :       ulong  max_http_connections;
     382             :       ulong  max_websocket_connections;
     383             :       ulong  max_http_request_length;
     384             :       ulong  send_buffer_size_mb;
     385             :     } gui;
     386             : 
     387             :     /* Firedancer-only tile configs */
     388             : 
     389             :     struct {
     390             :       ushort repair_intake_listen_port;
     391             :       ushort repair_serve_listen_port;
     392             :       char   good_peer_cache_file[ PATH_MAX ];
     393             :     } repair;
     394             : 
     395             :     struct {
     396             :       char  capture[ PATH_MAX ];
     397             :       char  funk_checkpt[ PATH_MAX ];
     398             :       ulong funk_rec_max;
     399             :       ulong funk_sz_gb;
     400             :       ulong funk_txn_max;
     401             :       char  funk_file[ PATH_MAX ];
     402             :       char  genesis[ PATH_MAX ];
     403             :       char  incremental[ PATH_MAX ];
     404             :       char  slots_replayed[PATH_MAX ];
     405             :       char  snapshot[ PATH_MAX ];
     406             :       char  status_cache[ PATH_MAX ];
     407             :       ulong tpool_thread_count;
     408             :       char  cluster_version[ 32 ];
     409             :       char  tower_checkpt[ PATH_MAX ];
     410             :     } replay;
     411             : 
     412             :     struct {
     413             :       char  slots_pending[PATH_MAX];
     414             :       char  shred_cap_archive[ PATH_MAX ];
     415             :       char  shred_cap_replay[ PATH_MAX ];
     416             :       ulong shred_cap_end_slot;
     417             :     } store_int;
     418             : 
     419             :     struct {
     420             :       ulong full_interval;
     421             :       ulong incremental_interval;
     422             :       char  out_dir[ PATH_MAX ];
     423             :       ulong hash_tpool_thread_count;
     424             :     } batch;
     425             : 
     426             :     struct {
     427             :       int   in_wen_restart;
     428             :       char  genesis_hash[ FD_BASE58_ENCODED_32_SZ ];
     429             :       char  wen_restart_coordinator[ FD_BASE58_ENCODED_32_SZ ];
     430             :     } restart;
     431             : 
     432             :   } tiles;
     433             : };
     434             : 
     435             : typedef struct fd_config fd_config_t;
     436             : typedef struct fd_config config_t;
     437             : 
     438             : struct fd_action {
     439             :   const char * name;
     440             :   const char * description;
     441             :   uchar        is_diagnostic;  /* 1 implies action should be allowed for prod debugging */
     442             : 
     443             :   void       (*args)( int * pargc, char *** pargv, args_t * args );
     444             :   void       (*perm)( args_t * args, fd_cap_chk_t * chk, config_t const * config );
     445             :   void       (*fn  )( args_t * args, config_t * config );
     446             : };
     447             : 
     448             : typedef struct fd_action action_t;
     449             : 
     450             : FD_PROTOTYPES_BEGIN
     451             : 
     452             : /* fdctl_cfg_from_env() loads a full configuration object from the provided
     453             :    arguments or the environment. First, the `default.toml` file is
     454             :    loaded as a base, and then if a FIREDANCER_CONFIG_FILE environment
     455             :    variable is provided, or a --config <path> command line argument, the
     456             :    `toml` file at that path is loaded and applied on top of the default
     457             :    configuration. This exits the program if it encounters any issue
     458             :    while loading or parsing the configuration. */
     459             : 
     460             : void
     461             : fdctl_cfg_from_env( int *      pargc,
     462             :                     char ***   pargv,
     463             :                     config_t * config );
     464             : 
     465             : /* Create a memfd and write the contents of the config struct into it.
     466             :    Used when execve() a child process so that it can read back in the
     467             :    same config as we did. */
     468             : 
     469             : int
     470             : fdctl_cfg_to_memfd( config_t const * config );
     471             : 
     472             : /* fdctl_cfg_net_auto attempts to automatically select an interface
     473             :    index and publicly routable IP address based on the current net
     474             :    configuration.  Existing interface/IP address config overrules the
     475             :    auto-selection logic. */
     476             : 
     477             : void
     478             : fdctl_cfg_net_auto( config_t * config );
     479             : 
     480             : FD_PROTOTYPES_END
     481             : 
     482             : #endif /* HEADER_fd_src_app_shared_fd_config_h */

Generated by: LCOV version 1.14