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