Line data Source code
1 : /* The frontend assets are pre-built and statically compiled into the
2 : binary here. To regenerate them, run
3 :
4 : $ git clone https://github.com/firedancer-io/firedancer-frontend.git frontend
5 : $ make frontend
6 :
7 : from the repository root. */
8 :
9 : #include "../../disco/gui/generated/http_import_dist.h"
10 :
11 : /* STATIC_FILES is the null-terminated list of frontend assets baked into
12 : the binary. It is defined in generated/http_import_dist.c and accessed
13 : in the gui_http_request callback. */
14 :
15 : #include <sys/socket.h> /* SOCK_CLOEXEC, SOCK_NONBLOCK needed for seccomp filter */
16 :
17 : #include <linux/futex.h>
18 : #include "generated/fd_gui_tile_seccomp.h"
19 :
20 : #include "../../disco/tiles.h"
21 : #include "../../disco/keyguard/fd_keyload.h"
22 : #include "../../disco/keyguard/fd_keyswitch.h"
23 : #include "../../disco/gui/fd_gui.h"
24 : #include "../../disco/gui/fd_gui_store.h"
25 : #include "../../disco/gui/fd_gui_hist.h"
26 : #include "../../discof/replay/fd_execrp.h"
27 : #include "../../disco/metrics/fd_metrics.h"
28 : #include "../../disco/net/fd_net_tile.h"
29 : #include "../../disco/waker/fd_waker.h"
30 : #include "../../disco/sleep/fd_sleep.h"
31 : #include "../../disco/fd_clock_tile.h"
32 : #include "../../discof/genesis/fd_genesi_tile.h" // TODO: Layering violation
33 : #include "../../ballet/sha256/fd_sha256.h"
34 : #include "../../ballet/base64/fd_base64.h"
35 : #include "../../waltz/http/fd_http_server.h"
36 : #include "../../waltz/http/fd_http_server_private.h"
37 : #include "../../disco/repair/fd_repair_serde.h"
38 : #include "../../discof/replay/fd_replay_tile.h"
39 : #include "../../discof/votor/fd_votor_tile.h"
40 : #include "../../disco/shred/fd_shred_tile.h"
41 : #include "../../flamenco/accdb/fd_accdb_shmem.h"
42 :
43 : /* We're not going to use the TOWER DB, but need to keep its metric
44 : for backwards compatibility, so then we need an explicit mapping. */
45 :
46 : FD_STATIC_ASSERT( FD_METRICS_ENUM_GUI_DB_TYPE_CNT==FD_GUI_HIST_CNT+1UL, gui_db_enum );
47 :
48 : static ulong const gui_db_type_idx[ FD_GUI_HIST_CNT ] = {
49 : [ FD_GUI_HIST_SCHEDULER_COUNTS ] = FD_METRICS_ENUM_GUI_DB_TYPE_V_SCHEDULER_COUNTS_IDX,
50 : [ FD_GUI_HIST_TILE_TIMERS ] = FD_METRICS_ENUM_GUI_DB_TYPE_V_TILE_TIMERS_IDX,
51 : [ FD_GUI_HIST_SHRED_EVENTS ] = FD_METRICS_ENUM_GUI_DB_TYPE_V_SHRED_EVENTS_IDX,
52 : [ FD_GUI_HIST_TXN_START ] = FD_METRICS_ENUM_GUI_DB_TYPE_V_TXN_START_IDX,
53 : [ FD_GUI_HIST_TXN_END ] = FD_METRICS_ENUM_GUI_DB_TYPE_V_TXN_END_IDX,
54 : [ FD_GUI_HIST_SLOT ] = FD_METRICS_ENUM_GUI_DB_TYPE_V_SLOT_IDX,
55 : [ FD_GUI_HIST_LEADER_SLOT ] = FD_METRICS_ENUM_GUI_DB_TYPE_V_LEADER_SLOT_IDX,
56 : [ FD_GUI_HIST_EPOCH ] = FD_METRICS_ENUM_GUI_DB_TYPE_V_EPOCH_IDX,
57 : [ FD_GUI_HIST_TILE_STATS ] = FD_METRICS_ENUM_GUI_DB_TYPE_V_TILE_STATS_IDX,
58 : [ FD_GUI_HIST_TXN_WATERFALL ] = FD_METRICS_ENUM_GUI_DB_TYPE_V_TXN_WATERFALL_IDX,
59 : [ FD_GUI_HIST_TIMELINE_DAY ] = FD_METRICS_ENUM_GUI_DB_TYPE_V_TIMELINE_DAY_IDX,
60 : [ FD_GUI_HIST_REPLAY_TXN ] = FD_METRICS_ENUM_GUI_DB_TYPE_V_REPLAY_TXN_IDX,
61 : };
62 :
63 0 : #define IN_KIND_PACK_EXECLE ( 2UL)
64 0 : #define IN_KIND_PACK_POH ( 3UL)
65 0 : #define IN_KIND_EXECLE_POH ( 4UL)
66 0 : #define IN_KIND_SHRED_OUT ( 5UL) /* firedancer only */
67 0 : #define IN_KIND_GOSSVF_GUI ( 6UL) /* firedancer only */
68 0 : #define IN_KIND_GOSSIP_GUI ( 7UL) /* firedancer only */
69 0 : #define IN_KIND_GOSSIP_OUT ( 8UL) /* firedancer only */
70 0 : #define IN_KIND_SNAPCT ( 9UL) /* firedancer only */
71 0 : #define IN_KIND_REPAIR_NET (10UL) /* firedancer only */
72 0 : #define IN_KIND_REPLAY_OUT (12UL) /* firedancer only */
73 0 : #define IN_KIND_EPOCH (13UL) /* firedancer only */
74 0 : #define IN_KIND_GENESI_OUT (14UL) /* firedancer only */
75 0 : #define IN_KIND_SNAPIN (15UL) /* firedancer only */
76 0 : #define IN_KIND_EXECRP_REPLAY (16UL) /* firedancer only */
77 0 : #define IN_KIND_BUNDLE (17UL)
78 0 : #define IN_KIND_SNAPIN_MANIF (18UL) /* firedancer only */
79 0 : #define IN_KIND_SNAPSV_OUT (19UL) /* firedancer only */
80 0 : #define IN_KIND_DIAG (20UL) /* firedancer only */
81 0 : #define IN_KIND_VOTOR_OUT (21UL) /* firedancer only */
82 :
83 : FD_IMPORT_BINARY( firedancer_svg, "book/public/fire.svg" );
84 :
85 0 : #define FD_HTTP_SERVER_GUI_MAX_REQUEST_LEN 65536
86 0 : #define FD_HTTP_SERVER_GUI_MAX_WS_RECV_FRAME_LEN 65536
87 0 : #define FD_HTTP_SERVER_GUI_MAX_WS_SEND_FRAME_CNT 8192
88 :
89 : #define FD_GUI_TIMELINE_RAW_RESPONSE_MAX (32UL<<20)
90 : FD_STATIC_ASSERT( FD_GUI_TIMELINE_QUERY_SHRED_MAX*56UL+4096UL<=FD_GUI_TIMELINE_RAW_RESPONSE_MAX, shred_response_bound );
91 : /* Agg txn has four numeric arrays, and agg revenue has three
92 : ulong-string arrays: at most 4*21=84 or 3*23=69 bytes per bucket
93 : including commas, within the shared 512-byte budget. */
94 : FD_STATIC_ASSERT( FD_GUI_TIMELINE_QUERY_MAX_BUCKETS*512UL+4096UL<=FD_GUI_TIMELINE_RAW_RESPONSE_MAX, agg_response_bound );
95 : FD_STATIC_ASSERT( 2UL*FD_GUI_TIMELINE_RAW_RESPONSE_MAX+(FD_GUI_TIMELINE_RAW_RESPONSE_MAX>>8)<FD_GUI_HTTP_MIN_SEND_BUFFER_SZ,
96 : compressed_response_bound );
97 :
98 : static fd_http_server_params_t
99 0 : derive_http_params( fd_topo_tile_t const * tile ) {
100 0 : if( FD_UNLIKELY( tile->gui.send_buffer_size_mb<(FD_GUI_HTTP_MIN_SEND_BUFFER_SZ>>20) || tile->gui.send_buffer_size_mb>(ULONG_MAX>>20) ) ) {
101 0 : FD_LOG_ERR(( "[tiles.gui.send_buffer_size_mb] must be at least %lu MiB and fit in ulong bytes", FD_GUI_HTTP_MIN_SEND_BUFFER_SZ>>20 ));
102 0 : }
103 0 : return (fd_http_server_params_t) {
104 0 : .max_connection_cnt = tile->gui.max_http_connections,
105 0 : .max_ws_connection_cnt = tile->gui.max_websocket_connections,
106 0 : .max_request_len = FD_HTTP_SERVER_GUI_MAX_REQUEST_LEN,
107 0 : .max_ws_recv_frame_len = FD_HTTP_SERVER_GUI_MAX_WS_RECV_FRAME_LEN,
108 0 : .max_ws_send_frame_cnt = FD_HTTP_SERVER_GUI_MAX_WS_SEND_FRAME_CNT,
109 0 : .outgoing_buffer_sz = tile->gui.send_buffer_size_mb * (1UL<<20UL),
110 0 : .send_buffer_sz = 4UL<<20UL,
111 0 : .compress_websocket = tile->gui.websocket_compression,
112 0 : };
113 0 : }
114 :
115 : struct fd_gui_in_ctx {
116 : fd_wksp_t * mem;
117 : ulong mtu;
118 : ulong chunk0;
119 : ulong wmark;
120 : };
121 :
122 : typedef struct fd_gui_in_ctx fd_gui_in_ctx_t;
123 :
124 : struct fd_gui_out_ctx {
125 : ulong idx;
126 : fd_wksp_t * mem;
127 : ulong chunk0;
128 : ulong wmark;
129 : ulong chunk;
130 : };
131 :
132 : typedef struct fd_gui_out_ctx fd_gui_out_ctx_t;
133 :
134 : typedef struct {
135 : fd_topo_t const * topo;
136 : ulong seed;
137 :
138 : int snapshots_enabled;
139 :
140 : fd_gui_t * gui;
141 : fd_gui_store_t * db;
142 : fd_gui_peers_ctx_t * peers;
143 :
144 : ulong in_cnt;
145 : ulong idle_cnt;
146 :
147 : long deadline_ticks;
148 :
149 : fd_clock_tile_t clock[1];
150 :
151 : ulong chunk;
152 : union {
153 : struct {
154 : ulong slot;
155 : ulong shred_idx;
156 : } repair_net;
157 :
158 : fd_gui_gossip_bw_rec_t gossip_bw[ FD_GUI_GOSSIP_BW_REC_MAX ];
159 :
160 : struct {
161 : fd_snapsv_msg_t snapsv_out;
162 : int snapsv_eom;
163 : };
164 :
165 : fd_votor_msg_t votor_out;
166 : } parsed;
167 :
168 : fd_http_server_t * gui_server;
169 :
170 : char index_html_etag[ 3 ][ 24 ]; /* plain, zstd, gzip */
171 : char index_html_link[ 1024 ];
172 :
173 :
174 : /* The tile is a waker client: the server runs in epoll mode on the
175 : inherited inner epoll fd and fd servicing is gated on the waker
176 : readiness fseq. See fd_waker.h. */
177 : ulong waker_client_idx;
178 : ulong * waker_fseq;
179 :
180 : fd_keyswitch_t * keyswitch;
181 : uchar const * identity_key;
182 :
183 : int has_vote_key;
184 : fd_pubkey_t const vote_key[ 1UL ];
185 :
186 : ulong in_kind[ FD_TOPO_MAX_TILE_IN_LINKS ];
187 : int in_reliable[ FD_TOPO_MAX_TILE_IN_LINKS ];
188 : ulong in_bank_idx[ FD_TOPO_MAX_TILE_IN_LINKS ];
189 : fd_gui_in_ctx_t in[ FD_TOPO_MAX_TILE_IN_LINKS ];
190 : } fd_gui_ctx_t;
191 :
192 : FD_FN_CONST static inline ulong
193 0 : scratch_align( void ) {
194 0 : ulong a = alignof( fd_gui_ctx_t );
195 0 : a = fd_ulong_max( a, fd_http_server_align() );
196 0 : a = fd_ulong_max( a, fd_gui_peers_align() );
197 0 : a = fd_ulong_max( a, fd_gui_align() );
198 0 : return a;
199 0 : }
200 :
201 : static inline ulong
202 0 : scratch_footprint( fd_topo_tile_t const * tile ) {
203 0 : fd_http_server_params_t http_param = derive_http_params( tile );
204 0 : ulong http_fp = fd_http_server_footprint( http_param );
205 0 : if( FD_UNLIKELY( !http_fp ) ) FD_LOG_ERR(( "Invalid [tiles.gui] config parameters" ));
206 :
207 0 : ulong l = FD_LAYOUT_INIT;
208 0 : l = FD_LAYOUT_APPEND( l, alignof( fd_gui_ctx_t ), sizeof( fd_gui_ctx_t ) );
209 0 : l = FD_LAYOUT_APPEND( l, fd_http_server_align(), http_fp );
210 0 : l = FD_LAYOUT_APPEND( l, fd_gui_peers_align(), fd_gui_peers_footprint( http_param.max_ws_connection_cnt ) );
211 0 : l = FD_LAYOUT_APPEND( l, fd_gui_align(), fd_gui_footprint( tile->gui.tile_cnt, tile->gui.max_live_slots, tile->gui.max_txn_per_slot ) );
212 0 : l = FD_LAYOUT_APPEND( l, fd_gui_store_align(), fd_gui_store_footprint( tile->gui.db_size_gib<<30, fd_gui_hist_db_cnt(), fd_gui_hist_db_descs( tile->gui.db_size_gib<<30 ) ) );
213 0 : return FD_LAYOUT_FINI( l, scratch_align() );
214 0 : }
215 :
216 : static inline void
217 0 : during_housekeeping( fd_gui_ctx_t * ctx ) {
218 0 : if( FD_UNLIKELY( fd_clock_tile_recal_due( ctx->clock ) ) ) {
219 0 : fd_clock_tile_recal( ctx->clock );
220 0 : }
221 :
222 0 : if( FD_UNLIKELY( fd_keyswitch_state_query( ctx->keyswitch )==FD_KEYSWITCH_STATE_SWITCH_PENDING ) ) {
223 0 : fd_gui_set_identity( ctx->gui, ctx->keyswitch->bytes );
224 0 : fd_keyswitch_state( ctx->keyswitch, FD_KEYSWITCH_STATE_COMPLETED );
225 0 : }
226 0 : }
227 :
228 : static inline void
229 : gui_db_metric_copy( ulong off,
230 0 : ulong const * values ) {
231 0 : for( ulong i=0UL; i<FD_GUI_HIST_CNT; i++ ) fd_metrics_tl[ off+gui_db_type_idx[ i ] ] = values[ i ];
232 0 : }
233 :
234 : static inline void
235 0 : metrics_write( fd_gui_ctx_t * ctx ) {
236 0 : FD_MGAUGE_SET( GUI, CONN_OPEN, ctx->gui_server->metrics.connection_cnt );
237 0 : FD_MGAUGE_SET( GUI, WEBSOCKET_CONN_OPEN, ctx->gui_server->metrics.ws_connection_cnt );
238 :
239 0 : FD_MCNT_SET( GUI, WEBSOCKET_FRAME_TX, ctx->gui_server->metrics.frames_written );
240 0 : FD_MCNT_SET( GUI, WEBSOCKET_FRAME_RX, ctx->gui_server->metrics.frames_read );
241 :
242 0 : FD_MCNT_SET( GUI, CONN_TX_BYTES, ctx->gui_server->metrics.bytes_written );
243 0 : FD_MCNT_SET( GUI, CONN_RX_BYTES, ctx->gui_server->metrics.bytes_read );
244 :
245 0 : FD_MGAUGE_SET( GUI, DISK_ALLOCATED_BYTES, fd_gui_store_file_sz( ctx->db ) );
246 :
247 0 : ulong db_cnt = fd_gui_store_cnt( ctx->db );
248 :
249 0 : ulong used_bytes [ FD_GUI_HIST_CNT ];
250 0 : ulong cap_bytes [ FD_GUI_HIST_CNT ]; ulong free_bytes [ FD_GUI_HIST_CNT ];
251 0 : ulong used_slots [ FD_GUI_HIST_CNT ];
252 0 : ulong cap_slots [ FD_GUI_HIST_CNT ]; ulong free_slots [ FD_GUI_HIST_CNT ];
253 0 : memset( used_bytes, 0, sizeof(used_bytes) );
254 0 : memset( cap_bytes, 0, sizeof(cap_bytes) ); memset( free_bytes, 0, sizeof(free_bytes) );
255 0 : memset( used_slots, 0, sizeof(used_slots) );
256 0 : memset( cap_slots, 0, sizeof(cap_slots) ); memset( free_slots, 0, sizeof(free_slots) );
257 :
258 0 : for( ulong i=0UL; i<db_cnt; i++ ) {
259 0 : fd_gui_store_ring_stats( ctx->db, i,
260 0 : &used_bytes[ i ],
261 0 : &cap_bytes[ i ], &free_bytes[ i ],
262 0 : &used_slots[ i ],
263 0 : &cap_slots[ i ], &free_slots[ i ] );
264 0 : }
265 :
266 0 : gui_db_metric_copy( MIDX( GAUGE, GUI, DB_USED_BYTES ), used_bytes );
267 0 : gui_db_metric_copy( MIDX( GAUGE, GUI, DB_ALLOCATED_BYTES ), cap_bytes );
268 0 : FD_MGAUGE_SET( GUI, DB_FREE_BYTES, fd_gui_store_free_region_cnt( ctx->db )*FD_GUI_STORE_REGION_SZ ); /* shared by every ring */
269 0 : gui_db_metric_copy( MIDX( GAUGE, GUI, DB_RECORD_USED ), used_slots );
270 0 : gui_db_metric_copy( MIDX( GAUGE, GUI, DB_RECORD_ALLOCATED ), cap_slots );
271 :
272 0 : fd_gui_store_metrics_t const * dm = fd_gui_store_metrics( ctx->db );
273 0 : fd_gui_hist_metrics_t const * hist = fd_gui_hist_metrics( ctx->gui );
274 0 : static ulong const zero_hist_metrics[ FD_GUI_HIST_CNT ] = { 0UL };
275 0 : ulong const * hist_map_full = hist ? hist->map_full : zero_hist_metrics;
276 0 : ulong const * hist_reserves = hist ? hist->reserves : zero_hist_metrics;
277 0 : gui_db_metric_copy( MIDX( COUNTER, GUI, DB_KV_QUERIED ), dm->kv_lookups );
278 0 : gui_db_metric_copy( MIDX( COUNTER, GUI, DB_TIME_SERIES_RECORD_APPENDED ), dm->ts_appends );
279 0 : gui_db_metric_copy( MIDX( COUNTER, GUI, DB_TIME_SERIES_SCANNED ), dm->ts_reads );
280 0 : gui_db_metric_copy( MIDX( COUNTER, GUI, DB_TIME_SERIES_RECORD_READ ), dm->ts_read_records );
281 0 : gui_db_metric_copy( MIDX( COUNTER, GUI, DB_RECORD_EVICTED ), dm->evict_records );
282 0 : gui_db_metric_copy( MIDX( COUNTER, GUI, DB_EVICTION_PASS_COMPLETED ), dm->evicts );
283 0 : gui_db_metric_copy( MIDX( COUNTER, GUI, DB_REGION_CLAIMED ), dm->region_grows );
284 0 : gui_db_metric_copy( MIDX( COUNTER, GUI, DB_REGION_RELEASED ), dm->region_reclaims );
285 0 : gui_db_metric_copy( MIDX( COUNTER, GUI, DB_RECORD_DROPPED ), hist_map_full );
286 0 : gui_db_metric_copy( MIDX( COUNTER, GUI, DB_FORCED_EVICT_WRITE_COMPLETED ), hist_reserves );
287 0 : }
288 :
289 : static inline void
290 : deadline_update( fd_gui_ctx_t * ctx,
291 0 : long now ) {
292 0 : long due = fd_long_min( fd_gui_next_deadline( ctx->gui ), fd_gui_peers_next_deadline( ctx->peers ) );
293 0 : ctx->deadline_ticks = due-now>=FD_SLEEP_PARK_CAP_NS ? LONG_MAX : fd_clock_tile_wallclock_to_tickcount( ctx->clock, due );
294 0 : }
295 :
296 : static long
297 0 : next_deadline( fd_gui_ctx_t const * ctx ) {
298 0 : return ctx->deadline_ticks;
299 0 : }
300 :
301 : static void
302 : before_credit( fd_gui_ctx_t * ctx,
303 : fd_stem_context_t * stem,
304 0 : int * charge_busy ) {
305 0 : ctx->idle_cnt++;
306 0 : int due = stem->now>=ctx->deadline_ticks;
307 0 : if( FD_LIKELY( ctx->idle_cnt<2UL*ctx->in_cnt && !due ) ) return;
308 0 : ctx->idle_cnt = 0UL;
309 :
310 0 : int charge_busy_server = 0;
311 0 : long now = fd_clock_tile_now( ctx->clock );
312 : /* Wake protocol (fd_waker.h): only service fds when the waker
313 : raised our readiness word. Clear FIRST, service a bounded
314 : amount, rearm LAST. The drain is deliberately bounded (gui is
315 : a reliable consumer of hot links; unbounded fd work here would
316 : backpressure replay): EPOLL_CTL_MOD re-polls the inner set
317 : immediately, so leftover or raced readiness re-fires the outer
318 : set and servicing resumes next iteration. */
319 0 : if( FD_UNLIKELY( fd_fseq_query( ctx->waker_fseq )==1UL ) ) {
320 0 : fd_fseq_update( ctx->waker_fseq, 0UL );
321 : /* 8 matches a browser's per-host parallel connection budget */
322 0 : charge_busy_server = fd_http_server_epoll_poll( ctx->gui_server, 8UL );
323 0 : fd_waker_client_rearm( ctx->waker_client_idx );
324 0 : }
325 :
326 0 : int charge_poll = 0;
327 0 : charge_poll |= fd_gui_poll( ctx->gui, now );
328 0 : charge_poll |= fd_gui_peers_poll( ctx->peers, now );
329 :
330 0 : deadline_update( ctx, now );
331 :
332 0 : *charge_busy = charge_busy_server | charge_poll;
333 0 : }
334 :
335 : static int
336 : before_frag( fd_gui_ctx_t * ctx,
337 : ulong in_idx,
338 : ulong seq,
339 0 : ulong sig ) {
340 0 : (void)seq;
341 :
342 0 : if( FD_LIKELY( ctx->in_kind[ in_idx ]==IN_KIND_PACK_POH && sig==FD_PACK_MSG_REDUCE_MB_BOUND ) ) return 1;
343 0 : if( FD_LIKELY( ctx->in_kind[ in_idx ]==IN_KIND_EXECRP_REPLAY && sig>>32!=FD_EXECRP_TT_TXN_EXEC ) ) return 1;
344 :
345 0 : if( FD_LIKELY( ctx->in_kind[ in_idx ]==IN_KIND_GOSSIP_OUT &&
346 0 : (sig==FD_GOSSIP_UPDATE_TAG_WFS_DONE || sig==FD_GOSSIP_UPDATE_TAG_PEER_SATURATED) ) ) return 1;
347 0 : return 0;
348 0 : }
349 :
350 : static inline void
351 : during_frag( fd_gui_ctx_t * ctx,
352 : ulong in_idx,
353 : ulong seq FD_PARAM_UNUSED,
354 : ulong sig,
355 : ulong chunk,
356 : ulong sz,
357 0 : ulong ctl ) {
358 0 : uchar * src = (uchar *)fd_chunk_to_laddr( ctx->in[ in_idx ].mem, chunk );
359 :
360 0 : if( FD_LIKELY( ctx->in_kind[ in_idx ]==IN_KIND_EPOCH ) ) {
361 0 : fd_epoch_info_msg_t * epoch_info = (fd_epoch_info_msg_t *)src;
362 0 : FD_TEST( epoch_info->staked_vote_cnt<=MAX_STAKE_WEIGHTS );
363 0 : FD_TEST( epoch_info->staked_id_cnt<=MAX_STAKE_WEIGHTS );
364 0 : sz = fd_epoch_info_msg_sz( epoch_info->staked_vote_cnt, epoch_info->staked_id_cnt );
365 0 : }
366 :
367 0 : if( FD_UNLIKELY( ctx->in_kind[ in_idx ]==IN_KIND_GENESI_OUT ) ) {
368 0 : sz = sig;
369 0 : }
370 :
371 0 : if( FD_UNLIKELY( ctx->in_kind[ in_idx ]==IN_KIND_DIAG ) ) {
372 0 : sz = sig;
373 0 : }
374 :
375 0 : if( FD_LIKELY( ctx->in_kind[ in_idx ]==IN_KIND_REPLAY_OUT ) ) {
376 0 : if( FD_LIKELY( sig!=REPLAY_SIG_SLOT_COMPLETED &&
377 0 : sig!=REPLAY_SIG_BECAME_LEADER &&
378 0 : sig!=REPLAY_SIG_ROOT_ADVANCED &&
379 0 : sig!=REPLAY_SIG_TXN_EXECUTED ) ) return;
380 0 : }
381 :
382 0 : if( FD_UNLIKELY( (sz>0UL && (chunk<ctx->in[ in_idx ].chunk0 || chunk>ctx->in[ in_idx ].wmark)) || sz>ctx->in[ in_idx ].mtu ) )
383 0 : FD_LOG_ERR(( "in_kind %lu chunk %lu %lu corrupt, not in range [%lu,%lu] or too large (%lu)", ctx->in_kind[ in_idx ], chunk, sz, ctx->in[ in_idx ].chunk0, ctx->in[ in_idx ].wmark, ctx->in[ in_idx ].mtu ));
384 :
385 0 : switch( ctx->in_kind[ in_idx ] ) {
386 0 : case IN_KIND_REPAIR_NET: {
387 0 : ctx->parsed.repair_net.slot = ULONG_MAX;
388 0 : uchar * payload;
389 0 : ulong payload_sz;
390 0 : if( FD_LIKELY( fd_ip4_udp_hdr_strip( src, sz, &payload, &payload_sz, NULL, NULL, NULL ) ) ) {
391 0 : fd_repair_shred_t shred;
392 0 : fd_ed25519_sig_t signature;
393 0 : fd_pubkey_t sender;
394 0 : fd_pubkey_t recipient;
395 0 : ulong timestamp;
396 0 : uint nonce;
397 0 : if( FD_LIKELY( fd_repair_req_window_index_de( payload, payload_sz, &shred, signature, &sender, &recipient, ×tamp, &nonce ) ) ) {
398 0 : if( FD_UNLIKELY( shred.slot==0 ) ) break;
399 0 : ctx->parsed.repair_net.slot = shred.slot;
400 0 : ctx->parsed.repair_net.shred_idx = shred.shred_idx;
401 0 : }
402 0 : }
403 0 : break;
404 0 : }
405 0 : case IN_KIND_GOSSVF_GUI:
406 0 : case IN_KIND_GOSSIP_GUI: {
407 0 : FD_TEST( sz<=sizeof(ctx->parsed.gossip_bw) && !(sz%sizeof(fd_gui_gossip_bw_rec_t)) );
408 0 : fd_memcpy( ctx->parsed.gossip_bw, src, sz );
409 0 : break;
410 0 : }
411 0 : case IN_KIND_SNAPSV_OUT: {
412 0 : FD_TEST( sz<=sizeof(ctx->parsed.snapsv_out) );
413 0 : fd_memcpy( &ctx->parsed.snapsv_out, src, sz );
414 0 : ctx->parsed.snapsv_eom = fd_frag_meta_ctl_eom( ctl );
415 0 : break;
416 0 : }
417 0 : case IN_KIND_VOTOR_OUT: {
418 0 : if( FD_UNLIKELY( sz!=sizeof(fd_votor_msg_t) ) ) break;
419 0 : fd_memcpy( &ctx->parsed.votor_out, src, sz );
420 0 : break;
421 0 : }
422 0 : }
423 :
424 0 : ctx->chunk = chunk;
425 0 : }
426 :
427 : static inline void
428 : after_frag( fd_gui_ctx_t * ctx,
429 : ulong in_idx,
430 : ulong seq,
431 : ulong sig,
432 : ulong sz,
433 : ulong tsorig,
434 : ulong tspub,
435 0 : fd_stem_context_t * stem ) {
436 0 : (void)stem;
437 :
438 0 : if( FD_LIKELY( ctx->in_reliable[ in_idx ] ) ) ctx->idle_cnt = 0UL;
439 :
440 0 : uchar * src = (uchar *)fd_chunk_to_laddr( ctx->in[ in_idx ].mem, ctx->chunk );
441 :
442 0 : switch( ctx->in_kind[ in_idx ] ) {
443 0 : case IN_KIND_EXECRP_REPLAY: {
444 0 : if( FD_LIKELY( sig>>32==FD_EXECRP_TT_TXN_EXEC ) ) {
445 0 : fd_execrp_task_done_msg_t * msg = (fd_execrp_task_done_msg_t *)src;
446 :
447 0 : long tsorig_ns = fd_clock_tile_tickcomp_to_wallclock( ctx->clock, tsorig );
448 0 : long tspub_ns = fd_clock_tile_tickcomp_to_wallclock( ctx->clock, tspub );
449 0 : fd_gui_handle_exec_txn_done( ctx->gui, msg->txn_exec->slot, msg->txn_exec->start_shred_idx, msg->txn_exec->end_shred_idx, tsorig_ns, tspub_ns, fd_clock_tile_now( ctx->clock ) );
450 0 : }
451 :
452 0 : break;
453 0 : }
454 0 : case IN_KIND_VOTOR_OUT: {
455 0 : if( FD_UNLIKELY( sz!=sizeof(fd_votor_msg_t) ) ) return;
456 :
457 0 : fd_votor_msg_t const * msg = &ctx->parsed.votor_out;
458 :
459 0 : switch( sig ) {
460 0 : case FD_VOTOR_SIG_CERTED: {
461 0 : fd_votor_certed_t const * certed = &msg->certed;
462 0 : switch( certed->kind ) {
463 0 : case AG_CERT_KIND_FINAL: fd_gui_handle_ag_finalized( ctx->gui, certed->slot, &certed->block_id, FD_GUI_AG_FINAL_SLOW ); break;
464 0 : case AG_CERT_KIND_FAST_FINAL: fd_gui_handle_ag_finalized( ctx->gui, certed->slot, &certed->block_id, FD_GUI_AG_FINAL_FAST ); break;
465 0 : case AG_CERT_KIND_NOTAR: fd_gui_handle_ag_notarized( ctx->gui, certed->slot, &certed->block_id, FD_GUI_AG_NOTAR_REGULAR ); break;
466 0 : case AG_CERT_KIND_NOTAR_FALLBACK: fd_gui_handle_ag_notarized( ctx->gui, certed->slot, &certed->block_id, FD_GUI_AG_NOTAR_FALLBACK ); break;
467 0 : case AG_CERT_KIND_SKIP: fd_gui_handle_ag_skip_cert( ctx->gui, certed->slot ); break;
468 0 : default: break;
469 0 : }
470 0 : break;
471 0 : }
472 0 : case FD_VOTOR_SIG_LEADER: fd_gui_handle_ag_leader( ctx->gui, msg->leader.parent_slot ); break;
473 0 : default: break;
474 0 : }
475 0 : break;
476 0 : }
477 0 : case IN_KIND_REPLAY_OUT: {
478 0 : if( FD_UNLIKELY( sig==REPLAY_SIG_SLOT_COMPLETED ) ) {
479 0 : fd_replay_slot_completed_t const * slot_completed = (fd_replay_slot_completed_t const *)src;
480 :
481 0 : fd_gui_handle_replay_update( ctx->gui, slot_completed, fd_clock_tile_now( ctx->clock ) );
482 0 : fd_gui_peers_handle_slot_completed( ctx->peers, slot_completed->slot, slot_completed->epoch, &slot_completed->footer );
483 0 : } else if( FD_UNLIKELY( sig==REPLAY_SIG_BECAME_LEADER ) ) {
484 0 : fd_became_leader_t * became_leader = (fd_became_leader_t *)src;
485 0 : fd_gui_became_leader( ctx->gui, became_leader->slot, became_leader->slot_start_ns, became_leader->slot_end_ns, became_leader->limits.slot_max_cost, became_leader->max_microblocks_in_slot, became_leader->bank_seq );
486 0 : } else if( FD_UNLIKELY( sig==REPLAY_SIG_ROOT_ADVANCED ) ) {
487 0 : fd_replay_root_advanced_t const * ra = (fd_replay_root_advanced_t const *)src;
488 0 : fd_gui_handle_root_advanced( ctx->gui, ra->slot, ra->bank_seq, fd_clock_tile_now( ctx->clock ) );
489 0 : } else if( FD_LIKELY( sig==REPLAY_SIG_TXN_EXECUTED ) ) {
490 0 : if( FD_UNLIKELY( sz!=sizeof(fd_replay_txn_executed_t) ) ) FD_LOG_ERR(( "invalid replay transaction message size %lu", sz ));
491 0 : fd_gui_handle_replay_txn( ctx->gui, (fd_replay_txn_executed_t const *)src, fd_clock_tile_now( ctx->clock ) );
492 0 : } else {
493 0 : return;
494 0 : }
495 0 : break;
496 0 : }
497 0 : case IN_KIND_EPOCH: {
498 0 : fd_epoch_info_msg_t * epoch_info = (fd_epoch_info_msg_t *)src;
499 0 : fd_gui_handle_epoch_info( ctx->gui, epoch_info, fd_clock_tile_now( ctx->clock ) );
500 0 : fd_gui_peers_handle_epoch_info( ctx->peers, epoch_info, fd_clock_tile_now( ctx->clock ) );
501 0 : if( fd_gui_wfs_mode( ctx->gui )!=FD_WFS_MODE_NOOP ) fd_gui_peers_start_wfs( ctx->peers, epoch_info, fd_clock_tile_now( ctx->clock ) );
502 0 : break;
503 0 : }
504 0 : case IN_KIND_SNAPIN: {
505 0 : fd_gui_peers_handle_config_account( ctx->peers, src, sz, sig );
506 0 : break;
507 0 : }
508 0 : case IN_KIND_SNAPIN_MANIF: {
509 0 : if( fd_ssmsg_sig_message( sig )!=FD_SSMSG_DONE ) {
510 0 : fd_gui_stage_snapshot_manifest( ctx->gui, (fd_snapshot_manifest_t const *)src );
511 0 : }
512 0 : break;
513 0 : }
514 0 : case IN_KIND_GENESI_OUT: {
515 0 : fd_genesis_meta_t const * meta = (fd_genesis_meta_t const *)src;
516 0 : fd_gui_handle_genesis_hash( ctx->gui, &meta->genesis_hash );
517 0 : break;
518 0 : }
519 0 : case IN_KIND_SHRED_OUT: {
520 0 : long tsorig_nanos = fd_clock_tile_tickcomp_to_wallclock( ctx->clock, tsorig );
521 0 : uint sig_src = fd_shred_sig_src( sig );
522 : /* Skip repair shreds that have already been received via turbine. */
523 0 : if( FD_LIKELY( ( sig_src==SHRED_SIG_SRC_TURBINE || sig_src==SHRED_SIG_SRC_REPAIR || sig_src==SHRED_SIG_SRC_BAD_REPAIR ) &&
524 0 : fd_shred_sig_res( sig )!=SHRED_SIG_RESULT_DUPLICATE ) ) {
525 0 : fd_shred_base_t const * msg = (fd_shred_base_t const *)fd_type_pun_const( src );
526 0 : ulong slot = msg->shred.slot;
527 0 : ulong shred_idx = msg->shred.idx;
528 0 : int is_turbine = sig_src==SHRED_SIG_SRC_TURBINE;
529 : /* tsorig is the timestamp when the shred was received by the shred tile */
530 0 : fd_gui_handle_shred( ctx->gui, slot, shred_idx, is_turbine, tsorig_nanos, fd_clock_tile_now( ctx->clock ) );
531 0 : }
532 0 : if( FD_UNLIKELY( sig==SHRED_SIG_FEC_COMPLETE_LEADER ) ) {
533 0 : fd_fec_complete_t const * complete_msg = (fd_fec_complete_t const *)fd_type_pun_const( src );
534 0 : fd_gui_handle_leader_fec( ctx->gui, complete_msg->last_shred_hdr.slot, FD_FEC_SHRED_CNT, complete_msg->last_shred_hdr.data.flags & FD_SHRED_DATA_FLAG_SLOT_COMPLETE, tsorig_nanos, fd_clock_tile_now( ctx->clock ) );
535 0 : }
536 0 : break;
537 0 : }
538 0 : case IN_KIND_SNAPCT: {
539 0 : fd_gui_handle_snapshot_update( ctx->gui, (fd_snapct_update_t *)src );
540 0 : break;
541 0 : }
542 0 : case IN_KIND_SNAPSV_OUT: {
543 0 : long sample_time_nanos = fd_frag_meta_ts_decomp( tspub, fd_clock_tile_now( ctx->clock ) );
544 0 : fd_gui_handle_snapsv_update( ctx->gui, sig, &ctx->parsed.snapsv_out, sz, ctx->parsed.snapsv_eom, sample_time_nanos );
545 0 : break;
546 0 : }
547 0 : case IN_KIND_REPAIR_NET: {
548 0 : if( FD_UNLIKELY( ctx->parsed.repair_net.slot==ULONG_MAX ) ) break;
549 0 : long tsorig_ns = fd_clock_tile_tickcomp_to_wallclock( ctx->clock, tsorig );
550 0 : fd_gui_handle_repair_request( ctx->gui, ctx->parsed.repair_net.slot, ctx->parsed.repair_net.shred_idx, tsorig_ns, fd_clock_tile_now( ctx->clock ) );
551 0 : break;
552 0 : }
553 0 : case IN_KIND_GOSSVF_GUI:
554 0 : case IN_KIND_GOSSIP_GUI: {
555 0 : fd_gui_peers_handle_gossip_bw( ctx->peers, ctx->parsed.gossip_bw, sz/sizeof(fd_gui_gossip_bw_rec_t), ctx->in_kind[ in_idx ]==IN_KIND_GOSSVF_GUI );
556 0 : break;
557 0 : }
558 0 : case IN_KIND_GOSSIP_OUT: {
559 0 : fd_gui_peers_handle_gossip_update( ctx->peers, (fd_gossip_update_message_t *)src, fd_clock_tile_now( ctx->clock ) );
560 0 : break;
561 0 : }
562 0 : case IN_KIND_PACK_POH: {
563 0 : if( FD_UNLIKELY( sig==FD_PACK_MSG_DONE_DRAINING ) ) fd_gui_done_draining( ctx->gui, fd_clock_tile_now( ctx->clock ) );
564 0 : else fd_gui_unbecame_leader( ctx->gui, fd_disco_execle_sig_slot( sig ), (fd_done_packing_t const *)src );
565 0 : break;
566 0 : }
567 0 : case IN_KIND_PACK_EXECLE: {
568 0 : FD_TEST( sz>=sizeof(fd_microblock_execle_trailer_t) );
569 0 : FD_TEST( (sz-sizeof(fd_microblock_execle_trailer_t))%sizeof(fd_txn_e_t)==0UL );
570 :
571 0 : if( FD_LIKELY( fd_disco_poh_sig_pkt_type( sig )==POH_PKT_TYPE_MICROBLOCK ) ) {
572 0 : fd_microblock_execle_trailer_t trailer[1];
573 0 : fd_memcpy( trailer, src+sz-sizeof(fd_microblock_execle_trailer_t), sizeof(fd_microblock_execle_trailer_t) );
574 0 : long tspub_ns = fd_clock_tile_tickcomp_to_wallclock( ctx->clock, tspub );
575 0 : fd_gui_microblock_execution_begin( ctx->gui,
576 0 : tspub_ns,
577 0 : fd_disco_poh_sig_slot( sig ),
578 0 : (fd_txn_e_t *)src,
579 0 : (sz-sizeof( fd_microblock_execle_trailer_t ))/sizeof( fd_txn_e_t ),
580 0 : (uint)trailer->microblock_idx,
581 0 : trailer->pack_txn_idx,
582 0 : trailer->bank_seq,
583 0 : fd_clock_tile_now( ctx->clock ) );
584 0 : } else {
585 0 : FD_LOG_ERR(( "unexpected poh packet type %lu", fd_disco_poh_sig_pkt_type( sig ) ));
586 0 : }
587 : /* The link is shallow; return the credit now, like the execle. */
588 0 : fd_stem_credit_return( stem, in_idx, seq+1UL );
589 0 : break;
590 0 : }
591 0 : case IN_KIND_EXECLE_POH: {
592 0 : FD_TEST( sz>=sizeof(fd_microblock_trailer_t) );
593 0 : FD_TEST( (sz-sizeof(fd_microblock_trailer_t))%sizeof(fd_txn_p_t)==0UL );
594 :
595 0 : fd_microblock_trailer_t trailer[1];
596 0 : fd_memcpy( trailer, src+sz-sizeof(fd_microblock_trailer_t), sizeof(fd_microblock_trailer_t) );
597 0 : long tspub_ns = fd_clock_tile_tickcomp_to_wallclock( ctx->clock, tspub );
598 0 : ulong txn_cnt = (sz-sizeof( fd_microblock_trailer_t ))/sizeof(fd_txn_p_t);
599 0 : fd_gui_microblock_execution_end( ctx->gui,
600 0 : tspub_ns,
601 0 : ctx->in_bank_idx[ in_idx ],
602 0 : fd_disco_execle_sig_slot( sig ),
603 0 : txn_cnt,
604 0 : (fd_txn_p_t *)src,
605 0 : trailer->pack_txn_idx,
606 0 : trailer->txn_ns_dt,
607 0 : trailer->exec_end_ticks,
608 0 : trailer->tips,
609 0 : trailer->bank_seq,
610 0 : fd_clock_tile_now( ctx->clock ) );
611 0 : break;
612 0 : }
613 0 : case IN_KIND_BUNDLE: {
614 0 : fd_gui_handle_block_engine_update( ctx->gui, (fd_bundle_block_engine_update_t *)src );
615 0 : break;
616 0 : }
617 0 : case IN_KIND_DIAG: {
618 0 : fd_gui_handle_diag_snapshot( ctx->gui, src, sig );
619 0 : break;
620 0 : }
621 0 : default: FD_LOG_ERR(( "unexpected in_kind %lu", ctx->in_kind[ in_idx ] ));
622 0 : }
623 0 : }
624 :
625 : static int
626 : returnable_frag( fd_gui_ctx_t * ctx,
627 : ulong in_idx,
628 : ulong seq FD_PARAM_UNUSED,
629 : ulong sig FD_PARAM_UNUSED,
630 : ulong chunk FD_PARAM_UNUSED,
631 : ulong sz FD_PARAM_UNUSED,
632 : ulong ctl FD_PARAM_UNUSED,
633 : ulong tsorig FD_PARAM_UNUSED,
634 : ulong tspub FD_PARAM_UNUSED,
635 0 : fd_stem_context_t * stem FD_PARAM_UNUSED ) {
636 0 : if( FD_UNLIKELY( ctx->in_kind[ in_idx ]==IN_KIND_REPLAY_OUT && !ctx->gui->epoch.has_epoch_schedule ) ) return 1; /* epoch info not received yet: defer polling */
637 0 : return 0;
638 0 : }
639 :
640 : static fd_http_server_response_t
641 990 : gui_http_request( fd_http_server_request_t const * request ) {
642 990 : if( FD_UNLIKELY( request->method!=FD_HTTP_SERVER_METHOD_GET ) ) {
643 0 : return (fd_http_server_response_t){
644 0 : .status = 405,
645 0 : };
646 0 : }
647 :
648 990 : if( FD_LIKELY( !strcmp( request->path, "/websocket" ) ) ) {
649 0 : return (fd_http_server_response_t){
650 0 : .status = 200,
651 0 : .upgrade_websocket = 1,
652 0 : .compress_websocket = request->headers.compress_websocket,
653 0 : };
654 990 : } else if( FD_LIKELY( !strcmp( request->path, "/favicon.svg" ) ) ) {
655 0 : return (fd_http_server_response_t){
656 0 : .status = 200,
657 0 : .static_body = firedancer_svg,
658 0 : .static_body_len = firedancer_svg_sz,
659 0 : .content_type = "image/svg+xml",
660 0 : .cache_control = "public, max-age=86400",
661 0 : .upgrade_websocket = 0,
662 0 : };
663 0 : }
664 :
665 990 : int is_vite_page = !strcmp( request->path, "/" ) ||
666 990 : !strcmp( request->path, "/slotDetails" ) ||
667 990 : !strcmp( request->path, "/leaderSchedule" ) ||
668 990 : !strcmp( request->path, "/gossip") ||
669 990 : !strcmp( request->path, "/accounts") ||
670 990 : !strncmp( request->path, "/?", strlen("/?") ) ||
671 990 : !strncmp( request->path, "/slotDetails?", strlen("/slotDetails?") ) ||
672 990 : !strncmp( request->path, "/leaderSchedule?", strlen("/leaderSchedule?") ) ||
673 990 : !strncmp( request->path, "/gossip?", strlen("/gossip?") ) ||
674 990 : !strncmp( request->path, "/accounts?", strlen("/accounts?") );
675 :
676 12120 : for( fd_http_static_file_t const * f = STATIC_FILES; f->name; f++ ) {
677 12120 : if( !strcmp( request->path, f->name ) ||
678 12120 : (!strcmp( f->name, "/index.html" ) && is_vite_page) ) {
679 990 : char const * content_type = NULL;
680 :
681 990 : char const * ext = strrchr( f->name, '.' );
682 990 : if( FD_LIKELY( ext ) ) {
683 906 : if( !strcmp( ext, ".html" ) ) content_type = "text/html; charset=utf-8";
684 840 : else if( !strcmp( ext, ".css" ) ) content_type = "text/css";
685 798 : else if( !strcmp( ext, ".js" ) ) content_type = "application/javascript";
686 672 : else if( !strcmp( ext, ".svg" ) ) content_type = "image/svg+xml";
687 210 : else if( !strcmp( ext, ".woff" ) ) content_type = "font/woff";
688 126 : else if( !strcmp( ext, ".woff2" ) ) content_type = "font/woff2";
689 0 : else if( !strcmp( ext, ".wasm" ) ) content_type = "application/wasm";
690 906 : }
691 :
692 990 : char const * cache_control = NULL;
693 990 : if( FD_LIKELY( !strncmp( request->path, "/assets", 7 ) ) ) cache_control = "public, max-age=31536000, immutable";
694 150 : else if( FD_LIKELY( !strcmp( f->name, "/index.html" ) ) ) cache_control = "no-cache";
695 84 : else if( FD_UNLIKELY( !strcmp( f->name, "/version" ) ) ) cache_control = "no-cache";
696 :
697 990 : const uchar * data = f->data;
698 990 : ulong data_len = *(f->data_len);
699 :
700 990 : int q_zstd = 0;
701 990 : int q_gzip = 0;
702 990 : if( FD_LIKELY( request->headers.accept_encoding ) ) {
703 921 : q_zstd = fd_http_server_accept_encoding_q( request->headers.accept_encoding, "zstd" );
704 921 : q_gzip = fd_http_server_accept_encoding_q( request->headers.accept_encoding, "gzip" );
705 921 : }
706 :
707 : /* the client's preferred acceptable coding, zstd on a tie; a
708 : variant that did not shrink is not worth the decode */
709 990 : int zstd_ok = q_zstd && f->zstd_data && *(f->zstd_data_len)<data_len;
710 990 : int gzip_ok = q_gzip && f->gzip_data && *(f->gzip_data_len)<data_len;
711 990 : char const * content_encoding = NULL;
712 990 : ulong enc_idx = 0UL;
713 990 : if( FD_LIKELY( zstd_ok && (q_zstd>=q_gzip || !gzip_ok) ) ) {
714 291 : content_encoding = "zstd";
715 291 : data = f->zstd_data;
716 291 : data_len = *(f->zstd_data_len);
717 291 : enc_idx = 1UL;
718 699 : } else if( FD_LIKELY( gzip_ok ) ) {
719 198 : content_encoding = "gzip";
720 198 : data = f->gzip_data;
721 198 : data_len = *(f->gzip_data_len);
722 198 : enc_idx = 2UL;
723 198 : }
724 :
725 990 : char const * etag = NULL;
726 990 : char const * link = NULL;
727 990 : if( FD_LIKELY( !strcmp( f->name, "/index.html" ) ) ) {
728 66 : fd_gui_ctx_t * ctx = (fd_gui_ctx_t *)request->ctx;
729 66 : etag = ctx->index_html_etag[ enc_idx ];
730 66 : link = ctx->index_html_link[ 0 ] ? ctx->index_html_link : NULL;
731 66 : if( FD_UNLIKELY( fd_http_server_etag_matches( request->headers.if_none_match, etag ) ) ) {
732 9 : return (fd_http_server_response_t){
733 9 : .status = 304,
734 9 : .cache_control = cache_control,
735 9 : .vary = "Accept-Encoding",
736 9 : .etag = etag,
737 9 : .link = link,
738 9 : };
739 9 : }
740 66 : }
741 :
742 981 : return (fd_http_server_response_t){
743 981 : .status = 200,
744 981 : .static_body = data,
745 981 : .static_body_len = data_len,
746 981 : .content_type = content_type,
747 981 : .cache_control = cache_control,
748 981 : .content_encoding = content_encoding,
749 981 : .vary = "Accept-Encoding",
750 981 : .etag = etag,
751 981 : .link = link,
752 981 : .upgrade_websocket = 0,
753 981 : };
754 990 : }
755 12120 : }
756 :
757 0 : return (fd_http_server_response_t){
758 0 : .status = 404,
759 0 : };
760 990 : }
761 :
762 : static void
763 : gui_ws_open( ulong conn_id,
764 0 : void * _ctx ) {
765 0 : fd_gui_ctx_t * ctx = (fd_gui_ctx_t *)_ctx;
766 :
767 0 : fd_gui_ws_open( ctx->gui, conn_id, fd_clock_tile_now( ctx->clock ) );
768 0 : fd_gui_peers_ws_open( ctx->peers, conn_id, fd_clock_tile_now( ctx->clock ) );
769 0 : }
770 :
771 : static void
772 : gui_ws_close( ulong conn_id,
773 : int reason,
774 0 : void * _ctx ) {
775 0 : (void) reason;
776 0 : fd_gui_ctx_t * ctx = (fd_gui_ctx_t *)_ctx;
777 0 : fd_gui_peers_ws_close( ctx->peers, conn_id );
778 0 : }
779 :
780 : static void
781 : gui_ws_message( ulong ws_conn_id,
782 : uchar const * data,
783 : ulong data_len,
784 0 : void * _ctx ) {
785 0 : fd_gui_ctx_t * ctx = (fd_gui_ctx_t *)_ctx;
786 :
787 0 : int reason = fd_gui_ws_message( ctx->gui, ws_conn_id, data, data_len );
788 0 : if( FD_UNLIKELY( reason==FD_HTTP_SERVER_CONNECTION_CLOSE_UNKNOWN_METHOD ) ) reason = fd_gui_peers_ws_message( ctx->peers, ws_conn_id, data, data_len );
789 :
790 0 : if( FD_UNLIKELY( reason<0 ) ) fd_http_server_ws_close( ctx->gui_server, ws_conn_id, reason );
791 0 : }
792 :
793 : static void
794 : privileged_init( fd_topo_t const * topo,
795 0 : fd_topo_tile_t const * tile ) {
796 0 : void * scratch = fd_topo_obj_laddr( topo, tile->tile_obj_id );
797 :
798 0 : fd_http_server_params_t http_param = derive_http_params( tile );
799 :
800 0 : FD_SCRATCH_ALLOC_INIT( l, scratch );
801 0 : fd_gui_ctx_t * ctx = FD_SCRATCH_ALLOC_APPEND( l, alignof( fd_gui_ctx_t ), sizeof( fd_gui_ctx_t ) );
802 0 : FD_TEST( fd_rng_secure( &ctx->seed, sizeof(ctx->seed) ) );
803 0 : http_param.treap_seed = ctx->seed;
804 0 : fd_http_server_t * _gui = FD_SCRATCH_ALLOC_APPEND( l, fd_http_server_align(), fd_http_server_footprint( http_param ) );
805 0 : FD_SCRATCH_ALLOC_APPEND( l, fd_gui_peers_align(), fd_gui_peers_footprint( http_param.max_ws_connection_cnt ) );
806 0 : FD_SCRATCH_ALLOC_APPEND( l, fd_gui_align(), fd_gui_footprint( tile->gui.tile_cnt, tile->gui.max_live_slots, tile->gui.max_txn_per_slot ) );
807 0 : void * _db = FD_SCRATCH_ALLOC_APPEND( l, fd_gui_store_align(), fd_gui_store_footprint( tile->gui.db_size_gib<<30, fd_gui_hist_db_cnt(), fd_gui_hist_db_descs( tile->gui.db_size_gib<<30 ) ) );
808 :
809 0 : fd_http_server_callbacks_t gui_callbacks = {
810 0 : .request = gui_http_request,
811 0 : .ws_open = gui_ws_open,
812 0 : .ws_close = gui_ws_close,
813 0 : .ws_message = gui_ws_message,
814 0 : };
815 0 : ctx->gui_server = fd_http_server_join( fd_http_server_new( _gui, http_param, gui_callbacks, ctx ) );
816 :
817 0 : ctx->waker_client_idx = tile->waker_client_idx;
818 0 : FD_TEST( ctx->waker_client_idx!=ULONG_MAX );
819 0 : fd_http_server_listen( ctx->gui_server, FD_WAKER_INNER_FD( ctx->waker_client_idx ), tile->gui.listen_addr, tile->gui.listen_port );
820 :
821 0 : FD_LOG_NOTICE(( "gui server listening at %shttp://" FD_IP4_ADDR_FMT ":%u%s", fd_log_style_bold(), FD_IP4_ADDR_FMT_ARGS( tile->gui.listen_addr ), tile->gui.listen_port, fd_log_style_normal() ));
822 :
823 0 : ctx->db = fd_gui_store_join( fd_gui_store_new( _db, tile->gui.gui_database_path, tile->gui.db_size_gib<<30, fd_gui_hist_db_cnt(), ctx->seed, fd_gui_hist_db_descs( tile->gui.db_size_gib<<30 ) ) );
824 0 : if( FD_UNLIKELY( !ctx->db ) ) FD_LOG_ERR(( "fd_gui_store_new(%s) failed; gui tile cannot start", tile->gui.gui_database_path ));
825 :
826 0 : if( FD_UNLIKELY( !strcmp( tile->gui.identity_key_path, "" ) ) )
827 0 : FD_LOG_ERR(( "identity_key_path not set" ));
828 :
829 0 : ctx->identity_key = fd_keyload_load( tile->gui.identity_key_path, /* pubkey only: */ 1 );
830 :
831 0 : if( FD_UNLIKELY( !strcmp( tile->gui.vote_key_path, "" ) ) ) {
832 0 : ctx->has_vote_key = 0;
833 0 : } else {
834 0 : ctx->has_vote_key = 1;
835 0 : if( FD_UNLIKELY( !fd_base58_decode_32( tile->gui.vote_key_path, (uchar *)ctx->vote_key->uc ) ) ) {
836 0 : const uchar * vote_key = fd_keyload_load( tile->gui.vote_key_path, /* pubkey only: */ 1 );
837 0 : fd_memcpy( (uchar *)ctx->vote_key->uc, vote_key, 32UL );
838 0 : }
839 0 : }
840 0 : }
841 :
842 : static int
843 : index_html_refs( fd_http_static_file_t const * html,
844 0 : char const * name ) {
845 0 : ulong name_len = strlen( name );
846 0 : if( FD_UNLIKELY( name_len>*(html->data_len) ) ) return 0;
847 0 : for( ulong i=0UL; i<=*(html->data_len)-name_len; i++ ) if( FD_UNLIKELY( !memcmp( html->data+i, name, name_len ) ) ) return 1;
848 0 : return 0;
849 0 : }
850 :
851 : /* One ETag per index.html representation (plain, zstd, gzip). Returns
852 : the index.html static file. */
853 :
854 : static fd_http_static_file_t const *
855 3 : index_html_etag_init( fd_gui_ctx_t * ctx ) {
856 3 : fd_http_static_file_t const * index_html = NULL;
857 72 : for( fd_http_static_file_t const * f = STATIC_FILES; f->name; f++ ) {
858 69 : if( FD_UNLIKELY( !strcmp( f->name, "/index.html" ) ) ) index_html = f;
859 69 : }
860 3 : FD_TEST( index_html );
861 :
862 3 : fd_http_static_file_t const * f = index_html;
863 3 : uchar hash[ 32 ];
864 3 : uchar const * rep_data[ 3 ] = { f->data, f->zstd_data, f->gzip_data };
865 3 : ulong const * rep_data_len[ 3 ] = { f->data_len, f->zstd_data_len, f->gzip_data_len };
866 12 : for( ulong e=0UL; e<3UL; e++ ) {
867 9 : ctx->index_html_etag[ e ][ 0 ] = '\0';
868 9 : if( FD_UNLIKELY( !rep_data[ e ] ) ) continue;
869 9 : fd_sha256_hash( rep_data[ e ], *(rep_data_len[ e ]), hash );
870 9 : char b64[ FD_BASE64_ENC_SZ( 9UL )+1UL ];
871 9 : b64[ fd_base64_encode( b64, hash, 9UL ) ] = '\0';
872 9 : FD_TEST( fd_cstr_printf_check( ctx->index_html_etag[ e ], sizeof(ctx->index_html_etag[ e ]), NULL, "\"%s\"", b64 ) );
873 9 : }
874 3 : return index_html;
875 3 : }
876 :
877 : static void
878 : unprivileged_init( fd_topo_t const * topo,
879 0 : fd_topo_tile_t const * tile ) {
880 0 : void * scratch = fd_topo_obj_laddr( topo, tile->tile_obj_id );
881 :
882 0 : fd_http_server_params_t http_param = derive_http_params( tile );
883 0 : FD_SCRATCH_ALLOC_INIT( l, scratch );
884 0 : fd_gui_ctx_t * ctx = FD_SCRATCH_ALLOC_APPEND( l, alignof( fd_gui_ctx_t ), sizeof( fd_gui_ctx_t ) );
885 0 : FD_SCRATCH_ALLOC_APPEND( l, fd_http_server_align(), fd_http_server_footprint( http_param ) );
886 0 : void * _peers = FD_SCRATCH_ALLOC_APPEND( l, fd_gui_peers_align(), fd_gui_peers_footprint( http_param.max_ws_connection_cnt) );
887 0 : void * _gui = FD_SCRATCH_ALLOC_APPEND( l, fd_gui_align(), fd_gui_footprint( tile->gui.tile_cnt, tile->gui.max_live_slots, tile->gui.max_txn_per_slot ) );
888 0 : FD_SCRATCH_ALLOC_APPEND( l, fd_gui_store_align(), fd_gui_store_footprint( tile->gui.db_size_gib<<30, fd_gui_hist_db_cnt(), fd_gui_hist_db_descs( tile->gui.db_size_gib<<30 ) ) );
889 :
890 0 : fd_http_static_file_t const * index_html = index_html_etag_init( ctx );
891 :
892 0 : char const * preload_js = NULL;
893 0 : char const * preload_css = NULL;
894 0 : char const * preload_worker = NULL;
895 0 : char const * preload_wasm = NULL;
896 0 : char const * split_js[ 16 ];
897 0 : ulong split_js_cnt = 0UL;
898 0 : for( fd_http_static_file_t const * f = STATIC_FILES; f->name; f++ ) {
899 0 : char const * ext = strrchr( f->name, '.' );
900 0 : if( FD_UNLIKELY( !ext ) ) continue;
901 0 : if( FD_UNLIKELY( !strncmp( f->name, "/assets/index-", 14UL ) ) ) {
902 0 : if( !strcmp( ext, ".js" ) ) {
903 0 : if( FD_UNLIKELY( index_html_refs( index_html, f->name ) ) ) preload_js = f->name;
904 0 : else if( FD_LIKELY( split_js_cnt<sizeof(split_js)/sizeof(split_js[ 0 ]) ) ) split_js[ split_js_cnt++ ] = f->name;
905 0 : }
906 0 : else if( !strcmp( ext, ".css" ) && index_html_refs( index_html, f->name ) ) preload_css = f->name;
907 0 : }
908 0 : else if( FD_UNLIKELY( !strncmp( f->name, "/assets/wsWorker-", 17UL ) && !strcmp( ext, ".js" ) ) ) preload_worker = f->name;
909 0 : else if( FD_UNLIKELY( !strncmp( f->name, "/assets/zstd-dec-", 17UL ) && !strcmp( ext, ".wasm" ) ) ) preload_wasm = f->name;
910 0 : else if( FD_UNLIKELY( !strncmp( f->name, "/assets/UplotReact-", 19UL ) && !strcmp( ext, ".js" ) &&
911 0 : split_js_cnt<sizeof(split_js)/sizeof(split_js[ 0 ]) ) ) split_js[ split_js_cnt++ ] = f->name;
912 0 : }
913 :
914 0 : ctx->index_html_link[ 0 ] = '\0';
915 0 : ulong off = 0UL, sz;
916 0 : if( FD_LIKELY( preload_js ) ) {
917 0 : FD_TEST( fd_cstr_printf_check( ctx->index_html_link+off, sizeof(ctx->index_html_link)-off, &sz, "%s<%s>; rel=modulepreload", off ? ", " : "", preload_js ) );
918 0 : off += sz;
919 0 : }
920 0 : if( FD_LIKELY( preload_css ) ) {
921 0 : FD_TEST( fd_cstr_printf_check( ctx->index_html_link+off, sizeof(ctx->index_html_link)-off, &sz, "%s<%s>; rel=preload; as=style; crossorigin", off ? ", " : "", preload_css ) );
922 0 : off += sz;
923 0 : }
924 0 : if( FD_LIKELY( preload_worker ) ) {
925 0 : FD_TEST( fd_cstr_printf_check( ctx->index_html_link+off, sizeof(ctx->index_html_link)-off, &sz, "%s<%s>; rel=preload; as=worker", off ? ", " : "", preload_worker ) );
926 0 : off += sz;
927 0 : }
928 0 : if( FD_LIKELY( preload_wasm ) ) {
929 0 : FD_TEST( fd_cstr_printf_check( ctx->index_html_link+off, sizeof(ctx->index_html_link)-off, &sz, "%s<%s>; rel=preload; as=fetch; crossorigin", off ? ", " : "", preload_wasm ) );
930 0 : off += sz;
931 0 : }
932 0 : for( ulong i=0UL; i<split_js_cnt; i++ ) {
933 0 : FD_TEST( fd_cstr_printf_check( ctx->index_html_link+off, sizeof(ctx->index_html_link)-off, &sz, "%s<%s>; rel=modulepreload", off ? ", " : "", split_js[ i ] ) );
934 0 : off += sz;
935 0 : }
936 :
937 0 : ctx->snapshots_enabled = ULONG_MAX!=fd_topo_find_tile( topo, "snapct", 0UL );
938 :
939 0 : fd_clock_tile_init( ctx->clock );
940 :
941 0 : ctx->topo = topo;
942 0 : ctx->peers = fd_gui_peers_join( fd_gui_peers_new( _peers, ctx->gui_server, ctx->topo, http_param.max_ws_connection_cnt, tile->gui.wfs_bank_hash, ctx->seed, fd_clock_tile_now( ctx->clock ) ) );
943 : /* The gui only reads partition stats from the accdb shmem; it never
944 : reads account data from disk, so it does not join the accdb fd. */
945 0 : fd_accdb_shmem_t * accdb_shmem = NULL;
946 0 : if( FD_LIKELY( tile->gui.accdb_obj_id!=ULONG_MAX ) ) {
947 0 : void * accdb_shmem_raw = fd_topo_obj_laddr( topo, tile->gui.accdb_obj_id );
948 0 : FD_TEST( accdb_shmem_raw );
949 0 : accdb_shmem = fd_accdb_shmem_join( accdb_shmem_raw );
950 0 : FD_TEST( accdb_shmem );
951 0 : }
952 0 : ctx->gui = fd_gui_join( fd_gui_new( _gui, ctx->gui_server, fd_version_cstr, tile->gui.cluster, ctx->identity_key, ctx->has_vote_key, ctx->vote_key->uc, tile->gui.max_live_slots, tile->gui.max_txn_per_slot, ctx->snapshots_enabled, tile->gui.is_voting, tile->gui.schedule_strategy, tile->gui.wfs_bank_hash, tile->gui.expected_shred_version, tile->gui.wfs_slot, tile->gui.accounts_database_path, tile->gui.gui_database_path, ctx->db, ctx->topo, accdb_shmem, fd_clock_tile_now( ctx->clock ) ) );
953 0 : FD_TEST( ctx->gui );
954 0 : FD_TEST( ctx->db );
955 :
956 0 : ctx->keyswitch = fd_keyswitch_join( fd_topo_obj_laddr( topo, tile->id_keyswitch_obj_id ) );
957 0 : FD_TEST( ctx->keyswitch );
958 :
959 0 : FD_TEST( ctx->waker_client_idx!=ULONG_MAX );
960 0 : ctx->waker_fseq = fd_fseq_join( fd_topo_obj_laddr( topo, tile->waker_fseq_obj_id ) );
961 0 : FD_TEST( ctx->waker_fseq );
962 :
963 0 : ctx->idle_cnt = 0UL;
964 0 : deadline_update( ctx, fd_clock_tile_now( ctx->clock ) );
965 0 : FD_TEST( tile->in_cnt<=sizeof(ctx->in)/sizeof(ctx->in[0]) );
966 0 : ctx->in_cnt = tile->in_cnt;
967 :
968 0 : for( ulong i=0UL; i<tile->in_cnt; i++ ) {
969 0 : fd_topo_link_t const * link = &topo->links[ tile->in_link_id[ i ] ];
970 0 : fd_topo_wksp_t const * link_wksp = &topo->workspaces[ topo->objs[ link->dcache_obj_id ].wksp_id ];
971 :
972 0 : if( FD_LIKELY( !strcmp( link->name, "pack_execle" ) ) ) ctx->in_kind[ i ] = IN_KIND_PACK_EXECLE;
973 0 : else if( FD_LIKELY( !strcmp( link->name, "pack_poh" ) ) ) ctx->in_kind[ i ] = IN_KIND_PACK_POH;
974 0 : else if( FD_LIKELY( !strcmp( link->name, "execle_poh" ) ) ) ctx->in_kind[ i ] = IN_KIND_EXECLE_POH;
975 0 : else if( FD_LIKELY( !strcmp( link->name, "shred_out" ) ) ) ctx->in_kind[ i ] = IN_KIND_SHRED_OUT;
976 0 : else if( FD_LIKELY( !strcmp( link->name, "gossvf_gui" ) ) ) ctx->in_kind[ i ] = IN_KIND_GOSSVF_GUI;
977 0 : else if( FD_LIKELY( !strcmp( link->name, "gossip_gui" ) ) ) ctx->in_kind[ i ] = IN_KIND_GOSSIP_GUI;
978 0 : else if( FD_LIKELY( !strcmp( link->name, "gossip_ciseen" ) ) ) ctx->in_kind[ i ] = IN_KIND_GOSSIP_OUT;
979 0 : else if( FD_LIKELY( !strcmp( link->name, "snapct_gui" ) ) ) ctx->in_kind[ i ] = IN_KIND_SNAPCT;
980 0 : else if( FD_LIKELY( !strcmp( link->name, "repair_net" ) ) ) ctx->in_kind[ i ] = IN_KIND_REPAIR_NET;
981 0 : else if( FD_LIKELY( !strcmp( link->name, "replay_out" ) ) ) ctx->in_kind[ i ] = IN_KIND_REPLAY_OUT;
982 0 : else if( FD_LIKELY( !strcmp( link->name, "replay_epoch" ) ) ) ctx->in_kind[ i ] = IN_KIND_EPOCH;
983 0 : else if( FD_LIKELY( !strcmp( link->name, "genesi_out" ) ) ) ctx->in_kind[ i ] = IN_KIND_GENESI_OUT;
984 0 : else if( FD_LIKELY( !strcmp( link->name, "snapin_gui" ) ) ) ctx->in_kind[ i ] = IN_KIND_SNAPIN;
985 0 : else if( FD_LIKELY( !strcmp( link->name, "snapin_manif" ) ) ) ctx->in_kind[ i ] = IN_KIND_SNAPIN_MANIF;
986 0 : else if( FD_LIKELY( !strcmp( link->name, "snapsv_out" ) ) ) ctx->in_kind[ i ] = IN_KIND_SNAPSV_OUT;
987 0 : else if( FD_LIKELY( !strcmp( link->name, "execrp_replay" ) ) ) ctx->in_kind[ i ] = IN_KIND_EXECRP_REPLAY;
988 0 : else if( FD_LIKELY( !strcmp( link->name, "bundle_status" ) ) ) ctx->in_kind[ i ] = IN_KIND_BUNDLE;
989 0 : else if( FD_LIKELY( !strcmp( link->name, "diag_gui" ) ) ) ctx->in_kind[ i ] = IN_KIND_DIAG;
990 0 : else if( FD_LIKELY( !strcmp( link->name, "votor_out" ) ) ) ctx->in_kind[ i ] = IN_KIND_VOTOR_OUT;
991 0 : else FD_LOG_ERR(( "gui tile has unexpected input link %lu %s", i, link->name ));
992 :
993 0 : if( FD_LIKELY( !strcmp( link->name, "execle_poh" ) ) ) {
994 0 : ulong producer = fd_topo_find_link_producer( topo, &topo->links[ tile->in_link_id[ i ] ] );
995 0 : ctx->in_bank_idx[ i ] = topo->tiles[ producer ].kind_id;
996 0 : }
997 :
998 0 : ctx->in_reliable[ i ] = tile->in_link_reliable[ i ];
999 0 : ctx->in[ i ].mem = link_wksp->wksp;
1000 0 : ctx->in[ i ].mtu = link->mtu;
1001 0 : ctx->in[ i ].chunk0 = fd_dcache_compact_chunk0( ctx->in[ i ].mem, link->dcache );
1002 0 : ctx->in[ i ].wmark = fd_dcache_compact_wmark ( ctx->in[ i ].mem, link->dcache, link->mtu );
1003 0 : }
1004 :
1005 0 : ulong scratch_top = FD_SCRATCH_ALLOC_FINI( l, scratch_align() );
1006 0 : if( FD_UNLIKELY( scratch_top > (ulong)scratch + scratch_footprint( tile ) ) )
1007 0 : FD_LOG_ERR(( "scratch overflow %lu %lu %lu", scratch_top - (ulong)scratch - scratch_footprint( tile ), scratch_top, (ulong)scratch + scratch_footprint( tile ) ));
1008 0 : }
1009 :
1010 : static ulong
1011 : populate_allowed_seccomp( fd_topo_t const * topo,
1012 : fd_topo_tile_t const * tile,
1013 : ulong out_cnt,
1014 0 : struct sock_filter * out ) {
1015 0 : void * scratch = fd_topo_obj_laddr( topo, tile->tile_obj_id );
1016 0 : FD_SCRATCH_ALLOC_INIT( l, scratch );
1017 0 : fd_gui_ctx_t * ctx = FD_SCRATCH_ALLOC_APPEND( l, alignof( fd_gui_ctx_t ), sizeof( fd_gui_ctx_t ) );
1018 :
1019 0 : uint epoll_inner_fd = (uint)FD_WAKER_INNER_FD( tile->waker_client_idx );
1020 0 : uint epoll_outer_fd = (uint)FD_WAKER_OUTER_FD;
1021 :
1022 0 : populate_sock_filter_policy_fd_gui_tile( out_cnt, out, (uint)fd_log_private_logfile_fd(), (uint)fd_http_server_fd( ctx->gui_server ), (uint)fd_gui_store_fd( ctx->db ), epoll_inner_fd, epoll_outer_fd );
1023 0 : return sock_filter_policy_fd_gui_tile_instr_cnt;
1024 0 : }
1025 :
1026 : static ulong
1027 : populate_allowed_fds( fd_topo_t const * topo,
1028 : fd_topo_tile_t const * tile,
1029 : ulong out_fds_cnt,
1030 0 : int * out_fds ) {
1031 0 : void * scratch = fd_topo_obj_laddr( topo, tile->tile_obj_id );
1032 0 : FD_SCRATCH_ALLOC_INIT( l, scratch );
1033 0 : fd_gui_ctx_t * ctx = FD_SCRATCH_ALLOC_APPEND( l, alignof( fd_gui_ctx_t ), sizeof( fd_gui_ctx_t ) );
1034 :
1035 0 : if( FD_UNLIKELY( out_fds_cnt<6UL ) ) FD_LOG_ERR(( "out_fds_cnt %lu", out_fds_cnt ));
1036 :
1037 0 : ulong out_cnt = 0UL;
1038 0 : out_fds[ out_cnt++ ] = 2; /* stderr */
1039 0 : if( FD_LIKELY( -1!=fd_log_private_logfile_fd() ) )
1040 0 : out_fds[ out_cnt++ ] = fd_log_private_logfile_fd(); /* logfile */
1041 0 : out_fds[ out_cnt++ ] = fd_http_server_fd( ctx->gui_server ); /* gui listen socket */
1042 0 : out_fds[ out_cnt++ ] = fd_gui_store_fd( ctx->db ); /* historical store data file */
1043 0 : out_fds[ out_cnt++ ] = FD_WAKER_OUTER_FD; /* waker outer epoll fd (rearm) */
1044 0 : out_fds[ out_cnt++ ] = FD_WAKER_INNER_FD( tile->waker_client_idx ); /* waker inner epoll fd */
1045 0 : return out_cnt;
1046 0 : }
1047 :
1048 : static ulong
1049 : rlimit_file_cnt( fd_topo_t const * topo FD_PARAM_UNUSED,
1050 0 : fd_topo_tile_t const * tile ) {
1051 : /* pipefd, socket, stderr, logfile, guidb, and one spare for new accept() connections */
1052 0 : ulong base = 6UL;
1053 0 : return base + tile->gui.max_http_connections + tile->gui.max_websocket_connections;
1054 0 : }
1055 :
1056 0 : #define STEM_BURST (2UL)
1057 :
1058 : /* See explanation in fd_pack */
1059 0 : #define STEM_LAZY (128L*3000L)
1060 :
1061 0 : #define STEM_CALLBACK_CONTEXT_TYPE fd_gui_ctx_t
1062 0 : #define STEM_CALLBACK_CONTEXT_ALIGN alignof(fd_gui_ctx_t)
1063 :
1064 0 : #define STEM_CALLBACK_DURING_HOUSEKEEPING during_housekeeping
1065 0 : #define STEM_CALLBACK_METRICS_WRITE metrics_write
1066 0 : #define STEM_CALLBACK_BEFORE_CREDIT before_credit
1067 0 : #define STEM_CALLBACK_NEXT_DEADLINE next_deadline
1068 0 : #define STEM_CALLBACK_BEFORE_FRAG before_frag
1069 0 : #define STEM_CALLBACK_DURING_FRAG during_frag
1070 0 : #define STEM_CALLBACK_RETURNABLE_FRAG returnable_frag
1071 0 : #define STEM_CALLBACK_AFTER_FRAG after_frag
1072 :
1073 : #include "../../disco/stem/fd_stem.c"
1074 :
1075 : #ifndef FD_TILE_TEST
1076 : fd_topo_run_tile_t fd_tile_gui = {
1077 : .name = "gui",
1078 : .rlimit_file_cnt_fn = rlimit_file_cnt,
1079 : .populate_allowed_seccomp = populate_allowed_seccomp,
1080 : .populate_allowed_fds = populate_allowed_fds,
1081 : .scratch_align = scratch_align,
1082 : .scratch_footprint = scratch_footprint,
1083 : .privileged_init = privileged_init,
1084 : .unprivileged_init = unprivileged_init,
1085 : .run = stem_run,
1086 : };
1087 : #endif
|