LCOV - code coverage report
Current view: top level - app/fdctl/run/topos - fd_frankendancer.c (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 252 342 73.7 %
Date: 2025-03-10 12:29:05 Functions: 1 1 100.0 %

          Line data    Source code
       1             : #include "../../fdctl.h"
       2             : #include "../../../../disco/net/fd_net_tile.h"
       3             : #include "../../../../disco/quic/fd_tpu.h"
       4             : #include "../../../../disco/tiles.h"
       5             : #include "../../../../disco/topo/fd_topob.h"
       6             : #include "../../../../disco/topo/fd_cpu_topo.h"
       7             : #include "../../../../disco/topo/fd_pod_format.h"
       8             : #include "../../../../disco/plugin/fd_plugin.h"
       9             : #include "../../../../util/tile/fd_tile_private.h"
      10             : #include "../../../../util/shmem/fd_shmem_private.h"
      11             : 
      12             : void
      13           3 : fd_topo_initialize( config_t * config ) {
      14           3 :   ulong net_tile_cnt    = config->layout.net_tile_count;
      15           3 :   ulong quic_tile_cnt   = config->layout.quic_tile_count;
      16           3 :   ulong verify_tile_cnt = config->layout.verify_tile_count;
      17           3 :   ulong resolv_tile_cnt = config->layout.resolv_tile_count;
      18           3 :   ulong bank_tile_cnt   = config->layout.bank_tile_count;
      19           3 :   ulong shred_tile_cnt  = config->layout.shred_tile_count;
      20             : 
      21           3 :   fd_topo_t * topo = { fd_topob_new( &config->topo, config->name ) };
      22           3 :   topo->max_page_size = fd_cstr_to_shmem_page_sz( config->hugetlbfs.max_page_size );
      23             : 
      24             :   /*             topo, name */
      25           3 :   fd_topob_wksp( topo, "metric_in"    );
      26           3 :   fd_topob_wksp( topo, "net_quic"     );
      27           3 :   fd_topob_wksp( topo, "net_shred"    );
      28           3 :   fd_topob_wksp( topo, "quic_verify"  );
      29           3 :   fd_topob_wksp( topo, "verify_dedup" );
      30           3 :   fd_topob_wksp( topo, "dedup_resolv" );
      31           3 :   fd_topob_wksp( topo, "resolv_pack"  );
      32           3 :   fd_topob_wksp( topo, "pack_bank"    );
      33           3 :   fd_topob_wksp( topo, "bank_poh"     );
      34           3 :   fd_topob_wksp( topo, "bank_busy"    );
      35           3 :   fd_topob_wksp( topo, "poh_shred"    );
      36           3 :   fd_topob_wksp( topo, "gossip_dedup" );
      37           3 :   fd_topob_wksp( topo, "shred_store"  );
      38           3 :   fd_topob_wksp( topo, "stake_out"    );
      39             : 
      40           3 :   fd_topob_wksp( topo, "shred_sign"   );
      41           3 :   fd_topob_wksp( topo, "sign_shred"   );
      42             : 
      43           3 :   fd_topob_wksp( topo, "quic"         );
      44           3 :   fd_topob_wksp( topo, "verify"       );
      45           3 :   fd_topob_wksp( topo, "dedup"        );
      46           3 :   fd_topob_wksp( topo, "resolv"       );
      47           3 :   fd_topob_wksp( topo, "pack"         );
      48           3 :   fd_topob_wksp( topo, "bank"         );
      49           3 :   fd_topob_wksp( topo, "poh"          );
      50           3 :   fd_topob_wksp( topo, "shred"        );
      51           3 :   fd_topob_wksp( topo, "store"        );
      52           3 :   fd_topob_wksp( topo, "sign"         );
      53           3 :   fd_topob_wksp( topo, "metric"       );
      54           3 :   fd_topob_wksp( topo, "cswtch"       );
      55             : 
      56         375 :   #define FOR(cnt) for( ulong i=0UL; i<cnt; i++ )
      57             : 
      58             :   /*                                  topo, link_name,      wksp_name,      depth,                                    mtu,                    burst */
      59           3 :   FOR(quic_tile_cnt)   fd_topob_link( topo, "quic_net",     "net_quic",     config->tiles.net.send_buffer_size,       FD_NET_MTU,             1UL );
      60           3 :   FOR(shred_tile_cnt)  fd_topob_link( topo, "shred_net",    "net_shred",    32768UL,                                  FD_NET_MTU,             1UL );
      61           3 :   FOR(quic_tile_cnt)   fd_topob_link( topo, "quic_verify",  "quic_verify",  config->tiles.verify.receive_buffer_size, FD_TPU_REASM_MTU,       config->tiles.quic.txn_reassembly_count );
      62          18 :   FOR(verify_tile_cnt) fd_topob_link( topo, "verify_dedup", "verify_dedup", config->tiles.verify.receive_buffer_size, FD_TPU_PARSED_MTU,      1UL );
      63           3 :   /**/                 fd_topob_link( topo, "gossip_dedup", "gossip_dedup", 2048UL,                                   FD_TPU_MTU,             1UL );
      64             :   /* dedup_pack is large currently because pack can encounter stalls when running at very high throughput rates that would
      65             :      otherwise cause drops. */
      66           3 :   /**/                 fd_topob_link( topo, "dedup_resolv", "dedup_resolv", 65536UL,                                  FD_TPU_PARSED_MTU,      1UL );
      67           3 :   FOR(resolv_tile_cnt) fd_topob_link( topo, "resolv_pack",  "resolv_pack",  65536UL,                                  FD_TPU_RESOLVED_MTU,    1UL );
      68           3 :   /**/                 fd_topob_link( topo, "stake_out",    "stake_out",    128UL,                                    40UL + 40200UL * 40UL,  1UL );
      69             :   /* pack_bank is shared across all banks, so if one bank stalls due to complex transactions, the buffer neeeds to be large so that
      70             :      other banks can keep proceeding. */
      71           3 :   /**/                 fd_topob_link( topo, "pack_bank",    "pack_bank",    65536UL,                                  USHORT_MAX,             1UL );
      72          12 :   FOR(bank_tile_cnt)   fd_topob_link( topo, "bank_poh",     "bank_poh",     16384UL,                                  USHORT_MAX,             1UL );
      73           3 :   /**/                 fd_topob_link( topo, "poh_pack",     "bank_poh",     128UL,                                    sizeof(fd_became_leader_t), 1UL );
      74           3 :   /**/                 fd_topob_link( topo, "poh_shred",    "poh_shred",    16384UL,                                  USHORT_MAX,             1UL );
      75           3 :   /**/                 fd_topob_link( topo, "crds_shred",   "poh_shred",    128UL,                                    8UL  + 40200UL * 38UL,  1UL );
      76           3 :   /**/                 fd_topob_link( topo, "replay_resol", "bank_poh",     128UL,                                    sizeof(fd_completed_bank_t), 1UL );
      77             :   /* See long comment in fd_shred.c for an explanation about the size of this dcache. */
      78           3 :   FOR(shred_tile_cnt)  fd_topob_link( topo, "shred_store",  "shred_store",  65536UL,                                  4UL*FD_SHRED_STORE_MTU, 4UL+config->tiles.shred.max_pending_shred_sets );
      79             : 
      80           3 :   FOR(shred_tile_cnt)  fd_topob_link( topo, "shred_sign",   "shred_sign",   128UL,                                    32UL,                   1UL );
      81           3 :   FOR(shred_tile_cnt)  fd_topob_link( topo, "sign_shred",   "sign_shred",   128UL,                                    64UL,                   1UL );
      82             : 
      83           3 :   ushort parsed_tile_to_cpu[ FD_TILE_MAX ];
      84             :   /* Unassigned tiles will be floating, unless auto topology is enabled. */
      85        3075 :   for( ulong i=0UL; i<FD_TILE_MAX; i++ ) parsed_tile_to_cpu[ i ] = USHORT_MAX;
      86             : 
      87           3 :   int is_auto_affinity = !strcmp( config->layout.affinity, "auto" );
      88           3 :   int is_agave_auto_affinity = !strcmp( config->layout.agave_affinity, "auto" );
      89             : 
      90           3 :   if( FD_UNLIKELY( is_auto_affinity != is_agave_auto_affinity ) ) {
      91           0 :     FD_LOG_ERR(( "The CPU affinity string in the configuration file under [layout.affinity] and [layout.agave_affinity] must both be set to 'auto' or both be set to a specific CPU affinity string." ));
      92           0 :   }
      93             : 
      94           3 :   fd_topo_cpus_t cpus[1];
      95           3 :   fd_topo_cpus_init( cpus );
      96             : 
      97           3 :   ulong affinity_tile_cnt = 0UL;
      98           3 :   if( FD_LIKELY( !is_auto_affinity ) ) affinity_tile_cnt = fd_tile_private_cpus_parse( config->layout.affinity, parsed_tile_to_cpu );
      99             : 
     100           3 :   ulong tile_to_cpu[ FD_TILE_MAX ] = {0};
     101           3 :   for( ulong i=0UL; i<affinity_tile_cnt; i++ ) {
     102           0 :     if( FD_UNLIKELY( parsed_tile_to_cpu[ i ]!=USHORT_MAX && parsed_tile_to_cpu[ i ]>=cpus->cpu_cnt ) )
     103           0 :       FD_LOG_ERR(( "The CPU affinity string in the configuration file under [layout.affinity] specifies a CPU index of %hu, but the system "
     104           0 :                    "only has %lu CPUs. You should either change the CPU allocations in the affinity string, or increase the number of CPUs "
     105           0 :                    "in the system.",
     106           0 :                    parsed_tile_to_cpu[ i ], cpus->cpu_cnt ));
     107           0 :     tile_to_cpu[ i ] = fd_ulong_if( parsed_tile_to_cpu[ i ]==USHORT_MAX, ULONG_MAX, (ulong)parsed_tile_to_cpu[ i ] );
     108           0 :   }
     109             : 
     110           3 :   fd_topos_net_tiles( topo, config, tile_to_cpu );
     111             : 
     112           3 :   FOR(net_tile_cnt) fd_topos_net_rx_link( topo, "net_quic",  i, config->tiles.net.send_buffer_size );
     113           3 :   FOR(net_tile_cnt) fd_topos_net_rx_link( topo, "net_shred", i, config->tiles.net.send_buffer_size );
     114             : 
     115             :   /*                                  topo, tile_name, tile_wksp, metrics_wksp, cpu_idx,                       is_agave, uses_keyswitch */
     116           3 :   FOR(quic_tile_cnt)   fd_topob_tile( topo, "quic",    "quic",    "metric_in",  tile_to_cpu[ topo->tile_cnt ], 0,        0 );
     117          18 :   FOR(verify_tile_cnt) fd_topob_tile( topo, "verify",  "verify",  "metric_in",  tile_to_cpu[ topo->tile_cnt ], 0,        0 );
     118           3 :   /**/                 fd_topob_tile( topo, "dedup",   "dedup",   "metric_in",  tile_to_cpu[ topo->tile_cnt ], 0,        0 );
     119           3 :   FOR(resolv_tile_cnt) fd_topob_tile( topo, "resolv",  "resolv",  "metric_in",  tile_to_cpu[ topo->tile_cnt ], 1,        0 );
     120           3 :   /**/                 fd_topob_tile( topo, "pack",    "pack",    "metric_in",  tile_to_cpu[ topo->tile_cnt ], 0,        config->tiles.bundle.enabled );
     121          12 :   FOR(bank_tile_cnt)   fd_topob_tile( topo, "bank",    "bank",    "metric_in",  tile_to_cpu[ topo->tile_cnt ], 1,        0 );
     122           3 :   /**/                 fd_topob_tile( topo, "poh",     "poh",     "metric_in",  tile_to_cpu[ topo->tile_cnt ], 1,        1 );
     123           3 :   FOR(shred_tile_cnt)  fd_topob_tile( topo, "shred",   "shred",   "metric_in",  tile_to_cpu[ topo->tile_cnt ], 0,        1 );
     124           3 :   /**/                 fd_topob_tile( topo, "store",   "store",   "metric_in",  tile_to_cpu[ topo->tile_cnt ], 1,        0 );
     125           3 :   /**/                 fd_topob_tile( topo, "sign",    "sign",    "metric_in",  tile_to_cpu[ topo->tile_cnt ], 0,        1 );
     126           3 :   /**/                 fd_topob_tile( topo, "metric",  "metric",  "metric_in",  tile_to_cpu[ topo->tile_cnt ], 0,        0 );
     127           3 :   /**/                 fd_topob_tile( topo, "cswtch",  "cswtch",  "metric_in",  tile_to_cpu[ topo->tile_cnt ], 0,        0 );
     128             : 
     129             :   /*                                      topo, tile_name, tile_kind_id, fseq_wksp,   link_name,      link_kind_id, reliable,            polled */
     130           6 :   FOR(net_tile_cnt) for( ulong j=0UL; j<quic_tile_cnt; j++ )
     131           3 :                        fd_topob_tile_in(  topo, "net",     i,            "metric_in", "quic_net",     j,            FD_TOPOB_UNRELIABLE, FD_TOPOB_POLLED ); /* No reliable consumers of networking fragments, may be dropped or overrun */
     132           6 :   FOR(net_tile_cnt) for( ulong j=0UL; j<shred_tile_cnt; j++ )
     133           3 :                        fd_topob_tile_in(  topo, "net",     i,            "metric_in", "shred_net",    j,            FD_TOPOB_UNRELIABLE, FD_TOPOB_POLLED ); /* No reliable consumers of networking fragments, may be dropped or overrun */
     134           3 :   FOR(net_tile_cnt)    fd_topob_tile_out( topo, "net",     i,                         "net_quic",     i                                                  );
     135           3 :   FOR(net_tile_cnt)    fd_topob_tile_out( topo, "net",     i,                         "net_shred",    i                                                  );
     136             : 
     137           6 :   FOR(quic_tile_cnt) for( ulong j=0UL; j<net_tile_cnt; j++ )
     138           3 :                        fd_topob_tile_in(  topo, "quic",    i,            "metric_in", "net_quic",     j,            FD_TOPOB_UNRELIABLE, FD_TOPOB_POLLED ); /* No reliable consumers of networking fragments, may be dropped or overrun */
     139           3 :   FOR(quic_tile_cnt)   fd_topob_tile_out( topo, "quic",    i,                         "quic_verify",  i                                                  );
     140           3 :   FOR(quic_tile_cnt)   fd_topob_tile_out( topo, "quic",    i,                         "quic_net",     i                                                  );
     141             :   /* All verify tiles read from all QUIC tiles, packets are round robin. */
     142          36 :   FOR(verify_tile_cnt) for( ulong j=0UL; j<quic_tile_cnt; j++ )
     143          18 :                        fd_topob_tile_in(  topo, "verify",  i,            "metric_in", "quic_verify",  j,            FD_TOPOB_UNRELIABLE, FD_TOPOB_POLLED ); /* No reliable consumers, verify tiles may be overrun */
     144          18 :   FOR(verify_tile_cnt) fd_topob_tile_out( topo, "verify",  i,                         "verify_dedup", i                                                  );
     145             :   /* Declare the single gossip link before the variable length verify-dedup links so we could have a compile-time index to the gossip link. */
     146           3 :   /**/                 fd_topob_tile_in(  topo, "dedup",   0UL,          "metric_in", "gossip_dedup", 0UL,          FD_TOPOB_RELIABLE,   FD_TOPOB_POLLED );
     147          18 :   FOR(verify_tile_cnt) fd_topob_tile_in(  topo, "dedup",   0UL,          "metric_in", "verify_dedup", i,            FD_TOPOB_RELIABLE,   FD_TOPOB_POLLED );
     148           3 :   /**/                 fd_topob_tile_out( topo, "dedup",   0UL,                       "dedup_resolv", 0UL                                                );
     149           3 :   FOR(resolv_tile_cnt) fd_topob_tile_in(  topo, "resolv",  i,            "metric_in", "dedup_resolv", 0UL,          FD_TOPOB_RELIABLE,   FD_TOPOB_POLLED );
     150           3 :   FOR(resolv_tile_cnt) fd_topob_tile_in(  topo, "resolv",  i,            "metric_in", "replay_resol", 0UL,          FD_TOPOB_RELIABLE,   FD_TOPOB_POLLED );
     151           3 :   FOR(resolv_tile_cnt) fd_topob_tile_out( topo, "resolv",  i,                         "resolv_pack",  i                                                  );
     152           3 :   /**/                 fd_topob_tile_in(  topo, "pack",    0UL,          "metric_in", "resolv_pack",  0UL,          FD_TOPOB_RELIABLE,   FD_TOPOB_POLLED );
     153             :   /* The PoH to pack link is reliable, and must be.  The fragments going
     154             :      across here are "you became leader" which pack must respond to
     155             :      by publishing microblocks, otherwise the leader TPU will hang
     156             :      forever.
     157             : 
     158             :      It's marked as unreliable since otherwise we have a reliable credit
     159             :      loop which will also starve the pack tile.  This is OK because we
     160             :      will never send more than one leader message until the pack tile
     161             :      must acknowledge it with a packing done frag, so there will be at
     162             :      most one in flight at any time. */
     163           3 :   /**/                 fd_topob_tile_in(  topo, "pack",   0UL,           "metric_in", "poh_pack",     0UL,          FD_TOPOB_UNRELIABLE, FD_TOPOB_POLLED );
     164           3 :                        fd_topob_tile_out( topo, "pack",   0UL,                        "pack_bank",    0UL                                                );
     165          12 :   FOR(bank_tile_cnt)   fd_topob_tile_in(  topo, "bank",   i,             "metric_in", "pack_bank",    0UL,          FD_TOPOB_RELIABLE,   FD_TOPOB_POLLED );
     166          12 :   FOR(bank_tile_cnt)   fd_topob_tile_out( topo, "bank",   i,                          "bank_poh",     i                                                  );
     167          12 :   FOR(bank_tile_cnt)   fd_topob_tile_in(  topo, "poh",    0UL,           "metric_in", "bank_poh",     i,            FD_TOPOB_RELIABLE,   FD_TOPOB_POLLED );
     168           3 :   if( FD_LIKELY( config->tiles.pack.use_consumed_cus ) )
     169          12 :     FOR(bank_tile_cnt) fd_topob_tile_in(  topo, "pack",   0UL,           "metric_in", "bank_poh",     i,            FD_TOPOB_UNRELIABLE, FD_TOPOB_POLLED );
     170           3 :   /**/                 fd_topob_tile_in(  topo, "poh",    0UL,           "metric_in", "stake_out",    0UL,          FD_TOPOB_RELIABLE,   FD_TOPOB_POLLED );
     171           3 :   /**/                 fd_topob_tile_in(  topo, "poh",    0UL,           "metric_in", "pack_bank",    0UL,          FD_TOPOB_RELIABLE,   FD_TOPOB_POLLED );
     172           3 :   /**/                 fd_topob_tile_out( topo, "poh",    0UL,                        "poh_shred",    0UL                                                );
     173           3 :   /**/                 fd_topob_tile_out( topo, "poh",    0UL,                        "poh_pack",     0UL                                                );
     174           6 :   FOR(shred_tile_cnt) for( ulong j=0UL; j<net_tile_cnt; j++ )
     175           3 :                        fd_topob_tile_in(  topo, "shred",  i,             "metric_in", "net_shred",    j,            FD_TOPOB_UNRELIABLE, FD_TOPOB_POLLED ); /* No reliable consumers of networking fragments, may be dropped or overrun */
     176           3 :   FOR(shred_tile_cnt)  fd_topob_tile_in(  topo, "shred",  i,             "metric_in", "poh_shred",    0UL,          FD_TOPOB_RELIABLE,   FD_TOPOB_POLLED );
     177           3 :   FOR(shred_tile_cnt)  fd_topob_tile_in(  topo, "shred",  i,             "metric_in", "stake_out",    0UL,          FD_TOPOB_RELIABLE,   FD_TOPOB_POLLED );
     178           3 :   FOR(shred_tile_cnt)  fd_topob_tile_in(  topo, "shred",  i,             "metric_in", "crds_shred",   0UL,          FD_TOPOB_RELIABLE,   FD_TOPOB_POLLED );
     179           3 :   FOR(shred_tile_cnt)  fd_topob_tile_out( topo, "shred",  i,                          "shred_store",  i                                                  );
     180           3 :   FOR(shred_tile_cnt)  fd_topob_tile_out( topo, "shred",  i,                          "shred_net",    i                                                  );
     181           3 :   FOR(shred_tile_cnt)  fd_topob_tile_in(  topo, "store",  0UL,           "metric_in", "shred_store",  i,            FD_TOPOB_RELIABLE,   FD_TOPOB_POLLED );
     182             : 
     183             :   /* Sign links don't need to be reliable because they are synchronous,
     184             :      so there's at most one fragment in flight at a time anyway.  The
     185             :      sign links are also not polled by the mux, instead the tiles will
     186             :      read the sign responses out of band in a dedicated spin loop. */
     187             : 
     188           6 :   for( ulong i=0UL; i<shred_tile_cnt; i++ ) {
     189           3 :     /**/               fd_topob_tile_in(  topo, "sign",   0UL,           "metric_in", "shred_sign",     i,          FD_TOPOB_UNRELIABLE, FD_TOPOB_POLLED   );
     190           3 :     /**/               fd_topob_tile_out( topo, "shred",  i,                          "shred_sign",     i                                                  );
     191           3 :     /**/               fd_topob_tile_in(  topo, "shred",  i,             "metric_in", "sign_shred",     i,          FD_TOPOB_UNRELIABLE, FD_TOPOB_UNPOLLED );
     192           3 :     /**/               fd_topob_tile_out( topo, "sign",   0UL,                        "sign_shred",     i                                                  );
     193           3 :   }
     194             : 
     195             :   /* PoH tile represents the Agave address space, so it's
     196             :      responsible for publishing Agave provided data to
     197             :      these links. */
     198             :   /**/                 fd_topob_tile_out( topo, "poh",    0UL,                        "gossip_dedup", 0UL                                                  );
     199           3 :   /**/                 fd_topob_tile_out( topo, "poh",    0UL,                        "stake_out",    0UL                                                  );
     200           3 :   /**/                 fd_topob_tile_out( topo, "poh",    0UL,                        "crds_shred",   0UL                                                  );
     201           3 :   /**/                 fd_topob_tile_out( topo, "poh",    0UL,                        "replay_resol", 0UL                                                  );
     202             : 
     203             :   /* For now the only plugin consumer is the GUI */
     204           3 :   int plugins_enabled = config->tiles.gui.enabled;
     205           3 :   if( FD_LIKELY( plugins_enabled ) ) {
     206           3 :     fd_topob_wksp( topo, "plugin_in"    );
     207           3 :     fd_topob_wksp( topo, "plugin_out"   );
     208           3 :     fd_topob_wksp( topo, "plugin"       );
     209             : 
     210             :     /**/                 fd_topob_link( topo, "plugin_out",   "plugin_out",   128UL,                                    8UL+40200UL*(58UL+12UL*34UL), 1UL );
     211           3 :     /**/                 fd_topob_link( topo, "replay_plugi", "plugin_in",    128UL,                                    4098*8UL,                     1UL );
     212           3 :     /**/                 fd_topob_link( topo, "gossip_plugi", "plugin_in",    128UL,                                    8UL+40200UL*(58UL+12UL*34UL), 1UL );
     213           3 :     /**/                 fd_topob_link( topo, "poh_plugin",   "plugin_in",    128UL,                                    16UL,                         1UL );
     214           3 :     /**/                 fd_topob_link( topo, "startp_plugi", "plugin_in",    128UL,                                    56UL,                         1UL );
     215           3 :     /**/                 fd_topob_link( topo, "votel_plugin", "plugin_in",    128UL,                                    8UL,                          1UL );
     216           3 :     /**/                 fd_topob_link( topo, "valcfg_plugi", "plugin_in",    128UL,                                    608UL,                        1UL );
     217             : 
     218             :     /**/                 fd_topob_tile( topo, "plugin",  "plugin",  "metric_in",  tile_to_cpu[ topo->tile_cnt ], 0, 0 );
     219             : 
     220             :     /**/                 fd_topob_tile_out( topo, "poh",    0UL,                        "replay_plugi", 0UL                                                );
     221           3 :     /**/                 fd_topob_tile_out( topo, "poh",    0UL,                        "gossip_plugi", 0UL                                                );
     222           3 :     /**/                 fd_topob_tile_out( topo, "poh",    0UL,                        "poh_plugin",   0UL                                                );
     223           3 :     /**/                 fd_topob_tile_out( topo, "poh",    0UL,                        "startp_plugi", 0UL                                                );
     224           3 :     /**/                 fd_topob_tile_out( topo, "poh",    0UL,                        "votel_plugin", 0UL                                                );
     225           3 :     /**/                 fd_topob_tile_out( topo, "plugin", 0UL,                        "plugin_out",   0UL                                                );
     226           3 :     /**/                 fd_topob_tile_out( topo, "poh",    0UL,                        "valcfg_plugi", 0UL                                                );
     227             : 
     228           3 :     /**/                 fd_topob_tile_in(  topo, "plugin", 0UL,           "metric_in", "replay_plugi", 0UL,          FD_TOPOB_RELIABLE,   FD_TOPOB_POLLED );
     229           3 :     /**/                 fd_topob_tile_in(  topo, "plugin", 0UL,           "metric_in", "gossip_plugi", 0UL,          FD_TOPOB_RELIABLE,   FD_TOPOB_POLLED );
     230           3 :     /**/                 fd_topob_tile_in(  topo, "plugin", 0UL,           "metric_in", "stake_out",    0UL,          FD_TOPOB_RELIABLE,   FD_TOPOB_POLLED );
     231           3 :     /**/                 fd_topob_tile_in(  topo, "plugin", 0UL,           "metric_in", "poh_plugin",   0UL,          FD_TOPOB_RELIABLE,   FD_TOPOB_POLLED );
     232           3 :     /**/                 fd_topob_tile_in(  topo, "plugin", 0UL,           "metric_in", "startp_plugi", 0UL,          FD_TOPOB_RELIABLE,   FD_TOPOB_POLLED );
     233           3 :     /**/                 fd_topob_tile_in(  topo, "plugin", 0UL,           "metric_in", "votel_plugin", 0UL,          FD_TOPOB_RELIABLE,   FD_TOPOB_POLLED );
     234           3 :     /**/                 fd_topob_tile_in(  topo, "plugin", 0UL,           "metric_in", "valcfg_plugi", 0UL,          FD_TOPOB_RELIABLE,   FD_TOPOB_POLLED );
     235           3 :   }
     236             : 
     237           3 :   if( FD_LIKELY( config->tiles.gui.enabled ) ) {
     238           3 :     fd_topob_wksp( topo, "gui"          );
     239           3 :     /**/                 fd_topob_tile( topo, "gui",     "gui",     "metric_in",  tile_to_cpu[ topo->tile_cnt ], 0, 1 );
     240           3 :     /**/                 fd_topob_tile_in(  topo, "gui",    0UL,           "metric_in", "plugin_out",   0UL,          FD_TOPOB_RELIABLE,   FD_TOPOB_POLLED );
     241           3 :   }
     242             : 
     243           3 :   if( FD_UNLIKELY( config->tiles.bundle.enabled ) ) {
     244           0 :     fd_topob_wksp( topo, "bundle_verif" );
     245           0 :     fd_topob_wksp( topo, "bundle_sign"  );
     246           0 :     fd_topob_wksp( topo, "sign_bundle"  );
     247           0 :     fd_topob_wksp( topo, "pack_sign"    );
     248           0 :     fd_topob_wksp( topo, "sign_pack"    );
     249           0 :     fd_topob_wksp( topo, "bundle"       );
     250             : 
     251           0 :     /**/                 fd_topob_link( topo, "bundle_verif", "bundle_verif", config->tiles.verify.receive_buffer_size, FD_TPU_PARSED_MTU,         1UL );
     252           0 :     /**/                 fd_topob_link( topo, "bundle_sign",  "bundle_sign",  65536UL,                                  9UL,                       1UL );
     253           0 :     /**/                 fd_topob_link( topo, "sign_bundle",  "sign_bundle",  128UL,                                    64UL,                      1UL );
     254           0 :     /**/                 fd_topob_link( topo, "pack_sign",    "pack_sign",    65536UL,                                  1232UL,                    1UL );
     255           0 :     /**/                 fd_topob_link( topo, "sign_pack",    "sign_pack",    128UL,                                    64UL,                      1UL );
     256             : 
     257             :     /**/                 fd_topob_tile( topo, "bundle",  "bundle",  "metric_in", tile_to_cpu[ topo->tile_cnt ], 0, 1 );
     258             : 
     259             :     /**/                 fd_topob_tile_out( topo, "bundle", 0UL, "bundle_verif", 0UL );
     260           0 :     FOR(verify_tile_cnt) fd_topob_tile_in(  topo, "verify", i,             "metric_in", "bundle_verif",   0UL,        FD_TOPOB_RELIABLE,   FD_TOPOB_POLLED   );
     261             : 
     262           0 :     /**/                 fd_topob_tile_in(  topo, "sign",   0UL,           "metric_in", "bundle_sign",    0UL,        FD_TOPOB_UNRELIABLE, FD_TOPOB_POLLED   );
     263           0 :     /**/                 fd_topob_tile_out( topo, "bundle", 0UL,                        "bundle_sign",    0UL                                                );
     264           0 :     /**/                 fd_topob_tile_in(  topo, "bundle", 0UL,           "metric_in", "sign_bundle",    0UL,        FD_TOPOB_UNRELIABLE, FD_TOPOB_UNPOLLED );
     265           0 :     /**/                 fd_topob_tile_out( topo, "sign",   0UL,                        "sign_bundle",    0UL                                                );
     266             : 
     267           0 :     /**/                 fd_topob_tile_in(  topo, "sign",   0UL,           "metric_in", "pack_sign",      0UL,        FD_TOPOB_UNRELIABLE, FD_TOPOB_POLLED   );
     268           0 :     /**/                 fd_topob_tile_out( topo, "pack",   0UL,                        "pack_sign",      0UL                                                );
     269           0 :     /**/                 fd_topob_tile_in(  topo, "pack",   0UL,           "metric_in", "sign_pack",      0UL,        FD_TOPOB_UNRELIABLE, FD_TOPOB_UNPOLLED );
     270           0 :     /**/                 fd_topob_tile_out( topo, "sign",   0UL,                        "sign_pack",      0UL                                                );
     271             : 
     272           0 :     if( plugins_enabled ) {
     273           0 :       fd_topob_wksp( topo, "bundle_plugi" );
     274             :       /* bundle_plugi must be kind of deep, to prevent exhausting shared
     275             :          flow control credits when publishing many packets at once. */
     276           0 :       fd_topob_link( topo, "bundle_plugi", "bundle_plugi", 65536UL, sizeof(fd_plugin_msg_block_engine_update_t), 1UL );
     277           0 :       fd_topob_tile_in( topo, "plugin", 0UL, "metric_in", "bundle_plugi", 0UL, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
     278           0 :       fd_topob_tile_out( topo, "bundle", 0UL, "bundle_plugi", 0UL );
     279           0 :     }
     280           0 :   }
     281             : 
     282           3 :   if( FD_LIKELY( !is_auto_affinity ) ) {
     283           0 :     if( FD_UNLIKELY( affinity_tile_cnt<topo->tile_cnt ) )
     284           0 :       FD_LOG_ERR(( "The topology you are using has %lu tiles, but the CPU affinity specified in the config tile as [layout.affinity] only provides for %lu cores. "
     285           0 :                    "You should either increase the number of cores dedicated to Firedancer in the affinity string, or decrease the number of cores needed by reducing "
     286           0 :                    "the total tile count. You can reduce the tile count by decreasing individual tile counts in the [layout] section of the configuration file.",
     287           0 :                    topo->tile_cnt, affinity_tile_cnt ));
     288           0 :     if( FD_UNLIKELY( affinity_tile_cnt>topo->tile_cnt ) )
     289           0 :       FD_LOG_WARNING(( "The topology you are using has %lu tiles, but the CPU affinity specified in the config tile as [layout.affinity] provides for %lu cores. "
     290           0 :                        "Not all cores in the affinity will be used by Firedancer. You may wish to increase the number of tiles in the system by increasing "
     291           0 :                        "individual tile counts in the [layout] section of the configuration file.",
     292           0 :                        topo->tile_cnt, affinity_tile_cnt ));
     293             : 
     294           0 :     if( FD_LIKELY( strcmp( "", config->layout.agave_affinity ) ) ) {
     295           0 :       ushort agave_cpu[ FD_TILE_MAX ];
     296           0 :       ulong agave_cpu_cnt = fd_tile_private_cpus_parse( config->layout.agave_affinity, agave_cpu );
     297             : 
     298           0 :       for( ulong i=0UL; i<agave_cpu_cnt; i++ ) {
     299           0 :         if( FD_UNLIKELY( agave_cpu[ i ]>=cpus->cpu_cnt ) )
     300           0 :           FD_LOG_ERR(( "The CPU affinity string in the configuration file under [layout.agave_affinity] specifies a CPU index of %hu, but the system "
     301           0 :                        "only has %lu CPUs. You should either change the CPU allocations in the affinity string, or increase the number of CPUs "
     302           0 :                        "in the system.",
     303           0 :                        agave_cpu[ i ], cpus->cpu_cnt ));
     304             : 
     305           0 :         for( ulong j=0UL; j<topo->tile_cnt; j++ ) {
     306           0 :           fd_topo_tile_t * tile = &topo->tiles[ j ];
     307           0 :           if( tile->cpu_idx==agave_cpu[ i ] ) FD_LOG_WARNING(( "Tile `%s:%lu` is already assigned to CPU %hu, but the CPU is also assigned to Agave. "
     308           0 :                                                                "This may cause contention between the two tiles.", tile->name, tile->kind_id, agave_cpu[ i ] ));
     309           0 :         }
     310             : 
     311           0 :         if( FD_UNLIKELY( topo->agave_affinity_cnt>FD_TILE_MAX ) ) {
     312           0 :           FD_LOG_ERR(( "The CPU affinity string in the configuration file under [layout.agave_affinity] specifies more CPUs than Firedancer can use. "
     313           0 :                         "You should either reduce the number of CPUs in the affinity string." ));
     314           0 :         }
     315           0 :         topo->agave_affinity_cpu_idx[ topo->agave_affinity_cnt++ ] = agave_cpu[ i ];
     316           0 :       }
     317           0 :     }
     318           0 :   }
     319             : 
     320             :   /* There is a special fseq that sits between the pack, bank, and poh
     321             :      tiles to indicate when the bank/poh tiles are done processing a
     322             :      microblock.  Pack uses this to determine when to "unlock" accounts
     323             :      that it marked as locked because they were being used. */
     324             : 
     325          15 :   for( ulong i=0UL; i<bank_tile_cnt; i++ ) {
     326          12 :     fd_topo_obj_t * busy_obj = fd_topob_obj( topo, "fseq", "bank_busy" );
     327             : 
     328          12 :     fd_topo_tile_t * poh_tile = &topo->tiles[ fd_topo_find_tile( topo, "poh", 0UL ) ];
     329          12 :     fd_topo_tile_t * pack_tile = &topo->tiles[ fd_topo_find_tile( topo, "pack", 0UL ) ];
     330          12 :     fd_topob_tile_uses( topo, poh_tile, busy_obj, FD_SHMEM_JOIN_MODE_READ_WRITE );
     331          12 :     fd_topob_tile_uses( topo, pack_tile, busy_obj, FD_SHMEM_JOIN_MODE_READ_ONLY );
     332          12 :     FD_TEST( fd_pod_insertf_ulong( topo->props, busy_obj->id, "bank_busy.%lu", i ) );
     333          12 :   }
     334             : 
     335             :   /* There's another special fseq that's used to communicate the shred
     336             :      version from the Agave boot path to the shred tile. */
     337           3 :   fd_topo_obj_t * poh_shred_obj = fd_topob_obj( topo, "fseq", "poh_shred" );
     338           3 :   fd_topo_tile_t * poh_tile = &topo->tiles[ fd_topo_find_tile( topo, "poh", 0UL ) ];
     339           3 :   fd_topob_tile_uses( topo, poh_tile, poh_shred_obj, FD_SHMEM_JOIN_MODE_READ_WRITE );
     340           6 :   for( ulong i=0UL; i<shred_tile_cnt; i++ ) {
     341           3 :     fd_topo_tile_t * shred_tile = &topo->tiles[ fd_topo_find_tile( topo, "shred", i ) ];
     342           3 :     fd_topob_tile_uses( topo, shred_tile, poh_shred_obj, FD_SHMEM_JOIN_MODE_READ_ONLY );
     343           3 :   }
     344           3 :   FD_TEST( fd_pod_insertf_ulong( topo->props, poh_shred_obj->id, "poh_shred" ) );
     345             : 
     346           3 :   FOR(net_tile_cnt) fd_topos_net_tile_umem( topo, i );
     347             : 
     348          75 :   for( ulong i=0UL; i<topo->tile_cnt; i++ ) {
     349          72 :     fd_topo_tile_t * tile = &topo->tiles[ i ];
     350             : 
     351          72 :     if( FD_UNLIKELY( !strcmp( tile->name, "net" ) ) ) {
     352             : 
     353           3 :       tile->net.shred_listen_port              = config->tiles.shred.shred_listen_port;
     354           3 :       tile->net.quic_transaction_listen_port   = config->tiles.quic.quic_transaction_listen_port;
     355           3 :       tile->net.legacy_transaction_listen_port = config->tiles.quic.regular_transaction_listen_port;
     356             : 
     357          69 :     } else if( FD_UNLIKELY( !strcmp( tile->name, "netlnk" ) ) ) {
     358             : 
     359             :       /* already configured */
     360             : 
     361          66 :     } else if( FD_UNLIKELY( !strcmp( tile->name, "quic" ) ) ) {
     362           3 :       fd_memcpy( tile->quic.src_mac_addr, config->tiles.net.mac_addr, 6 );
     363             : 
     364           3 :       tile->quic.reasm_cnt                      = config->tiles.quic.txn_reassembly_count;
     365           3 :       tile->quic.out_depth                      = config->tiles.verify.receive_buffer_size;
     366           3 :       tile->quic.max_concurrent_connections     = config->tiles.quic.max_concurrent_connections;
     367           3 :       tile->quic.max_concurrent_handshakes      = config->tiles.quic.max_concurrent_handshakes;
     368           3 :       tile->quic.ip_addr                        = config->tiles.net.ip_addr;
     369           3 :       tile->quic.quic_transaction_listen_port   = config->tiles.quic.quic_transaction_listen_port;
     370           3 :       tile->quic.idle_timeout_millis            = config->tiles.quic.idle_timeout_millis;
     371           3 :       tile->quic.ack_delay_millis               = config->tiles.quic.ack_delay_millis;
     372           3 :       tile->quic.retry                          = config->tiles.quic.retry;
     373             : 
     374          63 :     } else if( FD_UNLIKELY( !strcmp( tile->name, "bundle" ) ) ) {
     375           0 :       strncpy( tile->bundle.url, config->tiles.bundle.url, sizeof(tile->bundle.url) );
     376           0 :       strncpy( tile->bundle.tls_domain_name, config->tiles.bundle.tls_domain_name, sizeof(tile->bundle.tls_domain_name) );
     377           0 :       strncpy( tile->bundle.identity_key_path, config->consensus.identity_path, sizeof(tile->bundle.identity_key_path) );
     378             : 
     379          63 :     } else if( FD_UNLIKELY( !strcmp( tile->name, "verify" ) ) ) {
     380          18 :       tile->verify.tcache_depth = config->tiles.verify.signature_cache_size;
     381             : 
     382          45 :     } else if( FD_UNLIKELY( !strcmp( tile->name, "dedup" ) ) ) {
     383           3 :       tile->dedup.tcache_depth = config->tiles.dedup.signature_cache_size;
     384             : 
     385          42 :     } else if( FD_UNLIKELY( !strcmp( tile->name, "resolv" ) ) ) {
     386             : 
     387          39 :     } else if( FD_UNLIKELY( !strcmp( tile->name, "pack" ) ) ) {
     388           3 :       tile->pack.max_pending_transactions      = config->tiles.pack.max_pending_transactions;
     389           3 :       tile->pack.bank_tile_count               = config->layout.bank_tile_count;
     390           3 :       tile->pack.larger_max_cost_per_block     = config->development.bench.larger_max_cost_per_block;
     391           3 :       tile->pack.larger_shred_limits_per_block = config->development.bench.larger_shred_limits_per_block;
     392           3 :       tile->pack.use_consumed_cus              = config->tiles.pack.use_consumed_cus;
     393             : 
     394           3 :       if( FD_UNLIKELY( config->tiles.bundle.enabled ) ) {
     395           0 : #define PARSE_PUBKEY( _tile, f ) \
     396           0 :         if( FD_UNLIKELY( !fd_base58_decode_32( config->tiles.bundle.f, tile->_tile.bundle.f ) ) )  \
     397           0 :           FD_LOG_ERR(( "[tiles.bundle.enabled] set to true, but failed to parse [tiles.bundle."#f"] %s", config->tiles.bundle.f ));
     398           0 :         tile->pack.bundle.enabled = 1;
     399           0 :         PARSE_PUBKEY( pack, tip_distribution_program_addr );
     400           0 :         PARSE_PUBKEY( pack, tip_payment_program_addr      );
     401           0 :         PARSE_PUBKEY( pack, tip_distribution_authority    );
     402           0 :         tile->pack.bundle.commission_bps = config->tiles.bundle.commission_bps;
     403           0 :         strncpy( tile->pack.bundle.identity_key_path, config->consensus.identity_path, sizeof(tile->pack.bundle.identity_key_path) );
     404           0 :         strncpy( tile->pack.bundle.vote_account_path, config->consensus.vote_account_path, sizeof(tile->pack.bundle.vote_account_path) );
     405           3 :       } else {
     406           3 :         fd_memset( &tile->pack.bundle, '\0', sizeof(tile->pack.bundle) );
     407           3 :       }
     408          36 :     } else if( FD_UNLIKELY( !strcmp( tile->name, "bank" ) ) ) {
     409             : 
     410          24 :     } else if( FD_UNLIKELY( !strcmp( tile->name, "poh" ) ) ) {
     411           3 :       strncpy( tile->poh.identity_key_path, config->consensus.identity_path, sizeof(tile->poh.identity_key_path) );
     412             : 
     413           3 :       tile->poh.plugins_enabled = plugins_enabled;
     414           3 :       tile->poh.bank_cnt = config->layout.bank_tile_count;
     415           3 :       tile->poh.lagged_consecutive_leader_start = config->tiles.poh.lagged_consecutive_leader_start;
     416             : 
     417           3 :       if( FD_UNLIKELY( config->tiles.bundle.enabled ) ) {
     418           0 :         tile->poh.bundle.enabled = 1;
     419           0 :         PARSE_PUBKEY( poh, tip_distribution_program_addr );
     420           0 :         PARSE_PUBKEY( poh, tip_payment_program_addr      );
     421           0 :         strncpy( tile->poh.bundle.vote_account_path, config->consensus.vote_account_path, sizeof(tile->poh.bundle.vote_account_path) );
     422           0 : #undef PARSE_PUBKEY
     423           3 :       } else {
     424           3 :         fd_memset( &tile->poh.bundle, '\0', sizeof(tile->poh.bundle) );
     425           3 :       }
     426             : 
     427          21 :     } else if( FD_UNLIKELY( !strcmp( tile->name, "shred" ) ) ) {
     428           3 :       fd_memcpy( tile->shred.src_mac_addr, config->tiles.net.mac_addr, 6 );
     429           3 :       strncpy( tile->shred.identity_key_path, config->consensus.identity_path, sizeof(tile->shred.identity_key_path) );
     430             : 
     431           3 :       tile->shred.depth                         = topo->links[ tile->out_link_id[ 0 ] ].depth;
     432           3 :       tile->shred.ip_addr                       = config->tiles.net.ip_addr;
     433           3 :       tile->shred.fec_resolver_depth            = config->tiles.shred.max_pending_shred_sets;
     434           3 :       tile->shred.expected_shred_version        = config->consensus.expected_shred_version;
     435           3 :       tile->shred.shred_listen_port             = config->tiles.shred.shred_listen_port;
     436           3 :       tile->shred.larger_shred_limits_per_block = config->development.bench.larger_shred_limits_per_block;
     437             : 
     438          18 :     } else if( FD_UNLIKELY( !strcmp( tile->name, "store" ) ) ) {
     439           3 :       tile->store.disable_blockstore_from_slot = config->development.bench.disable_blockstore_from_slot;
     440             : 
     441          15 :     } else if( FD_UNLIKELY( !strcmp( tile->name, "sign" ) ) ) {
     442           3 :       strncpy( tile->sign.identity_key_path, config->consensus.identity_path, sizeof(tile->sign.identity_key_path) );
     443             : 
     444          12 :     } else if( FD_UNLIKELY( !strcmp( tile->name, "metric" ) ) ) {
     445           3 :       if( FD_UNLIKELY( !fd_cstr_to_ip4_addr( config->tiles.metric.prometheus_listen_address, &tile->metric.prometheus_listen_addr ) ) )
     446           0 :         FD_LOG_ERR(( "failed to parse prometheus listen address `%s`", config->tiles.metric.prometheus_listen_address ));
     447           3 :       tile->metric.prometheus_listen_port = config->tiles.metric.prometheus_listen_port;
     448             : 
     449           9 :     } else if( FD_UNLIKELY( !strcmp( tile->name, "cswtch" ) ) ) {
     450             : 
     451           6 :     } else if( FD_UNLIKELY( !strcmp( tile->name, "gui" ) ) ) {
     452           3 :       if( FD_UNLIKELY( !fd_cstr_to_ip4_addr( config->tiles.gui.gui_listen_address, &tile->gui.listen_addr ) ) )
     453           0 :         FD_LOG_ERR(( "failed to parse gui listen address `%s`", config->tiles.gui.gui_listen_address ));
     454           3 :       tile->gui.listen_port = config->tiles.gui.gui_listen_port;
     455           3 :       tile->gui.is_voting = strcmp( config->consensus.vote_account_path, "" );
     456           3 :       strncpy( tile->gui.cluster, config->cluster, sizeof(tile->gui.cluster) );
     457           3 :       strncpy( tile->gui.identity_key_path, config->consensus.identity_path, sizeof(tile->gui.identity_key_path) );
     458             : 
     459           3 :     } else if( FD_UNLIKELY( !strcmp( tile->name, "plugin" ) ) ) {
     460             : 
     461           3 :     } else {
     462           0 :       FD_LOG_ERR(( "unknown tile name %lu `%s`", i, tile->name ));
     463           0 :     }
     464          72 :   }
     465             : 
     466           3 :   if( FD_UNLIKELY( is_auto_affinity ) ) fd_topob_auto_layout( topo );
     467             : 
     468           3 :   fd_topob_finish( topo, fdctl_obj_align, fdctl_obj_footprint, fdctl_obj_loose );
     469           3 :   config->topo = *topo;
     470           3 : }

Generated by: LCOV version 1.14