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