Line data Source code
1 : #include "fd_gui.h"
2 : #include "fd_gui_printf.h"
3 : #include "fd_gui_metrics.h"
4 :
5 : #include "../metrics/fd_metrics.h"
6 : #include "../../discof/gossip/fd_gossip_tile.h"
7 : #include "../../discoh/plugin/fd_plugin.h"
8 : #include "../bundle/fd_bundle_tile.h"
9 :
10 : #include "../../ballet/base58/fd_base58.h"
11 : #include "../../ballet/json/cJSON.h"
12 : #include "../../disco/genesis/fd_genesis_cluster.h"
13 : #include "../../disco/pack/fd_pack.h"
14 : #include "../../disco/pack/fd_pack_cost.h"
15 :
16 : #include <stdio.h>
17 :
18 : FD_FN_CONST ulong
19 0 : fd_gui_align( void ) {
20 0 : return 128UL;
21 0 : }
22 :
23 : ulong
24 0 : fd_gui_footprint( ulong tile_cnt ) {
25 0 : FD_TEST( tile_cnt && tile_cnt <=FD_TOPO_MAX_TILES );
26 :
27 0 : ulong l = FD_LAYOUT_INIT;
28 0 : l = FD_LAYOUT_APPEND( l, fd_gui_align(), sizeof(fd_gui_t) );
29 0 : l = FD_LAYOUT_APPEND( l, alignof(fd_gui_tile_timers_t), FD_GUI_TILE_TIMER_SNAP_CNT * tile_cnt * sizeof(fd_gui_tile_timers_t) );
30 0 : l = FD_LAYOUT_APPEND( l, alignof(fd_gui_tile_timers_t), FD_GUI_LEADER_CNT * FD_GUI_TILE_TIMER_LEADER_DOWNSAMPLE_CNT * tile_cnt * sizeof(fd_gui_tile_timers_t) );
31 0 : l = FD_LAYOUT_APPEND( l, fd_gui_rate_deque_align(), fd_gui_rate_deque_footprint() ); /* ingress_maxq */
32 0 : l = FD_LAYOUT_APPEND( l, fd_gui_rate_deque_align(), fd_gui_rate_deque_footprint() ); /* egress_maxq */
33 0 : return FD_LAYOUT_FINI( l, fd_gui_align() );
34 0 : }
35 :
36 : void *
37 : fd_gui_new( void * shmem,
38 : fd_http_server_t * http,
39 : char const * version,
40 : char const * cluster,
41 : uchar const * identity_key,
42 : int has_vote_key,
43 : uchar const * vote_key,
44 : int is_full_client,
45 : int snapshots_enabled,
46 : int is_voting,
47 : int schedule_strategy,
48 : char const * wfs_expected_bank_hash_cstr,
49 : ushort expected_shred_version,
50 : fd_topo_t const * topo,
51 0 : long now ) {
52 :
53 0 : if( FD_UNLIKELY( !shmem ) ) {
54 0 : FD_LOG_WARNING(( "NULL shmem" ));
55 0 : return NULL;
56 0 : }
57 :
58 0 : if( FD_UNLIKELY( !fd_ulong_is_aligned( (ulong)shmem, fd_gui_align() ) ) ) {
59 0 : FD_LOG_WARNING(( "misaligned shmem" ));
60 0 : return NULL;
61 0 : }
62 :
63 0 : if( FD_UNLIKELY( topo->tile_cnt>FD_TOPO_MAX_TILES ) ) {
64 0 : FD_LOG_WARNING(( "too many tiles" ));
65 0 : return NULL;
66 0 : }
67 :
68 0 : ulong tile_cnt = topo->tile_cnt;
69 :
70 0 : FD_SCRATCH_ALLOC_INIT( l, shmem );
71 0 : fd_gui_t * gui = FD_SCRATCH_ALLOC_APPEND( l, fd_gui_align(), sizeof(fd_gui_t) );
72 0 : fd_gui_tile_timers_t * tile_timers_snap_mem = FD_SCRATCH_ALLOC_APPEND( l, alignof(fd_gui_tile_timers_t), FD_GUI_TILE_TIMER_SNAP_CNT * tile_cnt * sizeof(fd_gui_tile_timers_t) );
73 0 : fd_gui_tile_timers_t * leader_tt_mem = FD_SCRATCH_ALLOC_APPEND( l, alignof(fd_gui_tile_timers_t), FD_GUI_LEADER_CNT * FD_GUI_TILE_TIMER_LEADER_DOWNSAMPLE_CNT * tile_cnt * sizeof(fd_gui_tile_timers_t) );
74 0 : void * ingress_maxq_mem = FD_SCRATCH_ALLOC_APPEND( l, fd_gui_rate_deque_align(), fd_gui_rate_deque_footprint() );
75 0 : void * egress_maxq_mem = FD_SCRATCH_ALLOC_APPEND( l, fd_gui_rate_deque_align(), fd_gui_rate_deque_footprint() );
76 :
77 0 : gui->http = http;
78 0 : gui->topo = topo;
79 0 : gui->tile_cnt = tile_cnt;
80 :
81 0 : gui->summary.tile_timers_snap = tile_timers_snap_mem;
82 0 : gui->summary.ingress_maxq = fd_gui_rate_deque_join( fd_gui_rate_deque_new( ingress_maxq_mem ) );
83 0 : gui->summary.egress_maxq = fd_gui_rate_deque_join( fd_gui_rate_deque_new( egress_maxq_mem ) );
84 :
85 0 : gui->summary.network_stats_has_prev = 0;
86 0 : gui->summary.net_rate_ema_ready = 0;
87 0 : gui->summary.net_rate_prev_ts = 0L;
88 0 : fd_memset( gui->summary.ingress_ema, 0, sizeof(gui->summary.ingress_ema) );
89 0 : fd_memset( gui->summary.egress_ema, 0, sizeof(gui->summary.egress_ema) );
90 :
91 0 : for( ulong i=0UL; i<FD_GUI_LEADER_CNT; i++ ) gui->leader_slots[ i ]->tile_timers = leader_tt_mem + i * FD_GUI_TILE_TIMER_LEADER_DOWNSAMPLE_CNT * tile_cnt;
92 :
93 0 : gui->leader_slot = ULONG_MAX;
94 0 : gui->summary.schedule_strategy = schedule_strategy;
95 :
96 :
97 0 : gui->next_sample_400millis = now;
98 0 : gui->next_sample_100millis = now;
99 0 : gui->next_sample_50millis = now;
100 0 : gui->next_sample_25millis = now;
101 0 : gui->next_sample_10millis = now;
102 :
103 0 : memcpy( gui->summary.identity_key->uc, identity_key, 32UL );
104 0 : fd_base58_encode_32( identity_key, NULL, gui->summary.identity_key_base58 );
105 0 : gui->summary.identity_key_base58[ FD_BASE58_ENCODED_32_SZ-1UL ] = '\0';
106 :
107 0 : if( FD_LIKELY( has_vote_key ) ) {
108 0 : gui->summary.has_vote_key = 1;
109 0 : memcpy( gui->summary.vote_key->uc, vote_key, 32UL );
110 0 : fd_base58_encode_32( vote_key, NULL, gui->summary.vote_key_base58 );
111 0 : gui->summary.vote_key_base58[ FD_BASE58_ENCODED_32_SZ-1UL ] = '\0';
112 0 : } else {
113 0 : gui->summary.has_vote_key = 0;
114 0 : memset( gui->summary.vote_key_base58, 0, sizeof(gui->summary.vote_key_base58) );
115 0 : }
116 :
117 0 : gui->summary.is_full_client = is_full_client;
118 0 : gui->summary.version = version;
119 0 : gui->summary.cluster = cluster;
120 0 : gui->summary.startup_time_nanos = gui->next_sample_400millis;
121 0 : gui->summary.expected_shred_version = expected_shred_version;
122 0 : gui->summary.wfs_enabled = 0;
123 0 : gui->summary.wfs_bank_hash[ 0UL ] = '\0';
124 :
125 0 : if( FD_UNLIKELY( is_full_client ) ) {
126 0 : fd_cstr_ncpy( gui->summary.wfs_bank_hash, wfs_expected_bank_hash_cstr, sizeof(gui->summary.wfs_bank_hash) );
127 0 : gui->summary.wfs_enabled = !!strcmp( wfs_expected_bank_hash_cstr, "" );
128 :
129 0 : if( FD_UNLIKELY( snapshots_enabled ) ) {
130 0 : gui->summary.boot_progress.phase = FD_GUI_BOOT_PROGRESS_TYPE_JOINING_GOSSIP;
131 0 : gui->summary.boot_progress.joining_gossip_time_nanos = gui->next_sample_400millis;
132 0 : memset( gui->summary.boot_progress.loading_snapshot, 0, sizeof(gui->summary.boot_progress.loading_snapshot) );
133 0 : for( ulong i=0UL; i<FD_GUI_BOOT_PROGRESS_SNAPSHOT_CNT; i++ ) {
134 0 : gui->summary.boot_progress.loading_snapshot[ i ].reset_cnt = ULONG_MAX; /* ensures other fields are reset initially */
135 0 : gui->summary.boot_progress.loading_snapshot[ i ].slot = ULONG_MAX;
136 0 : }
137 0 : gui->summary.boot_progress.catching_up_time_nanos = 0L;
138 0 : gui->summary.boot_progress.catching_up_first_replay_slot = ULONG_MAX;
139 0 : gui->summary.boot_progress.wfs_total_stake = 0UL;
140 0 : gui->summary.boot_progress.wfs_connected_stake = 0UL;
141 0 : gui->summary.boot_progress.wfs_total_peers = 0UL;
142 0 : gui->summary.boot_progress.wfs_connected_peers = 0UL;
143 0 : gui->summary.boot_progress.wfs_attempt = 0UL;
144 0 : } else {
145 0 : fd_memset( &gui->summary.boot_progress, 0, sizeof(gui->summary.boot_progress) );
146 0 : gui->summary.boot_progress.phase = FD_GUI_BOOT_PROGRESS_TYPE_RUNNING;
147 0 : }
148 0 : } else {
149 0 : gui->summary.startup_progress.phase = FD_GUI_START_PROGRESS_TYPE_INITIALIZING;
150 0 : gui->summary.startup_progress.startup_got_full_snapshot = 0;
151 0 : gui->summary.startup_progress.startup_full_snapshot_slot = 0;
152 0 : gui->summary.startup_progress.startup_incremental_snapshot_slot = 0;
153 0 : gui->summary.startup_progress.startup_waiting_for_supermajority_slot = ULONG_MAX;
154 0 : gui->summary.startup_progress.startup_ledger_max_slot = ULONG_MAX;
155 0 : }
156 :
157 0 : gui->summary.identity_account_balance = 0UL;
158 0 : gui->summary.vote_account_balance = 0UL;
159 0 : gui->summary.estimated_slot_duration_nanos = 0UL;
160 :
161 0 : gui->summary.vote_distance = 0UL;
162 0 : gui->summary.vote_state = is_voting ? FD_GUI_VOTE_STATE_VOTING : FD_GUI_VOTE_STATE_NON_VOTING;
163 :
164 0 : gui->summary.sock_tile_cnt = fd_topo_tile_name_cnt( gui->topo, "sock" );
165 0 : gui->summary.net_tile_cnt = fd_topo_tile_name_cnt( gui->topo, "net" );
166 0 : gui->summary.quic_tile_cnt = fd_topo_tile_name_cnt( gui->topo, "quic" );
167 0 : gui->summary.verify_tile_cnt = fd_topo_tile_name_cnt( gui->topo, "verify" );
168 0 : gui->summary.resolh_tile_cnt = fd_topo_tile_name_cnt( gui->topo, "resolh" );
169 0 : gui->summary.resolv_tile_cnt = fd_topo_tile_name_cnt( gui->topo, "resolv" );
170 0 : gui->summary.bank_tile_cnt = fd_topo_tile_name_cnt( gui->topo, "bank" );
171 0 : gui->summary.execle_tile_cnt = fd_topo_tile_name_cnt( gui->topo, "execle" );
172 0 : gui->summary.execrp_tile_cnt = fd_topo_tile_name_cnt( gui->topo, "execrp" );
173 0 : gui->summary.shred_tile_cnt = fd_topo_tile_name_cnt( gui->topo, "shred" );
174 :
175 0 : gui->summary.slot_rooted = ULONG_MAX;
176 0 : gui->summary.slot_optimistically_confirmed = ULONG_MAX;
177 0 : gui->summary.slot_completed = ULONG_MAX;
178 0 : gui->summary.slot_estimated = ULONG_MAX;
179 0 : gui->summary.slot_caught_up = ULONG_MAX;
180 0 : gui->summary.slot_repair = ULONG_MAX;
181 0 : gui->summary.slot_turbine = ULONG_MAX;
182 0 : gui->summary.slot_reset = ULONG_MAX;
183 0 : gui->summary.slot_storage = ULONG_MAX;
184 0 : gui->summary.active_fork_cnt = 1UL;
185 :
186 0 : for( ulong i=0UL; i < (FD_GUI_REPAIR_SLOT_HISTORY_SZ+1UL); i++ ) gui->summary.slots_max_repair[ i ].slot = ULONG_MAX;
187 0 : for( ulong i=0UL; i < (FD_GUI_TURBINE_SLOT_HISTORY_SZ+1UL); i++ ) gui->summary.slots_max_turbine[ i ].slot = ULONG_MAX;
188 :
189 0 : for( ulong i=0UL; i < FD_GUI_TURBINE_RECV_TIMESTAMPS; i++ ) gui->turbine_slots[ i ].slot = ULONG_MAX;
190 :
191 0 : gui->summary.estimated_tps_history_idx = 0UL;
192 0 : memset( gui->summary.estimated_tps_history, 0, sizeof(gui->summary.estimated_tps_history) );
193 :
194 0 : memset( gui->summary.txn_waterfall_reference, 0, sizeof(gui->summary.txn_waterfall_reference) );
195 0 : memset( gui->summary.txn_waterfall_current, 0, sizeof(gui->summary.txn_waterfall_current) );
196 :
197 0 : memset( gui->summary.tile_stats_reference, 0, sizeof(gui->summary.tile_stats_reference) );
198 0 : memset( gui->summary.tile_stats_current, 0, sizeof(gui->summary.tile_stats_current) );
199 :
200 0 : gui->summary.progcache_history_idx = 0UL;
201 0 : memset( gui->summary.progcache_hits_history, 0, sizeof(gui->summary.progcache_hits_history) );
202 0 : memset( gui->summary.progcache_lookups_history, 0, sizeof(gui->summary.progcache_lookups_history) );
203 0 : gui->summary.progcache_hits_1min = 0UL;
204 0 : gui->summary.progcache_lookups_1min = 0UL;
205 :
206 0 : memset( gui->summary.tile_timers_snap, 0, tile_cnt * sizeof(fd_gui_tile_timers_t) );
207 0 : memset( gui->summary.tile_timers_snap + tile_cnt, 0, tile_cnt * sizeof(fd_gui_tile_timers_t) );
208 0 : gui->summary.tile_timers_snap_idx = 2UL;
209 :
210 0 : memset( gui->summary.scheduler_counts_snap[ 0 ], 0, sizeof(gui->summary.scheduler_counts_snap[ 0 ]) );
211 0 : memset( gui->summary.scheduler_counts_snap[ 1 ], 0, sizeof(gui->summary.scheduler_counts_snap[ 1 ]) );
212 0 : gui->summary.scheduler_counts_snap_idx = 2UL;
213 :
214 0 : for( ulong i=0UL; i<FD_GUI_SLOTS_CNT; i++ ) gui->slots[ i ]->slot = ULONG_MAX;
215 0 : for( ulong i=0UL; i<FD_GUI_LEADER_CNT; i++ ) gui->leader_slots[ i ]->slot = ULONG_MAX;
216 0 : gui->leader_slots_cnt = 0UL;
217 :
218 0 : gui->tower_cnt = 0UL;
219 :
220 0 : gui->block_engine.has_block_engine = 0;
221 :
222 0 : gui->epoch.has_epoch[ 0 ] = 0;
223 0 : gui->epoch.has_epoch[ 1 ] = 0;
224 :
225 0 : gui->gossip.peer_cnt = 0UL;
226 0 : gui->vote_account.vote_account_cnt = 0UL;
227 0 : gui->validator_info.info_cnt = 0UL;
228 :
229 0 : gui->pack_txn_idx = 0UL;
230 :
231 0 : gui->shreds.leader_shred_cnt = 0UL;
232 0 : gui->shreds.staged_next_broadcast = 0UL;
233 0 : gui->shreds.staged_head = 0UL;
234 0 : gui->shreds.staged_tail = 0UL;
235 0 : gui->shreds.history_tail = 0UL;
236 0 : gui->shreds.history_slot = ULONG_MAX;
237 0 : gui->summary.catch_up_repair_sz = 0UL;
238 0 : gui->summary.catch_up_turbine_sz = 0UL;
239 0 : gui->summary.late_votes_sz = 0UL;
240 :
241 0 : return gui;
242 0 : }
243 :
244 : fd_gui_t *
245 0 : fd_gui_join( void * shmem ) {
246 0 : return (fd_gui_t *)shmem;
247 0 : }
248 :
249 : void
250 : fd_gui_set_identity( fd_gui_t * gui,
251 0 : uchar const * identity_pubkey ) {
252 0 : memcpy( gui->summary.identity_key->uc, identity_pubkey, 32UL );
253 0 : fd_base58_encode_32( identity_pubkey, NULL, gui->summary.identity_key_base58 );
254 0 : gui->summary.identity_key_base58[ FD_BASE58_ENCODED_32_SZ-1UL ] = '\0';
255 :
256 0 : fd_gui_printf_identity_key( gui );
257 0 : fd_http_server_ws_broadcast( gui->http );
258 0 : }
259 :
260 : void
261 : fd_gui_ws_open( fd_gui_t * gui,
262 : ulong ws_conn_id,
263 0 : long now ) {
264 0 : void (* printers[] )( fd_gui_t * gui ) = {
265 0 : gui->summary.is_full_client ? fd_gui_printf_boot_progress : fd_gui_printf_startup_progress,
266 0 : fd_gui_printf_version,
267 0 : fd_gui_printf_cluster,
268 0 : fd_gui_printf_commit_hash,
269 0 : fd_gui_printf_identity_key,
270 0 : fd_gui_printf_vote_key,
271 0 : fd_gui_printf_startup_time_nanos,
272 0 : fd_gui_printf_vote_state,
273 0 : fd_gui_printf_vote_distance,
274 0 : fd_gui_printf_turbine_slot,
275 0 : fd_gui_printf_repair_slot,
276 0 : fd_gui_printf_slot_caught_up,
277 0 : fd_gui_printf_tps_history,
278 0 : fd_gui_printf_tiles,
279 0 : fd_gui_printf_schedule_strategy,
280 0 : fd_gui_printf_identity_balance,
281 0 : fd_gui_printf_vote_balance,
282 0 : fd_gui_printf_estimated_slot_duration_nanos,
283 0 : fd_gui_printf_root_slot,
284 0 : fd_gui_printf_storage_slot,
285 0 : fd_gui_printf_reset_slot,
286 0 : fd_gui_printf_active_fork_cnt,
287 0 : fd_gui_printf_optimistically_confirmed_slot,
288 0 : fd_gui_printf_completed_slot,
289 0 : fd_gui_printf_estimated_slot,
290 0 : fd_gui_printf_live_tile_timers,
291 0 : fd_gui_printf_live_tile_metrics,
292 0 : fd_gui_printf_catch_up_history,
293 0 : fd_gui_printf_vote_latency_history,
294 0 : fd_gui_printf_late_votes_history,
295 0 : fd_gui_printf_health
296 0 : };
297 :
298 0 : ulong printers_len = sizeof(printers) / sizeof(printers[0]);
299 0 : for( ulong i=0UL; i<printers_len; i++ ) {
300 0 : printers[ i ]( gui );
301 0 : FD_TEST( !fd_http_server_ws_send( gui->http, ws_conn_id ) );
302 0 : }
303 :
304 0 : if( FD_LIKELY( gui->summary.is_full_client ) ) {
305 0 : fd_gui_printf_live_program_cache( gui );
306 0 : FD_TEST( !fd_http_server_ws_send( gui->http, ws_conn_id ) );
307 0 : }
308 :
309 0 : if( FD_LIKELY( gui->block_engine.has_block_engine ) ) {
310 0 : fd_gui_printf_block_engine( gui );
311 0 : FD_TEST( !fd_http_server_ws_send( gui->http, ws_conn_id ) );
312 0 : }
313 :
314 0 : for( ulong i=0UL; i<2UL; i++ ) {
315 0 : if( FD_LIKELY( gui->epoch.has_epoch[ i ] ) ) {
316 0 : fd_gui_printf_skip_rate( gui, i );
317 0 : FD_TEST( !fd_http_server_ws_send( gui->http, ws_conn_id ) );
318 0 : fd_gui_printf_epoch( gui, i );
319 0 : FD_TEST( !fd_http_server_ws_send( gui->http, ws_conn_id ) );
320 0 : }
321 0 : }
322 :
323 0 : ulong epoch_idx = fd_gui_current_epoch_idx( gui );
324 0 : if( FD_LIKELY( epoch_idx!=ULONG_MAX ) ) {
325 0 : fd_gui_printf_skipped_history( gui, epoch_idx );
326 0 : FD_TEST( !fd_http_server_ws_send( gui->http, ws_conn_id ) );
327 0 : fd_gui_printf_skipped_history_cluster( gui, epoch_idx );
328 0 : FD_TEST( !fd_http_server_ws_send( gui->http, ws_conn_id ) );
329 0 : }
330 :
331 : /* Print peers last because it's the largest message and would
332 : block other information. */
333 0 : fd_gui_printf_peers_all( gui );
334 0 : FD_TEST( !fd_http_server_ws_send( gui->http, ws_conn_id ) );
335 :
336 : /* rebroadcast 10s of historical shred data */
337 0 : if( FD_LIKELY( gui->shreds.staged_next_broadcast!=ULONG_MAX ) ) {
338 0 : fd_gui_printf_shred_rebroadcast( gui, now-(long)(10*1e9) );
339 0 : FD_TEST( !fd_http_server_ws_send( gui->http, ws_conn_id ) );
340 0 : }
341 0 : }
342 :
343 : static void
344 0 : fd_gui_tile_timers_snap( fd_gui_t * gui ) {
345 0 : fd_gui_tile_timers_t * cur = gui->summary.tile_timers_snap + gui->summary.tile_timers_snap_idx * gui->tile_cnt;
346 0 : gui->summary.tile_timers_snap_idx = (gui->summary.tile_timers_snap_idx+1UL)%FD_GUI_TILE_TIMER_SNAP_CNT;
347 0 : for( ulong i=0UL; i<gui->topo->tile_cnt; i++ ) {
348 0 : fd_topo_tile_t const * tile = &gui->topo->tiles[ i ];
349 0 : if ( FD_UNLIKELY( !tile->metrics ) ) {
350 : /* bench tiles might not have been booted initially.
351 : This check shouldn't be necessary if all tiles barrier after boot. */
352 : // TODO(FIXME) this probably isn't the right fix but it makes fddev bench work for now
353 0 : return;
354 0 : }
355 0 : volatile ulong const * tile_metrics = fd_metrics_tile( tile->metrics );
356 :
357 0 : cur[ i ].timers[ FD_METRICS_ENUM_TILE_REGIME_V_CAUGHT_UP_HOUSEKEEPING_IDX ] = tile_metrics[ MIDX( COUNTER, TILE, REGIME_DURATION_NANOS_CAUGHT_UP_HOUSEKEEPING ) ];
358 0 : cur[ i ].timers[ FD_METRICS_ENUM_TILE_REGIME_V_PROCESSING_HOUSEKEEPING_IDX ] = tile_metrics[ MIDX( COUNTER, TILE, REGIME_DURATION_NANOS_PROCESSING_HOUSEKEEPING ) ];
359 0 : cur[ i ].timers[ FD_METRICS_ENUM_TILE_REGIME_V_BACKPRESSURE_HOUSEKEEPING_IDX ] = tile_metrics[ MIDX( COUNTER, TILE, REGIME_DURATION_NANOS_BACKPRESSURE_HOUSEKEEPING ) ];
360 0 : cur[ i ].timers[ FD_METRICS_ENUM_TILE_REGIME_V_CAUGHT_UP_PREFRAG_IDX ] = tile_metrics[ MIDX( COUNTER, TILE, REGIME_DURATION_NANOS_CAUGHT_UP_PREFRAG ) ];
361 0 : cur[ i ].timers[ FD_METRICS_ENUM_TILE_REGIME_V_PROCESSING_PREFRAG_IDX ] = tile_metrics[ MIDX( COUNTER, TILE, REGIME_DURATION_NANOS_PROCESSING_PREFRAG ) ];
362 0 : cur[ i ].timers[ FD_METRICS_ENUM_TILE_REGIME_V_BACKPRESSURE_PREFRAG_IDX ] = tile_metrics[ MIDX( COUNTER, TILE, REGIME_DURATION_NANOS_BACKPRESSURE_PREFRAG ) ];
363 0 : cur[ i ].timers[ FD_METRICS_ENUM_TILE_REGIME_V_CAUGHT_UP_POSTFRAG_IDX ] = tile_metrics[ MIDX( COUNTER, TILE, REGIME_DURATION_NANOS_CAUGHT_UP_POSTFRAG ) ];
364 0 : cur[ i ].timers[ FD_METRICS_ENUM_TILE_REGIME_V_PROCESSING_POSTFRAG_IDX ] = tile_metrics[ MIDX( COUNTER, TILE, REGIME_DURATION_NANOS_PROCESSING_POSTFRAG ) ];
365 :
366 0 : cur[ i ].sched_timers[ FD_METRICS_ENUM_CPU_REGIME_V_WAIT_IDX ] = tile_metrics[ MIDX( COUNTER, TILE, CPU_DURATION_NANOS_WAIT ) ];
367 0 : cur[ i ].sched_timers[ FD_METRICS_ENUM_CPU_REGIME_V_USER_IDX ] = tile_metrics[ MIDX( COUNTER, TILE, CPU_DURATION_NANOS_USER ) ];
368 0 : cur[ i ].sched_timers[ FD_METRICS_ENUM_CPU_REGIME_V_SYSTEM_IDX ] = tile_metrics[ MIDX( COUNTER, TILE, CPU_DURATION_NANOS_SYSTEM ) ];
369 0 : cur[ i ].sched_timers[ FD_METRICS_ENUM_CPU_REGIME_V_IDLE_IDX ] = tile_metrics[ MIDX( COUNTER, TILE, CPU_DURATION_NANOS_IDLE ) ];
370 :
371 0 : cur[ i ].in_backp = (int)tile_metrics[ MIDX(GAUGE, TILE, IN_BACKPRESSURE) ];
372 0 : cur[ i ].status = (uchar)tile_metrics[ MIDX( GAUGE, TILE, STATUS ) ];
373 0 : cur[ i ].heartbeat = tile_metrics[ MIDX( GAUGE, TILE, HEARTBEAT ) ];
374 0 : cur[ i ].backp_cnt = tile_metrics[ MIDX( COUNTER, TILE, BACKPRESSURE_COUNT ) ];
375 0 : cur[ i ].nvcsw = tile_metrics[ MIDX( COUNTER, TILE, CONTEXT_SWITCH_VOLUNTARY_COUNT ) ];
376 0 : cur[ i ].nivcsw = tile_metrics[ MIDX( COUNTER, TILE, CONTEXT_SWITCH_INVOLUNTARY_COUNT ) ];
377 0 : cur[ i ].minflt = tile_metrics[ MIDX( COUNTER, TILE, PAGE_FAULT_MINOR_COUNT ) ];
378 0 : cur[ i ].majflt = tile_metrics[ MIDX( COUNTER, TILE, PAGE_FAULT_MAJOR_COUNT ) ];
379 0 : cur[ i ].last_cpu = (ushort)tile_metrics[ MIDX( GAUGE, TILE, LAST_CPU ) ];
380 0 : }
381 0 : }
382 :
383 : static void
384 0 : fd_gui_scheduler_counts_snap( fd_gui_t * gui, long now ) {
385 0 : ulong pack_tile_idx = fd_topo_find_tile( gui->topo, "pack", 0UL );
386 0 : if( FD_UNLIKELY( pack_tile_idx==ULONG_MAX ) ) return;
387 :
388 0 : fd_gui_scheduler_counts_t * cur = gui->summary.scheduler_counts_snap[ gui->summary.scheduler_counts_snap_idx ];
389 0 : gui->summary.scheduler_counts_snap_idx = (gui->summary.scheduler_counts_snap_idx+1UL)%FD_GUI_SCHEDULER_COUNT_SNAP_CNT;
390 :
391 0 : fd_topo_tile_t const * pack = &gui->topo->tiles[ fd_topo_find_tile( gui->topo, "pack", 0UL ) ];
392 0 : volatile ulong const * pack_metrics = fd_metrics_tile( pack->metrics );
393 :
394 0 : cur->sample_time_ns = now;
395 :
396 0 : cur->regular = pack_metrics[ MIDX( GAUGE, PACK, AVAILABLE_TRANSACTIONS_REGULAR ) ];
397 0 : cur->votes = pack_metrics[ MIDX( GAUGE, PACK, AVAILABLE_TRANSACTIONS_VOTES ) ];
398 0 : cur->conflicting = pack_metrics[ MIDX( GAUGE, PACK, AVAILABLE_TRANSACTIONS_CONFLICTING ) ];
399 0 : cur->bundles = pack_metrics[ MIDX( GAUGE, PACK, AVAILABLE_TRANSACTIONS_BUNDLES ) ];
400 0 : }
401 :
402 : static void
403 0 : fd_gui_estimated_tps_snap( fd_gui_t * gui ) {
404 0 : ulong vote_failed = 0UL;
405 0 : ulong vote_success = 0UL;
406 0 : ulong nonvote_success = 0UL;
407 0 : ulong nonvote_failed = 0UL;
408 :
409 0 : if( FD_LIKELY( gui->summary.slot_completed==ULONG_MAX ) ) return;
410 0 : for( ulong i=0UL; i<fd_ulong_min( gui->summary.slot_completed+1UL, FD_GUI_SLOTS_CNT ); i++ ) {
411 0 : ulong _slot = gui->summary.slot_completed-i;
412 0 : fd_gui_slot_t const * slot = fd_gui_get_slot_const( gui, _slot );
413 0 : if( FD_UNLIKELY( !slot ) ) break; /* Slot no longer exists, no TPS. */
414 0 : if( FD_UNLIKELY( slot->completed_time==LONG_MAX ) ) continue; /* Slot is on this fork but was never completed, must have been in root path on boot. */
415 0 : if( FD_UNLIKELY( slot->completed_time+FD_GUI_TPS_HISTORY_WINDOW_DURATION_SECONDS*1000L*1000L*1000L<gui->next_sample_400millis ) ) break; /* Slot too old. */
416 0 : if( FD_UNLIKELY( slot->skipped ) ) continue; /* Skipped slots don't count to TPS. */
417 0 : if( FD_UNLIKELY( slot->vote_failed==UINT_MAX ) ) continue; /* Slot transaction counts not yet populated. */
418 0 : vote_failed += slot->vote_failed;
419 0 : vote_success += slot->vote_success;
420 0 : nonvote_success += slot->nonvote_success;
421 0 : nonvote_failed += slot->nonvote_failed;
422 0 : }
423 :
424 0 : gui->summary.estimated_tps_history[ gui->summary.estimated_tps_history_idx ].vote_failed = vote_failed;
425 0 : gui->summary.estimated_tps_history[ gui->summary.estimated_tps_history_idx ].vote_success = vote_success;
426 0 : gui->summary.estimated_tps_history[ gui->summary.estimated_tps_history_idx ].nonvote_success = nonvote_success;
427 0 : gui->summary.estimated_tps_history[ gui->summary.estimated_tps_history_idx ].nonvote_failed = nonvote_failed;
428 0 : gui->summary.estimated_tps_history_idx = (gui->summary.estimated_tps_history_idx+1UL) % FD_GUI_TPS_HISTORY_SAMPLE_CNT;
429 0 : }
430 :
431 : static void
432 : fd_gui_network_stats_snap( fd_gui_t * gui,
433 0 : fd_gui_network_stats_t * cur ) {
434 0 : fd_topo_t const * topo = gui->topo;
435 0 : ulong gossvf_tile_cnt = fd_topo_tile_name_cnt( topo, "gossvf" );
436 0 : ulong gossip_tile_cnt = fd_topo_tile_name_cnt( topo, "gossip" );
437 0 : ulong shred_tile_cnt = fd_topo_tile_name_cnt( topo, "shred" );
438 0 : ulong net_tile_cnt = fd_topo_tile_name_cnt( topo, "net" );
439 0 : ulong quic_tile_cnt = fd_topo_tile_name_cnt( topo, "quic" );
440 :
441 0 : cur->in.gossip = fd_gui_metrics_gossip_total_ingress_bytes( topo, gossvf_tile_cnt );
442 0 : cur->out.gossip = fd_gui_metrics_gosip_total_egress_bytes( topo, gossip_tile_cnt );
443 0 : cur->in.turbine = fd_gui_metrics_sum_tiles_counter( topo, "shred", shred_tile_cnt, MIDX( COUNTER, SHRED, SHRED_TURBINE_RCV_BYTES ) );
444 :
445 0 : cur->out.turbine = 0UL;
446 0 : cur->out.repair = 0UL;
447 0 : cur->out.tpu = 0UL;
448 0 : for( ulong i=0UL; i<net_tile_cnt; i++ ) {
449 0 : ulong net_tile_idx = fd_topo_find_tile( topo, "net", i );
450 0 : if( FD_UNLIKELY( net_tile_idx==ULONG_MAX ) ) continue;
451 0 : fd_topo_tile_t const * net = &topo->tiles[ net_tile_idx ];
452 0 : for( ulong j=0UL; j<net->in_cnt; j++ ) {
453 0 : if( FD_UNLIKELY( !strcmp( topo->links[ net->in_link_id[ j ] ].name, "shred_net" ) ) ) {
454 0 : cur->out.turbine += fd_metrics_link_in( net->metrics, j )[ FD_METRICS_COUNTER_LINK_CONSUMED_SIZE_BYTES_OFF ];
455 0 : }
456 :
457 0 : if( FD_UNLIKELY( !strcmp( topo->links[ net->in_link_id[ j ] ].name, "repair_net" ) ) ) {
458 0 : cur->out.repair += fd_metrics_link_in( net->metrics, j )[ FD_METRICS_COUNTER_LINK_CONSUMED_SIZE_BYTES_OFF ];
459 0 : }
460 :
461 0 : if( FD_UNLIKELY( !strcmp( topo->links[ net->in_link_id[ j ] ].name, "send_net" ) ) ) {
462 0 : cur->out.tpu += fd_metrics_link_in( net->metrics, j )[ FD_METRICS_COUNTER_LINK_CONSUMED_SIZE_BYTES_OFF ];
463 0 : }
464 0 : }
465 0 : }
466 :
467 0 : cur->in.repair = fd_gui_metrics_sum_tiles_counter( topo, "shred", shred_tile_cnt, MIDX( COUNTER, SHRED, SHRED_REPAIR_RCV_BYTES ) );
468 0 : ulong repair_tile_idx = fd_topo_find_tile( topo, "repair", 0UL );
469 0 : if( FD_LIKELY( repair_tile_idx!=ULONG_MAX ) ) {
470 0 : fd_topo_tile_t const * repair = &topo->tiles[ repair_tile_idx ];
471 :
472 0 : for( ulong i=0UL; i<repair->in_cnt; i++ ) {
473 0 : if( FD_UNLIKELY( !strcmp( topo->links[ repair->in_link_id[ i ] ].name, "net_repair" ) ) ) {
474 0 : cur->in.repair += fd_metrics_link_in( repair->metrics, i )[ FD_METRICS_COUNTER_LINK_CONSUMED_SIZE_BYTES_OFF ];
475 0 : }
476 0 : }
477 0 : }
478 :
479 0 : cur->in.tpu = 0UL;
480 0 : for( ulong i=0UL; i<quic_tile_cnt; i++ ) {
481 0 : ulong quic_tile_idx = fd_topo_find_tile( topo, "quic", i );
482 0 : if( FD_UNLIKELY( quic_tile_idx==ULONG_MAX ) ) continue;
483 0 : fd_topo_tile_t const * quic = &topo->tiles[ quic_tile_idx ];
484 0 : volatile ulong * quic_metrics = fd_metrics_tile( quic->metrics );
485 0 : cur->in.tpu += quic_metrics[ MIDX( COUNTER, QUIC, RECEIVED_BYTES ) ];
486 0 : }
487 :
488 0 : ulong bundle_tile_idx = fd_topo_find_tile( topo, "bundle", 0UL );
489 0 : if( FD_LIKELY( bundle_tile_idx!=ULONG_MAX ) ) {
490 0 : fd_topo_tile_t const * bundle = &topo->tiles[ bundle_tile_idx ];
491 0 : volatile ulong * bundle_metrics = fd_metrics_tile( bundle->metrics );
492 0 : cur->in.tpu += bundle_metrics[ MIDX( COUNTER, BUNDLE, PROTO_RECEIVED_BYTES ) ];
493 0 : }
494 :
495 0 : ulong metric_tile_idx = fd_topo_find_tile( topo, "metric", 0UL );
496 0 : if( FD_LIKELY( metric_tile_idx!=ULONG_MAX ) ) {
497 0 : fd_topo_tile_t const * metric = &topo->tiles[ metric_tile_idx ];
498 0 : volatile ulong * metric_metrics = fd_metrics_tile( metric->metrics );
499 0 : cur->in.metric = metric_metrics[ MIDX( COUNTER, METRIC, BYTES_READ ) ];
500 0 : cur->out.metric = metric_metrics[ MIDX( COUNTER, METRIC, BYTES_WRITTEN ) ];
501 0 : } else {
502 0 : cur->in.metric = 0UL;
503 0 : cur->out.metric = 0UL;
504 0 : }
505 0 : }
506 :
507 : static void
508 : fd_gui_network_rate_max_update( fd_gui_t * gui,
509 0 : long now ) {
510 0 : fd_gui_network_stats_t * cur = gui->summary.network_stats_current;
511 0 : fd_gui_network_stats_t * prev = gui->summary.network_stats_prev;
512 :
513 : /* On the first sample we have no previous value. */
514 0 : if( FD_UNLIKELY( !gui->summary.network_stats_has_prev ) ) {
515 0 : *prev = *cur;
516 0 : gui->summary.network_stats_has_prev = 1;
517 0 : gui->summary.net_rate_prev_ts = now;
518 0 : return;
519 0 : }
520 :
521 0 : ulong d_in[ FD_GUI_NET_PROTO_CNT ];
522 0 : d_in[ 0 ] = fd_ulong_sat_sub( cur->in.turbine, prev->in.turbine );
523 0 : d_in[ 1 ] = fd_ulong_sat_sub( cur->in.gossip, prev->in.gossip );
524 0 : d_in[ 2 ] = fd_ulong_sat_sub( cur->in.tpu, prev->in.tpu );
525 0 : d_in[ 3 ] = fd_ulong_sat_sub( cur->in.repair, prev->in.repair );
526 0 : d_in[ 4 ] = fd_ulong_sat_sub( cur->in.metric, prev->in.metric );
527 :
528 0 : ulong d_out[ FD_GUI_NET_PROTO_CNT ];
529 0 : d_out[ 0 ] = fd_ulong_sat_sub( cur->out.turbine, prev->out.turbine );
530 0 : d_out[ 1 ] = fd_ulong_sat_sub( cur->out.gossip, prev->out.gossip );
531 0 : d_out[ 2 ] = fd_ulong_sat_sub( cur->out.tpu, prev->out.tpu );
532 0 : d_out[ 3 ] = fd_ulong_sat_sub( cur->out.repair, prev->out.repair );
533 0 : d_out[ 4 ] = fd_ulong_sat_sub( cur->out.metric, prev->out.metric );
534 :
535 : /* Compute per-protocol instantaneous bytes/sec rate and feed the EMA. */
536 0 : long dt_ns = now - gui->summary.net_rate_prev_ts;
537 0 : if( FD_LIKELY( dt_ns>0L ) ) {
538 0 : double dt_sec = (double)dt_ns / 1.0e9;
539 :
540 0 : for( ulong i=0UL; i<FD_GUI_NET_PROTO_CNT; i++ ) {
541 0 : double rate_in = (double)d_in[ i ] / dt_sec;
542 0 : double rate_out = (double)d_out[ i ] / dt_sec;
543 :
544 0 : if( FD_UNLIKELY( !gui->summary.net_rate_ema_ready ) ) {
545 0 : gui->summary.ingress_ema[ i ] = rate_in;
546 0 : gui->summary.egress_ema[ i ] = rate_out;
547 0 : } else {
548 0 : gui->summary.ingress_ema[ i ] = fd_gui_ema( gui->summary.net_rate_prev_ts, now, rate_in, gui->summary.ingress_ema[ i ], FD_GUI_NETWORK_EMA_HALF_LIFE_NS );
549 0 : gui->summary.egress_ema[ i ] = fd_gui_ema( gui->summary.net_rate_prev_ts, now, rate_out, gui->summary.egress_ema[ i ], FD_GUI_NETWORK_EMA_HALF_LIFE_NS );
550 0 : }
551 0 : }
552 0 : gui->summary.net_rate_ema_ready = 1;
553 0 : }
554 0 : gui->summary.net_rate_prev_ts = now;
555 :
556 : /* Track max total EMA in a rolling 5-minute window using monotonic
557 : deques.
558 :
559 : Invariant: deque entries are strictly decreasing in value from
560 : head to tail. The head is always the current window maximum.
561 :
562 : Insert: pop tail entries whose value <= new value (they can
563 : never become the maximum), then push the new entry.
564 : Expire: pop head entries older than 5 minutes. */
565 0 : if( FD_LIKELY( gui->summary.net_rate_ema_ready ) ) {
566 0 : double sum_in = 0.0;
567 0 : double sum_out = 0.0;
568 0 : for( ulong i=0UL; i<FD_GUI_NET_PROTO_CNT; i++ ) {
569 0 : sum_in += gui->summary.ingress_ema[ i ];
570 0 : sum_out += gui->summary.egress_ema[ i ];
571 0 : }
572 :
573 0 : while( !fd_gui_rate_deque_empty( gui->summary.ingress_maxq ) && fd_gui_rate_deque_peek_head_const( gui->summary.ingress_maxq )->ts_nanos<now-FD_GUI_NET_RATE_MAX_WINDOW_NS ) {
574 0 : fd_gui_rate_deque_pop_head( gui->summary.ingress_maxq );
575 0 : }
576 0 : while( !fd_gui_rate_deque_empty( gui->summary.ingress_maxq ) && fd_gui_rate_deque_peek_tail_const( gui->summary.ingress_maxq )->value<=sum_in ) {
577 0 : fd_gui_rate_deque_pop_tail( gui->summary.ingress_maxq );
578 0 : }
579 0 : if( FD_UNLIKELY( fd_gui_rate_deque_full( gui->summary.ingress_maxq ) ) ) {
580 0 : fd_gui_rate_deque_pop_tail( gui->summary.ingress_maxq );
581 0 : }
582 0 : fd_gui_rate_deque_push_tail( gui->summary.ingress_maxq, (fd_gui_rate_entry_t){ .ts_nanos=now, .value=sum_in } );
583 :
584 0 : while( !fd_gui_rate_deque_empty( gui->summary.egress_maxq ) && fd_gui_rate_deque_peek_head_const( gui->summary.egress_maxq )->ts_nanos<now-FD_GUI_NET_RATE_MAX_WINDOW_NS ) {
585 0 : fd_gui_rate_deque_pop_head( gui->summary.egress_maxq );
586 0 : }
587 0 : while( !fd_gui_rate_deque_empty( gui->summary.egress_maxq ) && fd_gui_rate_deque_peek_tail_const( gui->summary.egress_maxq )->value<=sum_out ) {
588 0 : fd_gui_rate_deque_pop_tail( gui->summary.egress_maxq );
589 0 : }
590 0 : if( FD_UNLIKELY( fd_gui_rate_deque_full( gui->summary.egress_maxq ) ) ) {
591 0 : fd_gui_rate_deque_pop_tail( gui->summary.egress_maxq );
592 0 : }
593 0 : fd_gui_rate_deque_push_tail( gui->summary.egress_maxq, (fd_gui_rate_entry_t){ .ts_nanos=now, .value=sum_out } );
594 0 : }
595 :
596 0 : *prev = *cur;
597 0 : }
598 :
599 : /* Snapshot all of the data from metrics to construct a view of the
600 : transaction waterfall.
601 :
602 : Tiles are sampled in reverse pipeline order: this helps prevent data
603 : discrepancies where a later tile has "seen" more transactions than an
604 : earlier tile, which shouldn't typically happen. */
605 :
606 : static void
607 : fd_gui_txn_waterfall_snap( fd_gui_t * gui,
608 0 : fd_gui_txn_waterfall_t * cur ) {
609 0 : memset( cur, 0, sizeof(fd_gui_txn_waterfall_t) );
610 0 : fd_topo_t const * topo = gui->topo;
611 :
612 0 : for( ulong i=0UL; i<gui->summary.bank_tile_cnt; i++ ) {
613 0 : fd_topo_tile_t const * bank = &topo->tiles[ fd_topo_find_tile( topo, "bank", i ) ];
614 :
615 0 : volatile ulong const * bank_metrics = fd_metrics_tile( bank->metrics );
616 0 : cur->out.block_success += bank_metrics[ MIDX( COUNTER, BANK, SUCCESSFUL_TRANSACTIONS ) ];
617 :
618 0 : cur->out.block_fail +=
619 0 : bank_metrics[ MIDX( COUNTER, BANK, EXECUTED_FAILED_TRANSACTIONS ) ]
620 0 : + bank_metrics[ MIDX( COUNTER, BANK, FEE_ONLY_TRANSACTIONS ) ];
621 :
622 0 : cur->out.bank_invalid +=
623 0 : bank_metrics[ MIDX( COUNTER, BANK, TRANSACTION_LOAD_ADDRESS_TABLES_ACCOUNT_UNINITIALIZED ) ]
624 0 : + bank_metrics[ MIDX( COUNTER, BANK, TRANSACTION_LOAD_ADDRESS_TABLES_ACCOUNT_NOT_FOUND ) ]
625 0 : + bank_metrics[ MIDX( COUNTER, BANK, TRANSACTION_LOAD_ADDRESS_TABLES_INVALID_ACCOUNT_OWNER ) ]
626 0 : + bank_metrics[ MIDX( COUNTER, BANK, TRANSACTION_LOAD_ADDRESS_TABLES_INVALID_ACCOUNT_DATA ) ]
627 0 : + bank_metrics[ MIDX( COUNTER, BANK, TRANSACTION_LOAD_ADDRESS_TABLES_INVALID_LOOKUP_INDEX ) ];
628 :
629 0 : cur->out.bank_invalid +=
630 0 : bank_metrics[ MIDX( COUNTER, BANK, PROCESSING_FAILED ) ];
631 0 : }
632 :
633 0 : for( ulong i=0UL; i<gui->summary.execle_tile_cnt; i++ ) {
634 0 : fd_topo_tile_t const * execle = &topo->tiles[ fd_topo_find_tile( topo, "execle", i ) ];
635 :
636 0 : volatile ulong const * execle_metrics = fd_metrics_tile( execle->metrics );
637 :
638 0 : cur->out.block_success += execle_metrics[ MIDX( COUNTER, EXECLE, TRANSACTION_LANDED_LANDED_SUCCESS ) ];
639 0 : cur->out.block_fail +=
640 0 : execle_metrics[ MIDX( COUNTER, EXECLE, TRANSACTION_LANDED_LANDED_FEES_ONLY ) ]
641 0 : + execle_metrics[ MIDX( COUNTER, EXECLE, TRANSACTION_LANDED_LANDED_FAILED ) ];
642 0 : cur->out.bank_invalid += execle_metrics[ MIDX( COUNTER, EXECLE, TRANSACTION_LANDED_UNLANDED ) ];
643 :
644 0 : cur->out.bank_nonce_already_advanced += execle_metrics[ MIDX( COUNTER, EXECLE, TRANSACTION_RESULT_NONCE_ALREADY_ADVANCED ) ];
645 0 : cur->out.bank_nonce_advance_failed += execle_metrics[ MIDX( COUNTER, EXECLE, TRANSACTION_RESULT_NONCE_ADVANCE_FAILED ) ];
646 0 : cur->out.bank_nonce_wrong_blockhash += execle_metrics[ MIDX( COUNTER, EXECLE, TRANSACTION_RESULT_NONCE_WRONG_BLOCKHASH ) ];
647 0 : }
648 :
649 0 : ulong pack_tile_idx = fd_topo_find_tile( topo, "pack", 0UL );
650 0 : if( pack_tile_idx!=ULONG_MAX ) {
651 0 : fd_topo_tile_t const * pack = &topo->tiles[ pack_tile_idx ];
652 0 : volatile ulong const * pack_metrics = fd_metrics_tile( pack->metrics );
653 :
654 0 : cur->out.pack_invalid_bundle =
655 0 : pack_metrics[ MIDX( COUNTER, PACK, TRANSACTION_DROPPED_PARTIAL_BUNDLE ) ]
656 0 : + pack_metrics[ MIDX( COUNTER, PACK, BUNDLE_CRANK_STATUS_INSERTION_FAILED ) ]
657 0 : + pack_metrics[ MIDX( COUNTER, PACK, BUNDLE_CRANK_STATUS_CREATION_FAILED ) ];
658 :
659 0 : cur->out.pack_invalid =
660 0 : pack_metrics[ MIDX( COUNTER, PACK, TRANSACTION_INSERTED_INSTR_ACCT_CNT ) ]
661 0 : + pack_metrics[ MIDX( COUNTER, PACK, TRANSACTION_INSERTED_NONCE_CONFLICT ) ]
662 0 : + pack_metrics[ MIDX( COUNTER, PACK, TRANSACTION_INSERTED_BUNDLE_BLACKLIST ) ]
663 0 : + pack_metrics[ MIDX( COUNTER, PACK, TRANSACTION_INSERTED_INVALID_NONCE ) ]
664 0 : + pack_metrics[ MIDX( COUNTER, PACK, TRANSACTION_INSERTED_WRITE_SYSVAR ) ]
665 0 : + pack_metrics[ MIDX( COUNTER, PACK, TRANSACTION_INSERTED_ESTIMATION_FAIL ) ]
666 0 : + pack_metrics[ MIDX( COUNTER, PACK, TRANSACTION_INSERTED_DUPLICATE_ACCOUNT ) ]
667 0 : + pack_metrics[ MIDX( COUNTER, PACK, TRANSACTION_INSERTED_TOO_MANY_ACCOUNTS ) ]
668 0 : + pack_metrics[ MIDX( COUNTER, PACK, TRANSACTION_INSERTED_TOO_LARGE ) ]
669 0 : + pack_metrics[ MIDX( COUNTER, PACK, TRANSACTION_INSERTED_ADDR_LUT ) ]
670 0 : + pack_metrics[ MIDX( COUNTER, PACK, TRANSACTION_INSERTED_UNAFFORDABLE ) ]
671 0 : + pack_metrics[ MIDX( COUNTER, PACK, TRANSACTION_INSERTED_DUPLICATE ) ]
672 0 : - pack_metrics[ MIDX( COUNTER, PACK, BUNDLE_CRANK_STATUS_INSERTION_FAILED ) ]; /* so we don't double count this, since its already accounted for in invalid_bundle */
673 :
674 0 : cur->out.pack_expired = pack_metrics[ MIDX( COUNTER, PACK, TRANSACTION_INSERTED_EXPIRED ) ] +
675 0 : pack_metrics[ MIDX( COUNTER, PACK, TRANSACTION_EXPIRED ) ] +
676 0 : pack_metrics[ MIDX( COUNTER, PACK, TRANSACTION_DELETED ) ] +
677 0 : pack_metrics[ MIDX( COUNTER, PACK, TRANSACTION_INSERTED_NONCE_PRIORITY ) ];
678 :
679 0 : cur->out.pack_already_executed = pack_metrics[ MIDX( COUNTER, PACK, TRANSACTION_ALREADY_EXECUTED ) ];
680 :
681 0 : cur->out.pack_leader_slow = pack_metrics[ MIDX( COUNTER, PACK, TRANSACTION_INSERTED_PRIORITY ) ];
682 :
683 0 : cur->out.pack_wait_full =
684 0 : pack_metrics[ MIDX( COUNTER, PACK, TRANSACTION_DROPPED_FROM_EXTRA ) ];
685 :
686 0 : cur->out.pack_retained = pack_metrics[ MIDX( GAUGE, PACK, AVAILABLE_TRANSACTIONS ) ];
687 :
688 0 : ulong inserted_to_extra = pack_metrics[ MIDX( COUNTER, PACK, TRANSACTION_INSERTED_TO_EXTRA ) ];
689 0 : ulong inserted_from_extra = pack_metrics[ MIDX( COUNTER, PACK, TRANSACTION_INSERTED_FROM_EXTRA ) ]
690 0 : + pack_metrics[ MIDX( COUNTER, PACK, TRANSACTION_DROPPED_FROM_EXTRA ) ];
691 0 : cur->out.pack_retained += fd_ulong_if( inserted_to_extra>=inserted_from_extra, inserted_to_extra-inserted_from_extra, 0UL );
692 :
693 0 : cur->in.pack_cranked =
694 0 : pack_metrics[ MIDX( COUNTER, PACK, BUNDLE_CRANK_STATUS_INSERTED ) ]
695 0 : + pack_metrics[ MIDX( COUNTER, PACK, BUNDLE_CRANK_STATUS_INSERTION_FAILED ) ]
696 0 : + pack_metrics[ MIDX( COUNTER, PACK, BUNDLE_CRANK_STATUS_CREATION_FAILED ) ];
697 0 : }
698 :
699 0 : for( ulong i=0UL; i<gui->summary.resolh_tile_cnt; i++ ) {
700 0 : fd_topo_tile_t const * resolv = &topo->tiles[ fd_topo_find_tile( topo, "resolh", i ) ];
701 0 : volatile ulong const * resolv_metrics = fd_metrics_tile( resolv->metrics );
702 :
703 0 : cur->out.resolv_no_ledger += resolv_metrics[ MIDX( COUNTER, RESOLH, NO_BANK_DROP ) ];
704 0 : cur->out.resolv_expired += resolv_metrics[ MIDX( COUNTER, RESOLH, BLOCKHASH_EXPIRED ) ]
705 0 : + resolv_metrics[ MIDX( COUNTER, RESOLH, TRANSACTION_BUNDLE_PEER_FAILURE ) ];
706 0 : cur->out.resolv_lut_failed += resolv_metrics[ MIDX( COUNTER, RESOLH, LUT_RESOLVED_ACCOUNT_NOT_FOUND ) ]
707 0 : + resolv_metrics[ MIDX( COUNTER, RESOLH, LUT_RESOLVED_INVALID_ACCOUNT_OWNER ) ]
708 0 : + resolv_metrics[ MIDX( COUNTER, RESOLH, LUT_RESOLVED_INVALID_ACCOUNT_DATA ) ]
709 0 : + resolv_metrics[ MIDX( COUNTER, RESOLH, LUT_RESOLVED_ACCOUNT_UNINITIALIZED ) ]
710 0 : + resolv_metrics[ MIDX( COUNTER, RESOLH, LUT_RESOLVED_INVALID_LOOKUP_INDEX ) ];
711 0 : cur->out.resolv_ancient += resolv_metrics[ MIDX( COUNTER, RESOLH, STASH_OPERATION_OVERRUN ) ];
712 :
713 0 : ulong inserted_to_resolv = resolv_metrics[ MIDX( COUNTER, RESOLH, STASH_OPERATION_INSERTED ) ];
714 0 : ulong removed_from_resolv = resolv_metrics[ MIDX( COUNTER, RESOLH, STASH_OPERATION_OVERRUN ) ]
715 0 : + resolv_metrics[ MIDX( COUNTER, RESOLH, STASH_OPERATION_PUBLISHED ) ]
716 0 : + resolv_metrics[ MIDX( COUNTER, RESOLH, STASH_OPERATION_REMOVED ) ];
717 0 : cur->out.resolv_retained += fd_ulong_if( inserted_to_resolv>=removed_from_resolv, inserted_to_resolv-removed_from_resolv, 0UL );
718 0 : }
719 :
720 0 : for( ulong i=0UL; i<gui->summary.resolv_tile_cnt; i++ ) {
721 0 : fd_topo_tile_t const * resolv = &topo->tiles[ fd_topo_find_tile( topo, "resolv", i ) ];
722 0 : volatile ulong const * resolv_metrics = fd_metrics_tile( resolv->metrics );
723 :
724 0 : cur->out.resolv_no_ledger += resolv_metrics[ MIDX( COUNTER, RESOLV, NO_BANK_DROP ) ];
725 0 : cur->out.resolv_expired += resolv_metrics[ MIDX( COUNTER, RESOLV, BLOCKHASH_EXPIRED ) ]
726 0 : + resolv_metrics[ MIDX( COUNTER, RESOLV, TRANSACTION_BUNDLE_PEER_FAILURE ) ];
727 0 : cur->out.resolv_lut_failed += resolv_metrics[ MIDX( COUNTER, RESOLV, LUT_RESOLVED_ACCOUNT_NOT_FOUND ) ]
728 0 : + resolv_metrics[ MIDX( COUNTER, RESOLV, LUT_RESOLVED_INVALID_ACCOUNT_OWNER ) ]
729 0 : + resolv_metrics[ MIDX( COUNTER, RESOLV, LUT_RESOLVED_INVALID_ACCOUNT_DATA ) ]
730 0 : + resolv_metrics[ MIDX( COUNTER, RESOLV, LUT_RESOLVED_ACCOUNT_UNINITIALIZED ) ]
731 0 : + resolv_metrics[ MIDX( COUNTER, RESOLV, LUT_RESOLVED_INVALID_LOOKUP_INDEX ) ];
732 0 : cur->out.resolv_ancient += resolv_metrics[ MIDX( COUNTER, RESOLV, STASH_OPERATION_OVERRUN ) ];
733 :
734 0 : ulong inserted_to_resolv = resolv_metrics[ MIDX( COUNTER, RESOLV, STASH_OPERATION_INSERTED ) ];
735 0 : ulong removed_from_resolv = resolv_metrics[ MIDX( COUNTER, RESOLV, STASH_OPERATION_OVERRUN ) ]
736 0 : + resolv_metrics[ MIDX( COUNTER, RESOLV, STASH_OPERATION_PUBLISHED ) ]
737 0 : + resolv_metrics[ MIDX( COUNTER, RESOLV, STASH_OPERATION_REMOVED ) ];
738 0 : cur->out.resolv_retained += fd_ulong_if( inserted_to_resolv>=removed_from_resolv, inserted_to_resolv-removed_from_resolv, 0UL );
739 0 : }
740 :
741 0 : ulong dedup_tile_idx = fd_topo_find_tile( topo, "dedup", 0UL );
742 0 : if( FD_UNLIKELY( dedup_tile_idx!=ULONG_MAX ) ) {
743 0 : fd_topo_tile_t const * dedup = &topo->tiles[ dedup_tile_idx ];
744 0 : volatile ulong const * dedup_metrics = fd_metrics_tile( dedup->metrics );
745 :
746 0 : cur->out.dedup_duplicate = dedup_metrics[ MIDX( COUNTER, DEDUP, TRANSACTION_RESULT_DEDUP_FAILURE ) ]
747 0 : + dedup_metrics[ MIDX( COUNTER, DEDUP, TRANSACTION_RESULT_BUNDLE_PEER_FAILURE ) ];
748 0 : }
749 :
750 0 : for( ulong i=0UL; i<gui->summary.verify_tile_cnt; i++ ) {
751 0 : fd_topo_tile_t const * verify = &topo->tiles[ fd_topo_find_tile( topo, "verify", i ) ];
752 0 : volatile ulong const * verify_metrics = fd_metrics_tile( verify->metrics );
753 :
754 0 : for( ulong j=0UL; j<gui->summary.quic_tile_cnt; j++ ) {
755 : /* TODO: Not precise... even if 1 frag gets skipped, it could have been for this verify tile. */
756 0 : cur->out.verify_overrun += fd_metrics_link_in( verify->metrics, j )[ FD_METRICS_COUNTER_LINK_OVERRUN_POLLING_FRAG_COUNT_OFF ] / gui->summary.verify_tile_cnt;
757 0 : cur->out.verify_overrun += fd_metrics_link_in( verify->metrics, j )[ FD_METRICS_COUNTER_LINK_OVERRUN_READING_FRAG_COUNT_OFF ];
758 0 : }
759 :
760 0 : cur->out.verify_failed += verify_metrics[ MIDX( COUNTER, VERIFY, TRANSACTION_RESULT_VERIFY_FAILURE ) ] +
761 0 : verify_metrics[ MIDX( COUNTER, VERIFY, TRANSACTION_RESULT_BUNDLE_PEER_FAILURE ) ];
762 0 : cur->out.verify_parse += verify_metrics[ MIDX( COUNTER, VERIFY, TRANSACTION_RESULT_PARSE_FAILURE ) ];
763 0 : cur->out.verify_duplicate += verify_metrics[ MIDX( COUNTER, VERIFY, TRANSACTION_RESULT_DEDUP_FAILURE ) ];
764 0 : }
765 :
766 0 : for( ulong i=0UL; i<gui->summary.quic_tile_cnt; i++ ) {
767 0 : fd_topo_tile_t const * quic = &topo->tiles[ fd_topo_find_tile( topo, "quic", i ) ];
768 0 : volatile ulong * quic_metrics = fd_metrics_tile( quic->metrics );
769 :
770 0 : cur->out.tpu_udp_invalid += quic_metrics[ MIDX( COUNTER, QUIC, LEGACY_TXN_UNDERSZ ) ];
771 0 : cur->out.tpu_udp_invalid += quic_metrics[ MIDX( COUNTER, QUIC, LEGACY_TXN_OVERSZ ) ];
772 0 : cur->out.tpu_quic_invalid += quic_metrics[ MIDX( COUNTER, QUIC, PKT_UNDERSZ ) ];
773 0 : cur->out.tpu_quic_invalid += quic_metrics[ MIDX( COUNTER, QUIC, PKT_OVERSZ ) ];
774 0 : cur->out.tpu_quic_invalid += quic_metrics[ MIDX( COUNTER, QUIC, TXN_OVERSZ ) ];
775 0 : cur->out.tpu_quic_invalid += quic_metrics[ MIDX( COUNTER, QUIC, PKT_CRYPTO_FAILED ) ];
776 0 : cur->out.tpu_quic_invalid += quic_metrics[ MIDX( COUNTER, QUIC, PKT_NO_CONN ) ];
777 0 : cur->out.tpu_quic_invalid += quic_metrics[ MIDX( COUNTER, QUIC, PKT_WRONG_SRC ) ];
778 0 : cur->out.tpu_quic_invalid += quic_metrics[ MIDX( COUNTER, QUIC, PKT_NET_HEADER_INVALID ) ];
779 0 : cur->out.tpu_quic_invalid += quic_metrics[ MIDX( COUNTER, QUIC, PKT_QUIC_HEADER_INVALID ) ];
780 0 : cur->out.quic_abandoned += quic_metrics[ MIDX( COUNTER, QUIC, TXNS_ABANDONED ) ];
781 0 : cur->out.quic_frag_drop += quic_metrics[ MIDX( COUNTER, QUIC, TXNS_OVERRUN ) ];
782 :
783 0 : for( ulong j=0UL; j<gui->summary.net_tile_cnt; j++ ) {
784 : /* TODO: Not precise... net frags that were skipped might not have been destined for QUIC tile */
785 : /* TODO: Not precise... even if 1 frag gets skipped, it could have been for this QUIC tile */
786 0 : cur->out.quic_overrun += fd_metrics_link_in( quic->metrics, j )[ FD_METRICS_COUNTER_LINK_OVERRUN_POLLING_FRAG_COUNT_OFF ] / gui->summary.quic_tile_cnt;
787 0 : cur->out.quic_overrun += fd_metrics_link_in( quic->metrics, j )[ FD_METRICS_COUNTER_LINK_OVERRUN_READING_FRAG_COUNT_OFF ];
788 0 : }
789 0 : }
790 :
791 0 : for( ulong i=0UL; i<gui->summary.net_tile_cnt; i++ ) {
792 0 : fd_topo_tile_t const * net = &topo->tiles[ fd_topo_find_tile( topo, "net", i ) ];
793 0 : volatile ulong * net_metrics = fd_metrics_tile( net->metrics );
794 :
795 0 : cur->out.net_overrun += net_metrics[ MIDX( COUNTER, NET, XDP_RX_RING_FULL ) ];
796 0 : cur->out.net_overrun += net_metrics[ MIDX( COUNTER, NET, XDP_RX_DROPPED_OTHER ) ];
797 0 : cur->out.net_overrun += net_metrics[ MIDX( COUNTER, NET, XDP_RX_FILL_RING_EMPTY_DESCS ) ];
798 0 : }
799 :
800 0 : ulong bundle_txns_received = 0UL;
801 0 : ulong bundle_tile_idx = fd_topo_find_tile( topo, "bundle", 0UL );
802 0 : if( FD_LIKELY( bundle_tile_idx!=ULONG_MAX ) ) {
803 0 : fd_topo_tile_t const * bundle = &topo->tiles[ bundle_tile_idx ];
804 0 : volatile ulong const * bundle_metrics = fd_metrics_tile( bundle->metrics );
805 :
806 0 : bundle_txns_received = bundle_metrics[ MIDX( COUNTER, BUNDLE, TRANSACTION_RECEIVED ) ];
807 0 : }
808 :
809 0 : if( FD_UNLIKELY( gui->summary.is_full_client ) ) {
810 0 : cur->in.gossip = 0UL;
811 0 : for( ulong i=0UL; i<gui->summary.verify_tile_cnt; i++ ) {
812 0 : fd_topo_tile_t const * verify = &topo->tiles[ fd_topo_find_tile( topo, "verify", i ) ];
813 0 : volatile ulong const * verify_metrics = fd_metrics_tile( verify->metrics );
814 0 : cur->in.gossip += verify_metrics[ MIDX( COUNTER, VERIFY, GOSSIPED_VOTES_RECEIVED ) ];
815 0 : }
816 0 : } else if( dedup_tile_idx!=ULONG_MAX ) {
817 0 : fd_topo_tile_t const * dedup = &topo->tiles[ dedup_tile_idx ];
818 0 : volatile ulong const * dedup_metrics = fd_metrics_tile( dedup->metrics );
819 0 : cur->in.gossip = dedup_metrics[ MIDX( COUNTER, DEDUP, GOSSIPED_VOTES_RECEIVED ) ];
820 0 : }
821 :
822 0 : cur->in.quic = cur->out.tpu_quic_invalid +
823 0 : cur->out.quic_overrun +
824 0 : cur->out.quic_frag_drop +
825 0 : cur->out.quic_abandoned +
826 0 : cur->out.net_overrun;
827 0 : cur->in.udp = cur->out.tpu_udp_invalid;
828 0 : cur->in.block_engine = bundle_txns_received;
829 0 : for( ulong i=0UL; i<gui->summary.quic_tile_cnt; i++ ) {
830 0 : fd_topo_tile_t const * quic = &topo->tiles[ fd_topo_find_tile( topo, "quic", i ) ];
831 0 : volatile ulong * quic_metrics = fd_metrics_tile( quic->metrics );
832 :
833 0 : cur->in.quic += quic_metrics[ MIDX( COUNTER, QUIC, TXNS_RECEIVED_QUIC_FAST ) ];
834 0 : cur->in.quic += quic_metrics[ MIDX( COUNTER, QUIC, TXNS_RECEIVED_QUIC_FRAG ) ];
835 0 : cur->in.udp += quic_metrics[ MIDX( COUNTER, QUIC, TXNS_RECEIVED_UDP ) ];
836 0 : }
837 0 : }
838 :
839 : static void
840 : fd_gui_tile_stats_snap( fd_gui_t * gui,
841 : fd_gui_txn_waterfall_t const * waterfall,
842 : fd_gui_tile_stats_t * stats,
843 0 : long now ) {
844 0 : memset( stats, 0, sizeof(fd_gui_tile_stats_t) );
845 0 : fd_topo_t const * topo = gui->topo;
846 :
847 0 : stats->sample_time_nanos = now;
848 :
849 0 : for( ulong i=0UL; i<gui->summary.net_tile_cnt; i++ ) {
850 0 : fd_topo_tile_t const * net = &topo->tiles[ fd_topo_find_tile( topo, "net", i ) ];
851 0 : volatile ulong * net_metrics = fd_metrics_tile( net->metrics );
852 :
853 0 : stats->net_in_rx_bytes += net_metrics[ MIDX( COUNTER, NET, RX_BYTES_TOTAL ) ];
854 0 : stats->net_out_tx_bytes += net_metrics[ MIDX( COUNTER, NET, TX_BYTES_TOTAL ) ];
855 0 : }
856 :
857 0 : for( ulong i=0UL; i<gui->summary.sock_tile_cnt; i++ ) {
858 0 : fd_topo_tile_t const * sock = &topo->tiles[ fd_topo_find_tile( topo, "sock", i ) ];
859 0 : volatile ulong * sock_metrics = fd_metrics_tile( sock->metrics );
860 :
861 0 : stats->net_in_rx_bytes += sock_metrics[ MIDX( COUNTER, SOCK, RX_BYTES_TOTAL ) ];
862 0 : stats->net_out_tx_bytes += sock_metrics[ MIDX( COUNTER, SOCK, TX_BYTES_TOTAL ) ];
863 0 : }
864 :
865 0 : for( ulong i=0UL; i<gui->summary.quic_tile_cnt; i++ ) {
866 0 : fd_topo_tile_t const * quic = &topo->tiles[ fd_topo_find_tile( topo, "quic", i ) ];
867 0 : volatile ulong * quic_metrics = fd_metrics_tile( quic->metrics );
868 :
869 0 : stats->quic_conn_cnt += quic_metrics[ MIDX( GAUGE, QUIC, CONNECTIONS_ALLOC ) ];
870 0 : }
871 :
872 0 : ulong bundle_tile_idx = fd_topo_find_tile( topo, "bundle", 0UL );
873 0 : if( FD_LIKELY( bundle_tile_idx!=ULONG_MAX ) ) {
874 0 : fd_topo_tile_t const * bundle = &topo->tiles[ bundle_tile_idx ];
875 0 : volatile ulong * bundle_metrics = fd_metrics_tile( bundle->metrics );
876 0 : stats->bundle_rtt_smoothed_nanos = bundle_metrics[ MIDX( GAUGE, BUNDLE, RTT_SMOOTHED ) ];
877 :
878 0 : fd_histf_new( &stats->bundle_rx_delay_hist, FD_MHIST_MIN( BUNDLE, MESSAGE_RX_DELAY_NANOS ), FD_MHIST_MAX( BUNDLE, MESSAGE_RX_DELAY_NANOS ) );
879 0 : stats->bundle_rx_delay_hist.sum = bundle_metrics[ MIDX( HISTOGRAM, BUNDLE, MESSAGE_RX_DELAY_NANOS ) + FD_HISTF_BUCKET_CNT ];
880 0 : for( ulong b=0; b<FD_HISTF_BUCKET_CNT; b++ ) stats->bundle_rx_delay_hist.counts[ b ] = bundle_metrics[ MIDX( HISTOGRAM, BUNDLE, MESSAGE_RX_DELAY_NANOS ) + b ];
881 0 : }
882 :
883 0 : stats->verify_drop_cnt = waterfall->out.verify_duplicate +
884 0 : waterfall->out.verify_parse +
885 0 : waterfall->out.verify_failed;
886 0 : stats->verify_total_cnt = waterfall->in.gossip +
887 0 : waterfall->in.quic +
888 0 : waterfall->in.udp -
889 0 : waterfall->out.net_overrun -
890 0 : waterfall->out.tpu_quic_invalid -
891 0 : waterfall->out.tpu_udp_invalid -
892 0 : waterfall->out.quic_abandoned -
893 0 : waterfall->out.quic_frag_drop -
894 0 : waterfall->out.quic_overrun -
895 0 : waterfall->out.verify_overrun;
896 0 : stats->dedup_drop_cnt = waterfall->out.dedup_duplicate;
897 0 : stats->dedup_total_cnt = stats->verify_total_cnt -
898 0 : waterfall->out.verify_duplicate -
899 0 : waterfall->out.verify_parse -
900 0 : waterfall->out.verify_failed;
901 :
902 0 : ulong pack_tile_idx = fd_topo_find_tile( topo, "pack", 0UL );
903 0 : if( pack_tile_idx!=ULONG_MAX ) {
904 0 : fd_topo_tile_t const * pack = &topo->tiles[ pack_tile_idx ];
905 0 : volatile ulong const * pack_metrics = fd_metrics_tile( pack->metrics );
906 0 : stats->pack_buffer_cnt = pack_metrics[ MIDX( GAUGE, PACK, AVAILABLE_TRANSACTIONS ) ];
907 0 : stats->pack_buffer_capacity = pack->pack.max_pending_transactions;
908 0 : }
909 :
910 0 : stats->bank_txn_exec_cnt = waterfall->out.block_fail + waterfall->out.block_success;
911 0 : }
912 :
913 : static void
914 0 : fd_gui_run_boot_progress( fd_gui_t * gui, long now ) {
915 0 : fd_topo_tile_t const * snapct = &gui->topo->tiles[ fd_topo_find_tile( gui->topo, "snapct", 0UL ) ];
916 0 : volatile ulong * snapct_metrics = fd_metrics_tile( snapct->metrics );
917 :
918 0 : fd_topo_tile_t const * snapdc = &gui->topo->tiles[ fd_topo_find_tile( gui->topo, "snapdc", 0UL ) ];
919 0 : volatile ulong * snapdc_metrics = fd_metrics_tile( snapdc->metrics );
920 :
921 0 : fd_topo_tile_t const * snapin = &gui->topo->tiles[ fd_topo_find_tile( gui->topo, "snapin", 0UL ) ];
922 0 : volatile ulong * snapin_metrics = fd_metrics_tile( snapin->metrics );
923 :
924 0 : fd_topo_tile_t const * gossip = &gui->topo->tiles[ fd_topo_find_tile( gui->topo, "gossip", 0UL ) ];
925 0 : volatile ulong * gossip_metrics = fd_metrics_tile( gossip->metrics );
926 :
927 0 : ulong snapshot_phase = snapct_metrics[ MIDX( GAUGE, SNAPCT, STATE ) ];
928 0 : ulong wfs_state = gossip_metrics[ MIDX( GAUGE, GOSSIP, WFS_STATE ) ];
929 :
930 : /* state transitions */
931 0 : if( FD_UNLIKELY( gui->summary.slot_caught_up!=ULONG_MAX ) ) {
932 0 : gui->summary.boot_progress.phase = FD_GUI_BOOT_PROGRESS_TYPE_RUNNING;
933 0 : } else if( FD_LIKELY( snapshot_phase == FD_SNAPCT_STATE_SHUTDOWN && wfs_state==FD_GOSSIP_WFS_STATE_DONE && gui->summary.slots_max_turbine[ 0 ].slot!=ULONG_MAX && gui->summary.slot_completed!=ULONG_MAX ) ) {
934 0 : if( FD_UNLIKELY( gui->summary.wfs_enabled ) ) {
935 0 : if( FD_UNLIKELY( gui->summary.slot_caught_up==ULONG_MAX ) ) {
936 0 : ulong snap_inc = gui->summary.boot_progress.loading_snapshot[ FD_GUI_BOOT_PROGRESS_INCREMENTAL_SNAPSHOT_IDX ].slot;
937 0 : ulong snap_full = gui->summary.boot_progress.loading_snapshot[ FD_GUI_BOOT_PROGRESS_FULL_SNAPSHOT_IDX ].slot;
938 0 : gui->summary.slot_caught_up = fd_ulong_if( snap_inc!=ULONG_MAX, snap_inc, snap_full );
939 0 : gui->summary.boot_progress.catching_up_time_nanos = now;
940 :
941 0 : fd_gui_printf_slot_caught_up( gui );
942 0 : fd_http_server_ws_broadcast( gui->http );
943 0 : }
944 0 : gui->summary.boot_progress.phase = FD_GUI_BOOT_PROGRESS_TYPE_RUNNING;
945 0 : } else {
946 0 : gui->summary.boot_progress.phase = FD_GUI_BOOT_PROGRESS_TYPE_CATCHING_UP;
947 0 : }
948 0 : } else if( FD_UNLIKELY( snapshot_phase == FD_SNAPCT_STATE_SHUTDOWN && wfs_state==FD_GOSSIP_WFS_STATE_WAIT ) ) {
949 0 : gui->summary.boot_progress.phase = FD_GUI_BOOT_PROGRESS_TYPE_WAITING_FOR_SUPERMAJORITY;
950 0 : } else if( FD_LIKELY( snapshot_phase==FD_SNAPCT_STATE_READING_FULL_FILE
951 0 : || snapshot_phase==FD_SNAPCT_STATE_FLUSHING_FULL_FILE_FINI
952 0 : || snapshot_phase==FD_SNAPCT_STATE_FLUSHING_FULL_FILE_DONE
953 0 : || snapshot_phase==FD_SNAPCT_STATE_READING_FULL_HTTP
954 0 : || snapshot_phase==FD_SNAPCT_STATE_FLUSHING_FULL_HTTP_FINI
955 0 : || snapshot_phase==FD_SNAPCT_STATE_FLUSHING_FULL_HTTP_DONE ) ) {
956 0 : gui->summary.boot_progress.phase = FD_GUI_BOOT_PROGRESS_TYPE_LOADING_FULL_SNAPSHOT;
957 0 : } else if( FD_LIKELY( snapshot_phase==FD_SNAPCT_STATE_READING_INCREMENTAL_FILE
958 0 : || snapshot_phase==FD_SNAPCT_STATE_FLUSHING_INCREMENTAL_FILE_FINI
959 0 : || snapshot_phase==FD_SNAPCT_STATE_FLUSHING_INCREMENTAL_FILE_DONE
960 0 : || snapshot_phase==FD_SNAPCT_STATE_READING_INCREMENTAL_HTTP
961 0 : || snapshot_phase==FD_SNAPCT_STATE_FLUSHING_INCREMENTAL_HTTP_FINI
962 0 : || snapshot_phase==FD_SNAPCT_STATE_FLUSHING_INCREMENTAL_HTTP_DONE ) ) {
963 0 : gui->summary.boot_progress.phase = FD_GUI_BOOT_PROGRESS_TYPE_LOADING_INCREMENTAL_SNAPSHOT;
964 0 : }
965 :
966 : /* It's possible for the incremental snapshot phase to be skipped, or
967 : complete before we can sample it. This ensures we always get at
968 : least one pass of the metrics. */
969 0 : if( FD_UNLIKELY( gui->summary.boot_progress.phase==FD_GUI_BOOT_PROGRESS_TYPE_CATCHING_UP
970 0 : && gui->summary.boot_progress.loading_snapshot[ FD_GUI_BOOT_PROGRESS_INCREMENTAL_SNAPSHOT_IDX ].reset_cnt==ULONG_MAX ) ) {
971 0 : gui->summary.boot_progress.phase = FD_GUI_BOOT_PROGRESS_TYPE_LOADING_INCREMENTAL_SNAPSHOT;
972 0 : }
973 :
974 0 : switch ( gui->summary.boot_progress.phase ) {
975 0 : case FD_GUI_BOOT_PROGRESS_TYPE_JOINING_GOSSIP: {
976 0 : gui->summary.boot_progress.joining_gossip_time_nanos = now;
977 0 : break;
978 0 : }
979 0 : case FD_GUI_BOOT_PROGRESS_TYPE_LOADING_FULL_SNAPSHOT:
980 0 : case FD_GUI_BOOT_PROGRESS_TYPE_LOADING_INCREMENTAL_SNAPSHOT: {
981 0 : ulong snapshot_idx = fd_ulong_if( gui->summary.boot_progress.phase==FD_GUI_BOOT_PROGRESS_TYPE_LOADING_FULL_SNAPSHOT, FD_GUI_BOOT_PROGRESS_FULL_SNAPSHOT_IDX, FD_GUI_BOOT_PROGRESS_INCREMENTAL_SNAPSHOT_IDX );
982 0 : ulong _retry_cnt = fd_ulong_if( snapshot_idx==FD_GUI_BOOT_PROGRESS_FULL_SNAPSHOT_IDX, snapct_metrics[ MIDX( GAUGE, SNAPCT, FULL_DOWNLOAD_RETRIES ) ], snapct_metrics[ MIDX( GAUGE, SNAPCT, INCREMENTAL_DOWNLOAD_RETRIES ) ]);
983 :
984 : /* reset boot state if necessary */
985 0 : if( FD_UNLIKELY( gui->summary.boot_progress.loading_snapshot[ snapshot_idx ].reset_cnt!=_retry_cnt ) ) {
986 0 : gui->summary.boot_progress.loading_snapshot[ snapshot_idx ].reset_time_nanos = now;
987 0 : gui->summary.boot_progress.loading_snapshot[ snapshot_idx ].reset_cnt = _retry_cnt;
988 0 : }
989 :
990 0 : ulong _total_bytes = fd_ulong_if( snapshot_idx==FD_GUI_BOOT_PROGRESS_FULL_SNAPSHOT_IDX, snapct_metrics[ MIDX( GAUGE, SNAPCT, FULL_BYTES_TOTAL ) ], snapct_metrics[ MIDX( GAUGE, SNAPCT, INCREMENTAL_BYTES_TOTAL ) ] );
991 0 : ulong _read_bytes = fd_ulong_if( snapshot_idx==FD_GUI_BOOT_PROGRESS_FULL_SNAPSHOT_IDX, snapct_metrics[ MIDX( GAUGE, SNAPCT, FULL_BYTES_READ ) ], snapct_metrics[ MIDX( GAUGE, SNAPCT, INCREMENTAL_BYTES_READ ) ] );
992 0 : ulong _decompress_decompressed_bytes = fd_ulong_if( snapshot_idx==FD_GUI_BOOT_PROGRESS_FULL_SNAPSHOT_IDX, snapdc_metrics[ MIDX( GAUGE, SNAPDC, FULL_DECOMPRESSED_BYTES_WRITTEN ) ], snapdc_metrics[ MIDX( GAUGE, SNAPDC, INCREMENTAL_DECOMPRESSED_BYTES_WRITTEN ) ] );
993 0 : ulong _decompress_compressed_bytes = fd_ulong_if( snapshot_idx==FD_GUI_BOOT_PROGRESS_FULL_SNAPSHOT_IDX, snapdc_metrics[ MIDX( GAUGE, SNAPDC, FULL_COMPRESSED_BYTES_READ ) ], snapdc_metrics[ MIDX( GAUGE, SNAPDC, INCREMENTAL_COMPRESSED_BYTES_READ ) ] );
994 0 : ulong _insert_bytes = fd_ulong_if( snapshot_idx==FD_GUI_BOOT_PROGRESS_FULL_SNAPSHOT_IDX, snapin_metrics[ MIDX( GAUGE, SNAPIN, FULL_BYTES_READ ) ], snapin_metrics[ MIDX( GAUGE, SNAPIN, INCREMENTAL_BYTES_READ ) ] );
995 0 : ulong _insert_accounts = snapin_metrics[ MIDX( GAUGE, SNAPIN, ACCOUNTS_LOADED ) ];
996 :
997 : /* metadata */
998 0 : gui->summary.boot_progress.loading_snapshot[ snapshot_idx ].total_bytes_compressed = _total_bytes;
999 0 : gui->summary.boot_progress.loading_snapshot[ snapshot_idx ].sample_time_nanos = now;
1000 :
1001 : /* read stage */
1002 0 : gui->summary.boot_progress.loading_snapshot[ snapshot_idx ].read_bytes_compressed = _read_bytes;
1003 :
1004 : /* decompress stage */
1005 0 : gui->summary.boot_progress.loading_snapshot[ snapshot_idx ].decompress_bytes_compressed = _decompress_compressed_bytes;
1006 0 : gui->summary.boot_progress.loading_snapshot[ snapshot_idx ].decompress_bytes_decompressed = _decompress_decompressed_bytes;
1007 :
1008 : /* insert stage */
1009 0 : gui->summary.boot_progress.loading_snapshot[ snapshot_idx ].insert_bytes_decompressed = _insert_bytes;
1010 :
1011 : /* Use the latest compression ratio to estimate decompressed size */
1012 0 : gui->summary.boot_progress.loading_snapshot[ snapshot_idx ].insert_accounts_current = _insert_accounts;
1013 :
1014 0 : break;
1015 0 : }
1016 0 : case FD_GUI_BOOT_PROGRESS_TYPE_WAITING_FOR_SUPERMAJORITY: {
1017 0 : gui->summary.boot_progress.wfs_total_stake = gossip_metrics[ MIDX( GAUGE, GOSSIP, WFS_STAKE_TOTAL ) ];
1018 0 : gui->summary.boot_progress.wfs_connected_stake = gossip_metrics[ MIDX( GAUGE, GOSSIP, WFS_STAKE_ONLINE ) ];
1019 0 : gui->summary.boot_progress.wfs_total_peers = gossip_metrics[ MIDX( GAUGE, GOSSIP, WFS_STAKED_PEERS_TOTAL ) ];
1020 0 : gui->summary.boot_progress.wfs_connected_peers = gossip_metrics[ MIDX( GAUGE, GOSSIP, WFS_STAKED_PEERS_ONLINE ) ];
1021 0 : break;
1022 0 : }
1023 0 : case FD_GUI_BOOT_PROGRESS_TYPE_CATCHING_UP: {
1024 0 : gui->summary.boot_progress.catching_up_time_nanos = now;
1025 0 : break;
1026 0 : }
1027 0 : case FD_GUI_BOOT_PROGRESS_TYPE_RUNNING: break;
1028 0 : default: FD_LOG_ERR(( "unknown boot progress phase: %d", gui->summary.boot_progress.phase ));
1029 0 : }
1030 0 : }
1031 :
1032 : static inline int
1033 0 : fd_gui_ephemeral_slots_contains( fd_gui_ephemeral_slot_t * slots, ulong slots_sz, ulong slot ) {
1034 0 : for( ulong i=0UL; i<slots_sz; i++ ) {
1035 0 : if( FD_UNLIKELY( slots[ i ].slot==ULONG_MAX ) ) break;
1036 0 : if( FD_UNLIKELY( slots[ i ].slot==slot ) ) return 1;
1037 0 : }
1038 0 : return 0;
1039 0 : }
1040 :
1041 : #define SORT_NAME fd_gui_ephemeral_slot_sort
1042 0 : #define SORT_KEY_T fd_gui_ephemeral_slot_t
1043 0 : #define SORT_BEFORE(a,b) fd_int_if( (a).slot==ULONG_MAX, 0, fd_int_if( (b).slot==ULONG_MAX, 1, fd_int_if( (a).slot==(b).slot, (a).timestamp_arrival_nanos>(b).timestamp_arrival_nanos, (a).slot>(b).slot ) ) )
1044 : #include "../../util/tmpl/fd_sort.c"
1045 :
1046 : static inline void
1047 0 : fd_gui_try_insert_ephemeral_slot( fd_gui_ephemeral_slot_t * slots, ulong slots_sz, ulong slot, long now ) {
1048 0 : int already_present = 0;
1049 0 : for( ulong i=0UL; i<slots_sz; i++ ) {
1050 : /* evict any slots older than 4.8 seconds */
1051 0 : if( FD_UNLIKELY( slots[ i ].slot!=ULONG_MAX && now-slots[ i ].timestamp_arrival_nanos>4800000000L ) ) {
1052 0 : slots[ i ].slot = ULONG_MAX;
1053 0 : continue;
1054 0 : }
1055 :
1056 : /* if we've already seen this slot, just update the timestamp */
1057 0 : if( FD_UNLIKELY( slots[ i ].slot==slot ) ) {
1058 0 : slots[ i ].timestamp_arrival_nanos = now;
1059 0 : already_present = 1;
1060 0 : }
1061 0 : }
1062 0 : if( FD_LIKELY( already_present ) ) return;
1063 :
1064 : /* Insert the new slot number, evicting a smaller slot if necessary */
1065 0 : slots[ slots_sz ].timestamp_arrival_nanos = now;
1066 0 : slots[ slots_sz ].slot = slot;
1067 0 : fd_gui_ephemeral_slot_sort_insert( slots, slots_sz+1UL );
1068 0 : }
1069 :
1070 : static inline void
1071 0 : fd_gui_try_insert_run_length_slot( ulong * slots, ulong capacity, ulong * slots_sz, ulong slot ) {
1072 : /* catch up history is run-length encoded */
1073 0 : ulong range_idx = fd_sort_up_ulong_split( slots, *slots_sz, slot );
1074 0 : if( FD_UNLIKELY( range_idx<(*slots_sz)-1UL && range_idx%2UL==0UL && slots[ range_idx ]<=slot && slots[ range_idx+1UL ]>=slot ) ) return;
1075 0 : if( FD_UNLIKELY( range_idx<(*slots_sz) && range_idx>0UL && range_idx%2UL==1UL && slots[ range_idx-1UL ]<=slot && slots[ range_idx ]>=slot ) ) return;
1076 :
1077 0 : slots[ (*slots_sz)++ ] = slot;
1078 0 : slots[ (*slots_sz)++ ] = slot;
1079 :
1080 0 : fd_sort_up_ulong_insert( slots, (*slots_sz) );
1081 :
1082 : /* colesce ranges */
1083 0 : ulong removed = 0UL;
1084 0 : for( ulong i=1UL; i<(*slots_sz)-1UL; i+=2 ) {
1085 0 : if( FD_UNLIKELY( slots[ i ]+1UL==slots[ i+1UL ] ) ) {
1086 0 : slots[ i ] = ULONG_MAX;
1087 0 : slots[ i+1UL ] = ULONG_MAX;
1088 0 : removed += 2;
1089 0 : }
1090 0 : }
1091 :
1092 0 : if( FD_UNLIKELY( (*slots_sz)>=removed+capacity-2UL && (*slots_sz)>=4UL ) ) {
1093 : /* We are at capacity, start coalescing earlier intervals. */
1094 0 : slots[ 1 ] = ULONG_MAX;
1095 0 : slots[ 2 ] = ULONG_MAX;
1096 0 : removed += 2;
1097 0 : }
1098 :
1099 0 : fd_sort_up_ulong_insert( slots, (*slots_sz) );
1100 0 : (*slots_sz) -= removed;
1101 0 : }
1102 :
1103 : void
1104 0 : fd_gui_handle_repair_slot( fd_gui_t * gui, ulong slot, long now ) {
1105 0 : int was_sent = fd_gui_ephemeral_slots_contains( gui->summary.slots_max_repair, FD_GUI_REPAIR_SLOT_HISTORY_SZ, slot );
1106 0 : fd_gui_try_insert_ephemeral_slot( gui->summary.slots_max_repair, FD_GUI_REPAIR_SLOT_HISTORY_SZ, slot, now );
1107 :
1108 0 : if( FD_UNLIKELY( !was_sent && slot!=gui->summary.slot_repair ) ) {
1109 0 : gui->summary.slot_repair = slot;
1110 :
1111 0 : fd_gui_printf_repair_slot( gui );
1112 0 : fd_http_server_ws_broadcast( gui->http );
1113 :
1114 0 : if( FD_UNLIKELY( gui->summary.slot_caught_up==ULONG_MAX ) ) fd_gui_try_insert_run_length_slot( gui->summary.catch_up_repair, FD_GUI_REPAIR_CATCH_UP_HISTORY_SZ, &gui->summary.catch_up_repair_sz, slot );
1115 0 : }
1116 0 : }
1117 :
1118 : void
1119 0 : fd_gui_handle_repair_request( fd_gui_t * gui, ulong slot, ulong shred_idx, long now ) {
1120 0 : fd_gui_slot_staged_shred_event_t * recv_event = fd_gui_staged_push( gui );
1121 0 : recv_event->timestamp = now;
1122 0 : recv_event->shred_idx = (ushort)shred_idx;
1123 0 : recv_event->slot = slot;
1124 0 : recv_event->event = FD_GUI_SLOT_SHRED_REPAIR_REQUEST;
1125 0 : }
1126 :
1127 : static void
1128 0 : fd_gui_progcache_sample( fd_gui_t * gui ) {
1129 0 : fd_topo_t const * topo = gui->topo;
1130 :
1131 0 : ulong hits = 0UL;
1132 0 : ulong lookups = 0UL;
1133 :
1134 0 : for( ulong i=0UL; i<gui->summary.execrp_tile_cnt; i++ ) {
1135 0 : fd_topo_tile_t const * execrp = &topo->tiles[ fd_topo_find_tile( topo, "execrp", i ) ];
1136 0 : volatile ulong const * metrics = fd_metrics_tile( execrp->metrics );
1137 :
1138 0 : lookups += metrics[ MIDX( COUNTER, EXECRP, PROGCACHE_LOOKUPS ) ];
1139 0 : hits += metrics[ MIDX( COUNTER, EXECRP, PROGCACHE_HITS ) ];
1140 0 : }
1141 :
1142 : /* The execrp tile writes lookups before hits in metrics_write, so
1143 : reading lookups first then hits here means we may observe the
1144 : new hits before the new lookups, giving hits > lookups
1145 : momentarily. Clamp to maintain the invariant hits <= lookups. */
1146 :
1147 0 : hits = fd_ulong_min( hits, lookups );
1148 :
1149 0 : ulong ring_idx = gui->summary.progcache_history_idx % FD_GUI_PROGCACHE_HISTORY_CNT;
1150 0 : ulong oldest_hits = gui->summary.progcache_hits_history [ ring_idx ];
1151 0 : ulong oldest_lookups = gui->summary.progcache_lookups_history[ ring_idx ];
1152 :
1153 0 : gui->summary.progcache_hits_history [ ring_idx ] = hits;
1154 0 : gui->summary.progcache_lookups_history[ ring_idx ] = lookups;
1155 0 : gui->summary.progcache_history_idx = gui->summary.progcache_history_idx + 1UL;
1156 :
1157 0 : ulong hits_1min = hits - oldest_hits;
1158 0 : ulong lookups_1min = lookups - oldest_lookups;
1159 0 : hits_1min = fd_ulong_min( hits_1min, lookups_1min );
1160 :
1161 0 : gui->summary.progcache_hits_1min = hits_1min;
1162 0 : gui->summary.progcache_lookups_1min = lookups_1min;
1163 0 : }
1164 :
1165 : int
1166 0 : fd_gui_poll( fd_gui_t * gui, long now ) {
1167 0 : if( FD_LIKELY( now>gui->next_sample_400millis ) ) {
1168 0 : fd_gui_estimated_tps_snap( gui );
1169 0 : fd_gui_printf_estimated_tps( gui );
1170 0 : fd_http_server_ws_broadcast( gui->http );
1171 :
1172 0 : gui->next_sample_400millis += 400L*1000L*1000L;
1173 0 : return 1;
1174 0 : }
1175 :
1176 0 : if( FD_LIKELY( now>gui->next_sample_100millis ) ) {
1177 0 : fd_gui_txn_waterfall_snap( gui, gui->summary.txn_waterfall_current );
1178 0 : fd_gui_printf_live_txn_waterfall( gui, gui->summary.txn_waterfall_reference, gui->summary.txn_waterfall_current, 0UL /* TODO: REAL NEXT LEADER SLOT */ );
1179 0 : fd_http_server_ws_broadcast( gui->http );
1180 :
1181 0 : fd_gui_network_stats_snap( gui, gui->summary.network_stats_current );
1182 0 : fd_gui_network_rate_max_update( gui, now );
1183 0 : fd_gui_printf_live_network_metrics( gui, gui->summary.network_stats_current );
1184 0 : fd_http_server_ws_broadcast( gui->http );
1185 :
1186 0 : *gui->summary.tile_stats_reference = *gui->summary.tile_stats_current;
1187 0 : fd_gui_tile_stats_snap( gui, gui->summary.txn_waterfall_current, gui->summary.tile_stats_current, now );
1188 0 : fd_gui_printf_live_tile_stats( gui, gui->summary.tile_stats_reference, gui->summary.tile_stats_current );
1189 0 : fd_http_server_ws_broadcast( gui->http );
1190 :
1191 0 : if( FD_LIKELY( gui->summary.is_full_client ) ) {
1192 0 : fd_gui_progcache_sample( gui );
1193 0 : fd_gui_printf_live_program_cache( gui );
1194 0 : fd_http_server_ws_broadcast( gui->http );
1195 0 : }
1196 :
1197 0 : if( FD_UNLIKELY( gui->summary.is_full_client && gui->summary.boot_progress.phase!=FD_GUI_BOOT_PROGRESS_TYPE_RUNNING ) ) {
1198 0 : fd_gui_run_boot_progress( gui, now );
1199 0 : if( FD_UNLIKELY( memcmp( &gui->summary.boot_progress, &gui->summary.prev_boot_progress, sizeof(fd_gui_boot_progress_t) ) ) ) {
1200 0 : gui->summary.prev_boot_progress = gui->summary.boot_progress;
1201 0 : fd_gui_printf_boot_progress( gui );
1202 0 : fd_http_server_ws_broadcast( gui->http );
1203 0 : }
1204 0 : }
1205 :
1206 0 : ulong bundle_tile_idx = fd_topo_find_tile( gui->topo, "bundle", 0UL );
1207 0 : if( FD_LIKELY( bundle_tile_idx!=ULONG_MAX ) ) {
1208 0 : volatile ulong const * bundle_metrics = fd_metrics_tile( gui->topo->tiles[ bundle_tile_idx ].metrics );
1209 0 : int cur_state = (int)bundle_metrics[ MIDX( GAUGE, BUNDLE, STATE ) ];
1210 0 : if( FD_UNLIKELY( cur_state != gui->block_engine.status ) ) {
1211 0 : gui->block_engine.status = cur_state;
1212 0 : fd_gui_printf_block_engine( gui );
1213 0 : fd_http_server_ws_broadcast( gui->http );
1214 0 : }
1215 0 : }
1216 :
1217 0 : fd_gui_printf_health( gui );
1218 0 : fd_http_server_ws_broadcast( gui->http );
1219 :
1220 0 : gui->next_sample_100millis += 100L*1000L*1000L;
1221 0 : return 1;
1222 0 : }
1223 :
1224 0 : if( FD_LIKELY( now>gui->next_sample_50millis ) ) {
1225 0 : if( FD_LIKELY( gui->summary.is_full_client && gui->shreds.staged_next_broadcast<gui->shreds.staged_tail ) ) {
1226 0 : fd_gui_printf_shred_updates( gui );
1227 0 : fd_http_server_ws_broadcast( gui->http );
1228 0 : gui->shreds.staged_next_broadcast = gui->shreds.staged_tail;
1229 0 : }
1230 :
1231 : /* We get the repair slot from the sampled metric after catching up
1232 : and from incoming shred data before catchup. This makes the
1233 : catchup progress bar look complete while also keeping the
1234 : overview slots vis correct. TODO: do this properly using frags
1235 : sent over a link */
1236 0 : if( FD_LIKELY( gui->summary.slot_caught_up!=ULONG_MAX ) ) {
1237 0 : fd_topo_tile_t const * repair = &gui->topo->tiles[ fd_topo_find_tile( gui->topo, "repair", 0UL ) ];
1238 0 : volatile ulong const * repair_metrics = fd_metrics_tile( repair->metrics );
1239 0 : ulong slot = repair_metrics[ MIDX( GAUGE, REPAIR, REPAIRED_SLOTS ) ];
1240 0 : fd_gui_handle_repair_slot( gui, slot, now );
1241 0 : }
1242 :
1243 0 : gui->next_sample_50millis += 50L*1000L*1000L;
1244 0 : return 1;
1245 0 : }
1246 :
1247 0 : if( FD_LIKELY( now>gui->next_sample_25millis ) ) {
1248 0 : fd_gui_tile_timers_snap( gui );
1249 :
1250 0 : fd_gui_printf_live_tile_timers( gui );
1251 0 : fd_http_server_ws_broadcast( gui->http );
1252 :
1253 0 : fd_gui_printf_live_tile_metrics( gui );
1254 0 : fd_http_server_ws_broadcast( gui->http );
1255 :
1256 0 : gui->next_sample_25millis += (long)(25*1000L*1000L);
1257 0 : return 1;
1258 0 : }
1259 :
1260 :
1261 0 : if( FD_LIKELY( now>gui->next_sample_10millis ) ) {
1262 0 : fd_gui_scheduler_counts_snap( gui, now );
1263 :
1264 0 : fd_gui_printf_server_time_nanos( gui, now );
1265 0 : fd_http_server_ws_broadcast( gui->http );
1266 :
1267 0 : gui->next_sample_10millis += 10L*1000L*1000L;
1268 0 : return 1;
1269 0 : }
1270 :
1271 0 : return 0;
1272 0 : }
1273 :
1274 : static void
1275 : fd_gui_handle_gossip_update( fd_gui_t * gui,
1276 0 : uchar const * msg ) {
1277 : /* `gui->gossip.peer_cnt` is guaranteed to be in [0, FD_GUI_MAX_PEER_CNT], because
1278 : `peer_cnt` is FD_TEST-ed to be less than or equal FD_GUI_MAX_PEER_CNT.
1279 : For every new peer that is added an existing peer will be removed or was still free.
1280 : And adding a new peer is done at most `peer_cnt` times. */
1281 0 : ulong peer_cnt = FD_LOAD( ulong, msg );
1282 :
1283 0 : FD_TEST( peer_cnt<=FD_GUI_MAX_PEER_CNT );
1284 :
1285 0 : ulong added_cnt = 0UL;
1286 0 : ulong added[ FD_GUI_MAX_PEER_CNT ] = {0};
1287 :
1288 0 : ulong update_cnt = 0UL;
1289 0 : ulong updated[ FD_GUI_MAX_PEER_CNT ] = {0};
1290 :
1291 0 : ulong removed_cnt = 0UL;
1292 0 : fd_pubkey_t removed[ FD_GUI_MAX_PEER_CNT ] = {0};
1293 :
1294 0 : uchar const * data = msg + sizeof(ulong);
1295 0 : for( ulong i=0UL; i<gui->gossip.peer_cnt; i++ ) {
1296 0 : int found = 0;
1297 0 : for( ulong j=0UL; j<peer_cnt; j++ ) {
1298 0 : if( FD_UNLIKELY( !memcmp( gui->gossip.peers[ i ].pubkey, data+j*(58UL+12UL*6UL), 32UL ) ) ) {
1299 0 : found = 1;
1300 0 : break;
1301 0 : }
1302 0 : }
1303 :
1304 0 : if( FD_UNLIKELY( !found ) ) {
1305 0 : fd_memcpy( removed[ removed_cnt++ ].uc, gui->gossip.peers[ i ].pubkey->uc, 32UL );
1306 0 : if( FD_LIKELY( i+1UL!=gui->gossip.peer_cnt ) ) {
1307 0 : gui->gossip.peers[ i ] = gui->gossip.peers[ gui->gossip.peer_cnt-1UL ];
1308 0 : i--;
1309 0 : }
1310 0 : gui->gossip.peer_cnt--;
1311 0 : }
1312 0 : }
1313 :
1314 0 : ulong before_peer_cnt = gui->gossip.peer_cnt;
1315 0 : for( ulong i=0UL; i<peer_cnt; i++ ) {
1316 0 : int found = 0;
1317 0 : ulong found_idx = 0;
1318 0 : for( ulong j=0UL; j<gui->gossip.peer_cnt; j++ ) {
1319 0 : if( FD_UNLIKELY( !memcmp( gui->gossip.peers[ j ].pubkey, data+i*(58UL+12UL*6UL), 32UL ) ) ) {
1320 0 : found_idx = j;
1321 0 : found = 1;
1322 0 : break;
1323 0 : }
1324 0 : }
1325 :
1326 0 : if( FD_UNLIKELY( !found ) ) {
1327 0 : fd_memcpy( gui->gossip.peers[ gui->gossip.peer_cnt ].pubkey->uc, data+i*(58UL+12UL*6UL), 32UL );
1328 0 : gui->gossip.peers[ gui->gossip.peer_cnt ].wallclock = FD_LOAD( ulong, data+i*(58UL+12UL*6UL)+32UL );
1329 0 : gui->gossip.peers[ gui->gossip.peer_cnt ].shred_version = FD_LOAD( ushort, data+i*(58UL+12UL*6UL)+40UL );
1330 0 : gui->gossip.peers[ gui->gossip.peer_cnt ].has_version = FD_LOAD( uchar, data+i*(58UL+12UL*6UL)+42UL );
1331 0 : if( FD_LIKELY( gui->gossip.peers[ gui->gossip.peer_cnt ].has_version ) ) {
1332 0 : gui->gossip.peers[ gui->gossip.peer_cnt ].version.major = FD_LOAD( ushort, data+i*(58UL+12UL*6UL)+43UL );
1333 0 : gui->gossip.peers[ gui->gossip.peer_cnt ].version.minor = FD_LOAD( ushort, data+i*(58UL+12UL*6UL)+45UL );
1334 0 : gui->gossip.peers[ gui->gossip.peer_cnt ].version.patch = FD_LOAD( ushort, data+i*(58UL+12UL*6UL)+47UL );
1335 0 : gui->gossip.peers[ gui->gossip.peer_cnt ].version.has_commit = FD_LOAD( uchar, data+i*(58UL+12UL*6UL)+49UL );
1336 0 : if( FD_LIKELY( gui->gossip.peers[ gui->gossip.peer_cnt ].version.has_commit ) ) {
1337 0 : gui->gossip.peers[ gui->gossip.peer_cnt ].version.commit = FD_LOAD( uint, data+i*(58UL+12UL*6UL)+50UL );
1338 0 : }
1339 0 : gui->gossip.peers[ gui->gossip.peer_cnt ].version.feature_set = FD_LOAD( uint, data+i*(58UL+12UL*6UL)+54UL );
1340 0 : }
1341 :
1342 0 : for( ulong j=0UL; j<12UL; j++ ) {
1343 0 : gui->gossip.peers[ gui->gossip.peer_cnt ].sockets[ j ].ipv4 = FD_LOAD( uint, data+i*(58UL+12UL*6UL)+58UL+j*6UL );
1344 0 : gui->gossip.peers[ gui->gossip.peer_cnt ].sockets[ j ].port = FD_LOAD( ushort, data+i*(58UL+12UL*6UL)+58UL+j*6UL+4UL );
1345 0 : }
1346 :
1347 0 : gui->gossip.peer_cnt++;
1348 0 : } else {
1349 0 : int peer_updated = gui->gossip.peers[ found_idx ].shred_version!=FD_LOAD( ushort, data+i*(58UL+12UL*6UL)+40UL ) ||
1350 : // gui->gossip.peers[ found_idx ].wallclock!=FD_LOAD( ulong, data+i*(58UL+12UL*6UL)+32UL ) ||
1351 0 : gui->gossip.peers[ found_idx ].has_version!=FD_LOAD( uchar, data+i*(58UL+12UL*6UL)+42UL );
1352 :
1353 0 : if( FD_LIKELY( !peer_updated && gui->gossip.peers[ found_idx ].has_version ) ) {
1354 0 : peer_updated = gui->gossip.peers[ found_idx ].version.major!=FD_LOAD( ushort, data+i*(58UL+12UL*6UL)+43UL ) ||
1355 0 : gui->gossip.peers[ found_idx ].version.minor!=FD_LOAD( ushort, data+i*(58UL+12UL*6UL)+45UL ) ||
1356 0 : gui->gossip.peers[ found_idx ].version.patch!=FD_LOAD( ushort, data+i*(58UL+12UL*6UL)+47UL ) ||
1357 0 : gui->gossip.peers[ found_idx ].version.has_commit!=FD_LOAD( uchar, data+i*(58UL+12UL*6UL)+49UL ) ||
1358 0 : (gui->gossip.peers[ found_idx ].version.has_commit && gui->gossip.peers[ found_idx ].version.commit!=FD_LOAD( uint, data+i*(58UL+12UL*6UL)+50UL )) ||
1359 0 : gui->gossip.peers[ found_idx ].version.feature_set!=FD_LOAD( uint, data+i*(58UL+12UL*6UL)+54UL );
1360 0 : }
1361 :
1362 0 : if( FD_LIKELY( !peer_updated ) ) {
1363 0 : for( ulong j=0UL; j<12UL; j++ ) {
1364 0 : peer_updated = gui->gossip.peers[ found_idx ].sockets[ j ].ipv4!=FD_LOAD( uint, data+i*(58UL+12UL*6UL)+58UL+j*6UL ) ||
1365 0 : gui->gossip.peers[ found_idx ].sockets[ j ].port!=FD_LOAD( ushort, data+i*(58UL+12UL*6UL)+58UL+j*6UL+4UL );
1366 0 : if( FD_LIKELY( peer_updated ) ) break;
1367 0 : }
1368 0 : }
1369 :
1370 0 : if( FD_UNLIKELY( peer_updated ) ) {
1371 0 : updated[ update_cnt++ ] = found_idx;
1372 0 : gui->gossip.peers[ found_idx ].shred_version = FD_LOAD( ushort, data+i*(58UL+12UL*6UL)+40UL );
1373 0 : gui->gossip.peers[ found_idx ].wallclock = FD_LOAD( ulong, data+i*(58UL+12UL*6UL)+32UL );
1374 0 : gui->gossip.peers[ found_idx ].has_version = FD_LOAD( uchar, data+i*(58UL+12UL*6UL)+42UL );
1375 0 : if( FD_LIKELY( gui->gossip.peers[ found_idx ].has_version ) ) {
1376 0 : gui->gossip.peers[ found_idx ].version.major = FD_LOAD( ushort, data+i*(58UL+12UL*6UL)+43UL );
1377 0 : gui->gossip.peers[ found_idx ].version.minor = FD_LOAD( ushort, data+i*(58UL+12UL*6UL)+45UL );
1378 0 : gui->gossip.peers[ found_idx ].version.patch = FD_LOAD( ushort, data+i*(58UL+12UL*6UL)+47UL );
1379 0 : gui->gossip.peers[ found_idx ].version.has_commit = FD_LOAD( uchar, data+i*(58UL+12UL*6UL)+49UL );
1380 0 : if( FD_LIKELY( gui->gossip.peers[ found_idx ].version.has_commit ) ) {
1381 0 : gui->gossip.peers[ found_idx ].version.commit = FD_LOAD( uint, data+i*(58UL+12UL*6UL)+50UL );
1382 0 : }
1383 0 : gui->gossip.peers[ found_idx ].version.feature_set = FD_LOAD( uint, data+i*(58UL+12UL*6UL)+54UL );
1384 0 : }
1385 :
1386 0 : for( ulong j=0UL; j<12UL; j++ ) {
1387 0 : gui->gossip.peers[ found_idx ].sockets[ j ].ipv4 = FD_LOAD( uint, data+i*(58UL+12UL*6UL)+58UL+j*6UL );
1388 0 : gui->gossip.peers[ found_idx ].sockets[ j ].port = FD_LOAD( ushort, data+i*(58UL+12UL*6UL)+58UL+j*6UL+4UL );
1389 0 : }
1390 0 : }
1391 0 : }
1392 0 : }
1393 :
1394 0 : added_cnt = gui->gossip.peer_cnt - before_peer_cnt;
1395 0 : for( ulong i=before_peer_cnt; i<gui->gossip.peer_cnt; i++ ) added[ i-before_peer_cnt ] = i;
1396 :
1397 0 : fd_gui_printf_peers_gossip_update( gui, updated, update_cnt, removed, removed_cnt, added, added_cnt );
1398 0 : fd_http_server_ws_broadcast( gui->http );
1399 0 : }
1400 :
1401 : static void
1402 : fd_gui_handle_vote_account_update( fd_gui_t * gui,
1403 0 : uchar const * msg ) {
1404 : /* See fd_gui_handle_gossip_update for why `gui->vote_account.vote_account_cnt`
1405 : is guaranteed to be in [0, FD_GUI_MAX_PEER_CNT]. */
1406 0 : ulong peer_cnt = FD_LOAD( ulong, msg );
1407 :
1408 0 : FD_TEST( peer_cnt<=FD_GUI_MAX_PEER_CNT );
1409 :
1410 0 : ulong added_cnt = 0UL;
1411 0 : ulong added[ FD_GUI_MAX_PEER_CNT ] = {0};
1412 :
1413 0 : ulong update_cnt = 0UL;
1414 0 : ulong updated[ FD_GUI_MAX_PEER_CNT ] = {0};
1415 :
1416 0 : ulong removed_cnt = 0UL;
1417 0 : fd_pubkey_t removed[ FD_GUI_MAX_PEER_CNT ] = {0};
1418 :
1419 0 : uchar const * data = msg + sizeof(ulong);
1420 0 : for( ulong i=0UL; i<gui->vote_account.vote_account_cnt; i++ ) {
1421 0 : int found = 0;
1422 0 : for( ulong j=0UL; j<peer_cnt; j++ ) {
1423 0 : if( FD_UNLIKELY( !memcmp( gui->vote_account.vote_accounts[ i ].vote_account, data+j*112UL, 32UL ) ) ) {
1424 0 : found = 1;
1425 0 : break;
1426 0 : }
1427 0 : }
1428 :
1429 0 : if( FD_UNLIKELY( !found ) ) {
1430 0 : fd_memcpy( removed[ removed_cnt++ ].uc, gui->vote_account.vote_accounts[ i ].vote_account->uc, 32UL );
1431 0 : if( FD_LIKELY( i+1UL!=gui->vote_account.vote_account_cnt ) ) {
1432 0 : gui->vote_account.vote_accounts[ i ] = gui->vote_account.vote_accounts[ gui->vote_account.vote_account_cnt-1UL ];
1433 0 : i--;
1434 0 : }
1435 0 : gui->vote_account.vote_account_cnt--;
1436 0 : }
1437 0 : }
1438 :
1439 0 : ulong before_peer_cnt = gui->vote_account.vote_account_cnt;
1440 0 : for( ulong i=0UL; i<peer_cnt; i++ ) {
1441 0 : int found = 0;
1442 0 : ulong found_idx;
1443 0 : for( ulong j=0UL; j<gui->vote_account.vote_account_cnt; j++ ) {
1444 0 : if( FD_UNLIKELY( !memcmp( gui->vote_account.vote_accounts[ j ].vote_account, data+i*112UL, 32UL ) ) ) {
1445 0 : found_idx = j;
1446 0 : found = 1;
1447 0 : break;
1448 0 : }
1449 0 : }
1450 :
1451 0 : if( FD_UNLIKELY( !found ) ) {
1452 0 : fd_memcpy( gui->vote_account.vote_accounts[ gui->vote_account.vote_account_cnt ].vote_account->uc, data+i*112UL, 32UL );
1453 0 : fd_memcpy( gui->vote_account.vote_accounts[ gui->vote_account.vote_account_cnt ].pubkey->uc, data+i*112UL+32UL, 32UL );
1454 :
1455 0 : gui->vote_account.vote_accounts[ gui->vote_account.vote_account_cnt ].activated_stake = FD_LOAD( ulong, data+i*112UL+64UL );
1456 0 : gui->vote_account.vote_accounts[ gui->vote_account.vote_account_cnt ].last_vote = FD_LOAD( ulong, data+i*112UL+72UL );
1457 0 : gui->vote_account.vote_accounts[ gui->vote_account.vote_account_cnt ].root_slot = FD_LOAD( ulong, data+i*112UL+80UL );
1458 0 : gui->vote_account.vote_accounts[ gui->vote_account.vote_account_cnt ].epoch_credits = FD_LOAD( ulong, data+i*112UL+88UL );
1459 0 : gui->vote_account.vote_accounts[ gui->vote_account.vote_account_cnt ].commission = FD_LOAD( uchar, data+i*112UL+96UL );
1460 0 : gui->vote_account.vote_accounts[ gui->vote_account.vote_account_cnt ].delinquent = FD_LOAD( uchar, data+i*112UL+97UL );
1461 :
1462 0 : gui->vote_account.vote_account_cnt++;
1463 0 : } else {
1464 0 : int peer_updated =
1465 0 : memcmp( gui->vote_account.vote_accounts[ found_idx ].pubkey->uc, data+i*112UL+32UL, 32UL ) ||
1466 0 : gui->vote_account.vote_accounts[ found_idx ].activated_stake != FD_LOAD( ulong, data+i*112UL+64UL ) ||
1467 : // gui->vote_account.vote_accounts[ found_idx ].last_vote != FD_LOAD( ulong, data+i*112UL+72UL ) ||
1468 : // gui->vote_account.vote_accounts[ found_idx ].root_slot != FD_LOAD( ulong, data+i*112UL+80UL ) ||
1469 : // gui->vote_account.vote_accounts[ found_idx ].epoch_credits != FD_LOAD( ulong, data+i*112UL+88UL ) ||
1470 0 : gui->vote_account.vote_accounts[ found_idx ].commission != FD_LOAD( uchar, data+i*112UL+96UL ) ||
1471 0 : gui->vote_account.vote_accounts[ found_idx ].delinquent != FD_LOAD( uchar, data+i*112UL+97UL );
1472 :
1473 0 : if( FD_UNLIKELY( peer_updated ) ) {
1474 0 : updated[ update_cnt++ ] = found_idx;
1475 :
1476 0 : fd_memcpy( gui->vote_account.vote_accounts[ found_idx ].pubkey->uc, data+i*112UL+32UL, 32UL );
1477 0 : gui->vote_account.vote_accounts[ found_idx ].activated_stake = FD_LOAD( ulong, data+i*112UL+64UL );
1478 0 : gui->vote_account.vote_accounts[ found_idx ].last_vote = FD_LOAD( ulong, data+i*112UL+72UL );
1479 0 : gui->vote_account.vote_accounts[ found_idx ].root_slot = FD_LOAD( ulong, data+i*112UL+80UL );
1480 0 : gui->vote_account.vote_accounts[ found_idx ].epoch_credits = FD_LOAD( ulong, data+i*112UL+88UL );
1481 0 : gui->vote_account.vote_accounts[ found_idx ].commission = FD_LOAD( uchar, data+i*112UL+96UL );
1482 0 : gui->vote_account.vote_accounts[ found_idx ].delinquent = FD_LOAD( uchar, data+i*112UL+97UL );
1483 0 : }
1484 0 : }
1485 0 : }
1486 :
1487 0 : added_cnt = gui->vote_account.vote_account_cnt - before_peer_cnt;
1488 0 : for( ulong i=before_peer_cnt; i<gui->vote_account.vote_account_cnt; i++ ) added[ i-before_peer_cnt ] = i;
1489 :
1490 0 : fd_gui_printf_peers_vote_account_update( gui, updated, update_cnt, removed, removed_cnt, added, added_cnt );
1491 0 : fd_http_server_ws_broadcast( gui->http );
1492 0 : }
1493 :
1494 : static void
1495 : fd_gui_handle_validator_info_update( fd_gui_t * gui,
1496 0 : uchar const * msg ) {
1497 0 : if( FD_UNLIKELY( gui->validator_info.info_cnt == FD_GUI_MAX_PEER_CNT ) ) {
1498 0 : FD_LOG_DEBUG(("validator info cnt exceeds 108000 %lu, ignoring additional entries", gui->validator_info.info_cnt ));
1499 0 : return;
1500 0 : }
1501 0 : uchar const * data = (uchar const *)fd_type_pun_const( msg );
1502 :
1503 0 : ulong added_cnt = 0UL;
1504 0 : ulong added[ 1 ] = {0};
1505 :
1506 0 : ulong update_cnt = 0UL;
1507 0 : ulong updated[ 1 ] = {0};
1508 :
1509 0 : ulong removed_cnt = 0UL;
1510 : /* Unlike gossip or vote account updates, validator info messages come
1511 : in as info is discovered, and may contain as little as 1 validator
1512 : per message. Therefore, it doesn't make sense to use the remove
1513 : mechanism. */
1514 :
1515 0 : ulong before_peer_cnt = gui->validator_info.info_cnt;
1516 0 : int found = 0;
1517 0 : ulong found_idx;
1518 0 : for( ulong j=0UL; j<gui->validator_info.info_cnt; j++ ) {
1519 0 : if( FD_UNLIKELY( !memcmp( gui->validator_info.info[ j ].pubkey, data, 32UL ) ) ) {
1520 0 : found_idx = j;
1521 0 : found = 1;
1522 0 : break;
1523 0 : }
1524 0 : }
1525 :
1526 0 : if( FD_UNLIKELY( !found ) ) {
1527 0 : fd_memcpy( gui->validator_info.info[ gui->validator_info.info_cnt ].pubkey->uc, data, 32UL );
1528 :
1529 0 : strncpy( gui->validator_info.info[ gui->validator_info.info_cnt ].name, (char const *)(data+32UL), 64 );
1530 0 : gui->validator_info.info[ gui->validator_info.info_cnt ].name[ 63 ] = '\0';
1531 :
1532 0 : strncpy( gui->validator_info.info[ gui->validator_info.info_cnt ].website, (char const *)(data+96UL), 128 );
1533 0 : gui->validator_info.info[ gui->validator_info.info_cnt ].website[ 127 ] = '\0';
1534 :
1535 0 : strncpy( gui->validator_info.info[ gui->validator_info.info_cnt ].details, (char const *)(data+224UL), 256 );
1536 0 : gui->validator_info.info[ gui->validator_info.info_cnt ].details[ 255 ] = '\0';
1537 :
1538 0 : strncpy( gui->validator_info.info[ gui->validator_info.info_cnt ].icon_uri, (char const *)(data+480UL), 128 );
1539 0 : gui->validator_info.info[ gui->validator_info.info_cnt ].icon_uri[ 127 ] = '\0';
1540 :
1541 0 : gui->validator_info.info_cnt++;
1542 0 : } else {
1543 0 : int peer_updated =
1544 0 : memcmp( gui->validator_info.info[ found_idx ].pubkey->uc, data, 32UL ) ||
1545 0 : strncmp( gui->validator_info.info[ found_idx ].name, (char const *)(data+32UL), 64 ) ||
1546 0 : strncmp( gui->validator_info.info[ found_idx ].website, (char const *)(data+96UL), 128 ) ||
1547 0 : strncmp( gui->validator_info.info[ found_idx ].details, (char const *)(data+224UL), 256 ) ||
1548 0 : strncmp( gui->validator_info.info[ found_idx ].icon_uri, (char const *)(data+480UL), 128 );
1549 :
1550 0 : if( FD_UNLIKELY( peer_updated ) ) {
1551 0 : updated[ update_cnt++ ] = found_idx;
1552 :
1553 0 : fd_memcpy( gui->validator_info.info[ found_idx ].pubkey->uc, data, 32UL );
1554 :
1555 0 : strncpy( gui->validator_info.info[ found_idx ].name, (char const *)(data+32UL), 64 );
1556 0 : gui->validator_info.info[ found_idx ].name[ 63 ] = '\0';
1557 :
1558 0 : strncpy( gui->validator_info.info[ found_idx ].website, (char const *)(data+96UL), 128 );
1559 0 : gui->validator_info.info[ found_idx ].website[ 127 ] = '\0';
1560 :
1561 0 : strncpy( gui->validator_info.info[ found_idx ].details, (char const *)(data+224UL), 256 );
1562 0 : gui->validator_info.info[ found_idx ].details[ 255 ] = '\0';
1563 :
1564 0 : strncpy( gui->validator_info.info[ found_idx ].icon_uri, (char const *)(data+480UL), 128 );
1565 0 : gui->validator_info.info[ found_idx ].icon_uri[ 127 ] = '\0';
1566 0 : }
1567 0 : }
1568 :
1569 0 : added_cnt = gui->validator_info.info_cnt - before_peer_cnt;
1570 0 : for( ulong i=before_peer_cnt; i<gui->validator_info.info_cnt; i++ ) added[ i-before_peer_cnt ] = i;
1571 :
1572 0 : fd_gui_printf_peers_validator_info_update( gui, updated, update_cnt, NULL, removed_cnt, added, added_cnt );
1573 0 : fd_http_server_ws_broadcast( gui->http );
1574 0 : }
1575 :
1576 : int
1577 : fd_gui_request_slot( fd_gui_t * gui,
1578 : ulong ws_conn_id,
1579 : ulong request_id,
1580 0 : cJSON const * params ) {
1581 0 : const cJSON * slot_param = cJSON_GetObjectItemCaseSensitive( params, "slot" );
1582 0 : if( FD_UNLIKELY( !cJSON_IsNumber( slot_param ) ) ) return FD_HTTP_SERVER_CONNECTION_CLOSE_BAD_REQUEST;
1583 :
1584 0 : ulong _slot = slot_param->valueulong;
1585 0 : fd_gui_slot_t const * slot = fd_gui_get_slot_const( gui, _slot );
1586 0 : if( FD_UNLIKELY( !slot ) ) {
1587 0 : fd_gui_printf_null_query_response( gui->http, "slot", "query", request_id );
1588 0 : FD_TEST( !fd_http_server_ws_send( gui->http, ws_conn_id ) );
1589 0 : return 0;
1590 0 : }
1591 :
1592 0 : fd_gui_printf_slot_request( gui, _slot, request_id );
1593 0 : FD_TEST( !fd_http_server_ws_send( gui->http, ws_conn_id ) );
1594 0 : return 0;
1595 0 : }
1596 :
1597 : int
1598 : fd_gui_request_slot_transactions( fd_gui_t * gui,
1599 : ulong ws_conn_id,
1600 : ulong request_id,
1601 0 : cJSON const * params ) {
1602 0 : const cJSON * slot_param = cJSON_GetObjectItemCaseSensitive( params, "slot" );
1603 0 : if( FD_UNLIKELY( !cJSON_IsNumber( slot_param ) ) ) return FD_HTTP_SERVER_CONNECTION_CLOSE_BAD_REQUEST;
1604 :
1605 0 : ulong _slot = slot_param->valueulong;
1606 0 : fd_gui_slot_t const * slot = fd_gui_get_slot_const( gui, _slot );
1607 0 : if( FD_UNLIKELY( !slot ) ) {
1608 0 : fd_gui_printf_null_query_response( gui->http, "slot", "query_transactions", request_id );
1609 0 : FD_TEST( !fd_http_server_ws_send( gui->http, ws_conn_id ) );
1610 0 : return 0;
1611 0 : }
1612 :
1613 0 : fd_gui_printf_slot_transactions_request( gui, _slot, request_id );
1614 0 : FD_TEST( !fd_http_server_ws_send( gui->http, ws_conn_id ) );
1615 0 : return 0;
1616 0 : }
1617 :
1618 : int
1619 : fd_gui_request_slot_detailed( fd_gui_t * gui,
1620 : ulong ws_conn_id,
1621 : ulong request_id,
1622 0 : cJSON const * params ) {
1623 0 : const cJSON * slot_param = cJSON_GetObjectItemCaseSensitive( params, "slot" );
1624 0 : if( FD_UNLIKELY( !cJSON_IsNumber( slot_param ) ) ) return FD_HTTP_SERVER_CONNECTION_CLOSE_BAD_REQUEST;
1625 :
1626 0 : ulong _slot = slot_param->valueulong;
1627 0 : fd_gui_slot_t const * slot = fd_gui_get_slot_const( gui, _slot );
1628 0 : if( FD_UNLIKELY( !slot ) ) {
1629 0 : fd_gui_printf_null_query_response( gui->http, "slot", "query_detailed", request_id );
1630 0 : FD_TEST( !fd_http_server_ws_send( gui->http, ws_conn_id ) );
1631 0 : return 0;
1632 0 : }
1633 :
1634 0 : fd_gui_printf_slot_request_detailed( gui, _slot, request_id );
1635 0 : FD_TEST( !fd_http_server_ws_send( gui->http, ws_conn_id ) );
1636 0 : return 0;
1637 0 : }
1638 :
1639 : static inline ulong
1640 0 : fd_gui_slot_duration( fd_gui_t const * gui, fd_gui_slot_t const * cur ) {
1641 0 : fd_gui_slot_t const * prev = fd_gui_get_slot_const( gui, cur->slot-1UL );
1642 0 : if( FD_UNLIKELY( !prev ||
1643 0 : prev->skipped ||
1644 0 : prev->completed_time == LONG_MAX ||
1645 0 : prev->slot != (cur->slot - 1UL) ||
1646 0 : cur->skipped ||
1647 0 : cur->completed_time == LONG_MAX ) ) return ULONG_MAX;
1648 :
1649 0 : return (ulong)(cur->completed_time - prev->completed_time);
1650 0 : }
1651 :
1652 : /* All rankings are initialized / reset to ULONG_MAX. These sentinels
1653 : sort AFTER non-sentinel ranking entries. Equal slots are sorted by
1654 : oldest slot AFTER. Otherwise sort by value according to ranking
1655 : type. */
1656 : #define SORT_NAME fd_gui_slot_ranking_sort
1657 0 : #define SORT_KEY_T fd_gui_slot_ranking_t
1658 0 : #define SORT_BEFORE(a,b) fd_int_if( (a).slot==ULONG_MAX, 0, fd_int_if( (b).slot==ULONG_MAX, 1, fd_int_if( (a).value==(b).value, (a).slot>(b).slot, fd_int_if( (a).type==FD_GUI_SLOT_RANKING_TYPE_DESC, (a).value>(b).value, (a).value<(b).value ) ) ) )
1659 : #include "../../util/tmpl/fd_sort.c"
1660 :
1661 : static inline void
1662 : fd_gui_try_insert_ranking( fd_gui_t * gui,
1663 : fd_gui_slot_rankings_t * rankings,
1664 0 : fd_gui_slot_t const * slot ) {
1665 : /* Rankings are inserted into an extra slot at the end of the ranking
1666 : array, then the array is sorted. */
1667 0 : #define TRY_INSERT_SLOT( ranking_name, ranking_slot, ranking_value ) \
1668 0 : do { \
1669 0 : rankings->FD_CONCAT2(largest_, ranking_name) [ FD_GUI_SLOT_RANKINGS_SZ ] = (fd_gui_slot_ranking_t){ .slot = (ranking_slot), .value = (ranking_value), .type = FD_GUI_SLOT_RANKING_TYPE_DESC }; \
1670 0 : fd_gui_slot_ranking_sort_insert( rankings->FD_CONCAT2(largest_, ranking_name), FD_GUI_SLOT_RANKINGS_SZ+1UL ); \
1671 0 : rankings->FD_CONCAT2(smallest_, ranking_name)[ FD_GUI_SLOT_RANKINGS_SZ ] = (fd_gui_slot_ranking_t){ .slot = (ranking_slot), .value = (ranking_value), .type = FD_GUI_SLOT_RANKING_TYPE_ASC }; \
1672 0 : fd_gui_slot_ranking_sort_insert( rankings->FD_CONCAT2(smallest_, ranking_name), FD_GUI_SLOT_RANKINGS_SZ+1UL ); \
1673 0 : } while (0)
1674 :
1675 0 : if( slot->skipped ) {
1676 0 : TRY_INSERT_SLOT( skipped, slot->slot, slot->slot );
1677 0 : return;
1678 0 : }
1679 :
1680 0 : ulong dur = fd_gui_slot_duration( gui, slot );
1681 0 : if( FD_LIKELY( dur!=ULONG_MAX ) ) TRY_INSERT_SLOT( duration, slot->slot, dur );
1682 0 : TRY_INSERT_SLOT( tips, slot->slot, slot->tips );
1683 0 : TRY_INSERT_SLOT( fees, slot->slot, slot->priority_fee + slot->transaction_fee );
1684 0 : TRY_INSERT_SLOT( rewards, slot->slot, slot->tips + slot->priority_fee + slot->transaction_fee );
1685 0 : TRY_INSERT_SLOT( rewards_per_cu, slot->slot, slot->compute_units==0UL ? 0UL : (slot->tips + slot->priority_fee + slot->transaction_fee) / slot->compute_units );
1686 0 : TRY_INSERT_SLOT( compute_units, slot->slot, slot->compute_units );
1687 0 : #undef TRY_INSERT_SLOT
1688 0 : }
1689 :
1690 : static void
1691 0 : fd_gui_update_slot_rankings( fd_gui_t * gui ) {
1692 0 : ulong first_replay_slot = ULONG_MAX;
1693 0 : if( FD_LIKELY( gui->summary.is_full_client ) ) {
1694 0 : ulong slot_caught_up = gui->summary.slot_caught_up;
1695 0 : ulong slot_incremental = gui->summary.boot_progress.loading_snapshot[ FD_GUI_BOOT_PROGRESS_INCREMENTAL_SNAPSHOT_IDX ].slot;
1696 0 : ulong slot_full = gui->summary.boot_progress.loading_snapshot[ FD_GUI_BOOT_PROGRESS_FULL_SNAPSHOT_IDX ].slot;
1697 0 : first_replay_slot = fd_ulong_if( slot_caught_up!=ULONG_MAX, fd_ulong_if( slot_incremental!=ULONG_MAX, slot_incremental+1UL, fd_ulong_if( slot_full!=ULONG_MAX, slot_full+1UL, ULONG_MAX ) ), ULONG_MAX );
1698 0 : } else {
1699 0 : first_replay_slot = gui->summary.startup_progress.startup_ledger_max_slot;
1700 0 : }
1701 0 : if( FD_UNLIKELY( first_replay_slot==ULONG_MAX ) ) return;
1702 0 : if( FD_UNLIKELY( gui->summary.slot_rooted ==ULONG_MAX ) ) return;
1703 :
1704 0 : ulong epoch_idx = fd_gui_current_epoch_idx( gui );
1705 0 : if( FD_UNLIKELY( epoch_idx==ULONG_MAX ) ) return;
1706 :
1707 : /* No new slots since the last update */
1708 0 : if( FD_UNLIKELY( gui->epoch.epochs[ epoch_idx ].rankings_slot>gui->summary.slot_rooted ) ) return;
1709 :
1710 : /* Slots before first_replay_slot are unavailable. */
1711 0 : gui->epoch.epochs[ epoch_idx ].rankings_slot = fd_ulong_max( gui->epoch.epochs[ epoch_idx ].rankings_slot, first_replay_slot );
1712 :
1713 : /* Update the rankings. Only look through slots we haven't already. */
1714 0 : for( ulong s = gui->summary.slot_rooted; s>=gui->epoch.epochs[ epoch_idx ].rankings_slot; s--) {
1715 0 : fd_gui_slot_t const * slot = fd_gui_get_slot_const( gui, s );
1716 0 : if( FD_UNLIKELY( !slot ) ) break;
1717 :
1718 0 : fd_gui_try_insert_ranking( gui, gui->epoch.epochs[ epoch_idx ].rankings, slot );
1719 0 : if( FD_UNLIKELY( slot->mine ) ) fd_gui_try_insert_ranking( gui, gui->epoch.epochs[ epoch_idx ].my_rankings, slot );
1720 0 : }
1721 :
1722 0 : gui->epoch.epochs[ epoch_idx ].rankings_slot = gui->summary.slot_rooted + 1UL;
1723 0 : }
1724 :
1725 : int
1726 : fd_gui_request_slot_rankings( fd_gui_t * gui,
1727 : ulong ws_conn_id,
1728 : ulong request_id,
1729 0 : cJSON const * params ) {
1730 0 : const cJSON * slot_param = cJSON_GetObjectItemCaseSensitive( params, "mine" );
1731 0 : if( FD_UNLIKELY( !cJSON_IsBool( slot_param ) ) ) return FD_HTTP_SERVER_CONNECTION_CLOSE_BAD_REQUEST;
1732 :
1733 0 : int mine = !!(slot_param->type & cJSON_True);
1734 0 : fd_gui_update_slot_rankings( gui );
1735 0 : fd_gui_printf_slot_rankings_request( gui, request_id, mine );
1736 0 : FD_TEST( !fd_http_server_ws_send( gui->http, ws_conn_id ) );
1737 0 : return 0;
1738 0 : }
1739 :
1740 : int
1741 : fd_gui_request_slot_shreds( fd_gui_t * gui,
1742 : ulong ws_conn_id,
1743 : ulong request_id,
1744 0 : cJSON const * params ) {
1745 0 : const cJSON * slot_param = cJSON_GetObjectItemCaseSensitive( params, "slot" );
1746 0 : if( FD_UNLIKELY( !cJSON_IsNumber( slot_param ) ) ) return FD_HTTP_SERVER_CONNECTION_CLOSE_BAD_REQUEST;
1747 :
1748 0 : ulong _slot = slot_param->valueulong;
1749 :
1750 0 : fd_gui_slot_t const * slot = fd_gui_get_slot_const( gui, _slot );
1751 0 : if( FD_UNLIKELY( !slot || slot->shreds.start_offset==ULONG_MAX || slot->shreds.end_offset==ULONG_MAX || gui->shreds.history_tail >= slot->shreds.end_offset + FD_GUI_SHREDS_HISTORY_SZ ) ) {
1752 0 : fd_gui_printf_null_query_response( gui->http, "slot", "query_shreds", request_id );
1753 0 : FD_TEST( !fd_http_server_ws_send( gui->http, ws_conn_id ) );
1754 0 : return 0;
1755 0 : }
1756 :
1757 0 : fd_gui_printf_slot_query_shreds( gui, _slot, request_id );
1758 0 : FD_TEST( !fd_http_server_ws_send( gui->http, ws_conn_id ) );
1759 0 : return 0;
1760 0 : }
1761 :
1762 : int
1763 : fd_gui_ws_message( fd_gui_t * gui,
1764 : ulong ws_conn_id,
1765 : uchar const * data,
1766 0 : ulong data_len ) {
1767 : /* TODO: cJSON allocates, might fail SIGSYS due to brk(2)...
1768 : switch off this (or use wksp allocator) */
1769 0 : const char * parse_end;
1770 0 : cJSON * json = cJSON_ParseWithLengthOpts( (char *)data, data_len, &parse_end, 0 );
1771 0 : if( FD_UNLIKELY( !json ) ) {
1772 0 : return FD_HTTP_SERVER_CONNECTION_CLOSE_BAD_REQUEST;
1773 0 : }
1774 :
1775 0 : const cJSON * node = cJSON_GetObjectItemCaseSensitive( json, "id" );
1776 0 : if( FD_UNLIKELY( !cJSON_IsNumber( node ) ) ) {
1777 0 : cJSON_Delete( json );
1778 0 : return FD_HTTP_SERVER_CONNECTION_CLOSE_BAD_REQUEST;
1779 0 : }
1780 0 : ulong id = node->valueulong;
1781 :
1782 0 : const cJSON * topic = cJSON_GetObjectItemCaseSensitive( json, "topic" );
1783 0 : if( FD_UNLIKELY( !cJSON_IsString( topic ) || topic->valuestring==NULL ) ) {
1784 0 : cJSON_Delete( json );
1785 0 : return FD_HTTP_SERVER_CONNECTION_CLOSE_BAD_REQUEST;
1786 0 : }
1787 :
1788 0 : const cJSON * key = cJSON_GetObjectItemCaseSensitive( json, "key" );
1789 0 : if( FD_UNLIKELY( !cJSON_IsString( key ) || key->valuestring==NULL ) ) {
1790 0 : cJSON_Delete( json );
1791 0 : return FD_HTTP_SERVER_CONNECTION_CLOSE_BAD_REQUEST;
1792 0 : }
1793 :
1794 0 : if( FD_LIKELY( !strcmp( topic->valuestring, "slot" ) && !strcmp( key->valuestring, "query" ) ) ) {
1795 0 : const cJSON * params = cJSON_GetObjectItemCaseSensitive( json, "params" );
1796 0 : if( FD_UNLIKELY( !cJSON_IsObject( params ) ) ) {
1797 0 : cJSON_Delete( json );
1798 0 : return FD_HTTP_SERVER_CONNECTION_CLOSE_BAD_REQUEST;
1799 0 : }
1800 :
1801 0 : int result = fd_gui_request_slot( gui, ws_conn_id, id, params );
1802 0 : cJSON_Delete( json );
1803 0 : return result;
1804 0 : } else if( FD_LIKELY( !strcmp( topic->valuestring, "slot" ) && !strcmp( key->valuestring, "query_detailed" ) ) ) {
1805 0 : const cJSON * params = cJSON_GetObjectItemCaseSensitive( json, "params" );
1806 0 : if( FD_UNLIKELY( !cJSON_IsObject( params ) ) ) {
1807 0 : cJSON_Delete( json );
1808 0 : return FD_HTTP_SERVER_CONNECTION_CLOSE_BAD_REQUEST;
1809 0 : }
1810 :
1811 0 : int result = fd_gui_request_slot_detailed( gui, ws_conn_id, id, params );
1812 0 : cJSON_Delete( json );
1813 0 : return result;
1814 0 : } else if( FD_LIKELY( !strcmp( topic->valuestring, "slot" ) && !strcmp( key->valuestring, "query_transactions" ) ) ) {
1815 0 : const cJSON * params = cJSON_GetObjectItemCaseSensitive( json, "params" );
1816 0 : if( FD_UNLIKELY( !cJSON_IsObject( params ) ) ) {
1817 0 : cJSON_Delete( json );
1818 0 : return FD_HTTP_SERVER_CONNECTION_CLOSE_BAD_REQUEST;
1819 0 : }
1820 :
1821 0 : int result = fd_gui_request_slot_transactions( gui, ws_conn_id, id, params );
1822 0 : cJSON_Delete( json );
1823 0 : return result;
1824 0 : } else if( FD_LIKELY( !strcmp( topic->valuestring, "slot" ) && !strcmp( key->valuestring, "query_rankings" ) ) ) {
1825 0 : const cJSON * params = cJSON_GetObjectItemCaseSensitive( json, "params" );
1826 0 : if( FD_UNLIKELY( !cJSON_IsObject( params ) ) ) {
1827 0 : cJSON_Delete( json );
1828 0 : return FD_HTTP_SERVER_CONNECTION_CLOSE_BAD_REQUEST;
1829 0 : }
1830 :
1831 0 : int result = fd_gui_request_slot_rankings( gui, ws_conn_id, id, params );
1832 0 : cJSON_Delete( json );
1833 0 : return result;
1834 0 : } else if( FD_LIKELY( !strcmp( topic->valuestring, "slot" ) && !strcmp( key->valuestring, "query_shreds" ) ) ) {
1835 0 : const cJSON * params = cJSON_GetObjectItemCaseSensitive( json, "params" );
1836 0 : if( FD_UNLIKELY( !cJSON_IsObject( params ) ) ) {
1837 0 : cJSON_Delete( json );
1838 0 : return FD_HTTP_SERVER_CONNECTION_CLOSE_BAD_REQUEST;
1839 0 : }
1840 :
1841 0 : int result = fd_gui_request_slot_shreds( gui, ws_conn_id, id, params );
1842 0 : cJSON_Delete( json );
1843 0 : return result;
1844 0 : } else if( FD_LIKELY( !strcmp( topic->valuestring, "summary" ) && !strcmp( key->valuestring, "ping" ) ) ) {
1845 0 : fd_gui_printf_summary_ping( gui, id );
1846 0 : FD_TEST( !fd_http_server_ws_send( gui->http, ws_conn_id ) );
1847 :
1848 0 : cJSON_Delete( json );
1849 0 : return 0;
1850 0 : }
1851 :
1852 0 : cJSON_Delete( json );
1853 0 : return FD_HTTP_SERVER_CONNECTION_CLOSE_UNKNOWN_METHOD;
1854 0 : }
1855 :
1856 : static fd_gui_slot_t *
1857 : fd_gui_clear_slot( fd_gui_t * gui,
1858 : ulong _slot,
1859 0 : ulong _parent_slot ) {
1860 0 : fd_gui_slot_t * slot = gui->slots[ _slot % FD_GUI_SLOTS_CNT ];
1861 :
1862 0 : int mine = 0;
1863 0 : ulong epoch_idx = 0UL;
1864 0 : for( ulong i=0UL; i<2UL; i++) {
1865 0 : if( FD_UNLIKELY( !gui->epoch.has_epoch[ i ] ) ) continue;
1866 0 : if( FD_LIKELY( _slot>=gui->epoch.epochs[ i ].start_slot && _slot<=gui->epoch.epochs[ i ].end_slot ) ) {
1867 0 : fd_pubkey_t const * slot_leader = fd_epoch_leaders_get( gui->epoch.epochs[ i ].lsched, _slot );
1868 0 : mine = !memcmp( slot_leader->uc, gui->summary.identity_key->uc, 32UL );
1869 0 : epoch_idx = i;
1870 0 : break;
1871 0 : }
1872 0 : }
1873 :
1874 0 : slot->slot = _slot;
1875 0 : slot->parent_slot = _parent_slot;
1876 0 : slot->vote_slot = ULONG_MAX;
1877 0 : slot->vote_latency = UCHAR_MAX;
1878 0 : slot->reset_slot = ULONG_MAX;
1879 0 : slot->max_compute_units = UINT_MAX;
1880 0 : slot->completed_time = LONG_MAX;
1881 0 : slot->mine = mine;
1882 0 : slot->skipped = 0;
1883 0 : slot->must_republish = 1;
1884 0 : slot->level = FD_GUI_SLOT_LEVEL_INCOMPLETE;
1885 0 : slot->vote_failed = UINT_MAX;
1886 0 : slot->vote_success = UINT_MAX;
1887 0 : slot->nonvote_success = UINT_MAX;
1888 0 : slot->nonvote_failed = UINT_MAX;
1889 0 : slot->compute_units = UINT_MAX;
1890 0 : slot->transaction_fee = ULONG_MAX;
1891 0 : slot->priority_fee = ULONG_MAX;
1892 0 : slot->tips = ULONG_MAX;
1893 0 : slot->shred_cnt = UINT_MAX;
1894 0 : slot->shreds.start_offset = ULONG_MAX;
1895 0 : slot->shreds.end_offset = ULONG_MAX;
1896 :
1897 0 : if( FD_LIKELY( slot->mine ) ) {
1898 : /* All slots start off not skipped, until we see it get off the reset
1899 : chain. */
1900 0 : gui->epoch.epochs[ epoch_idx ].my_total_slots++;
1901 :
1902 0 : slot->leader_history_idx = gui->leader_slots_cnt++;
1903 0 : fd_gui_leader_slot_t * lslot = gui->leader_slots[ slot->leader_history_idx % FD_GUI_LEADER_CNT ];
1904 :
1905 0 : lslot->slot = _slot;
1906 0 : memset( lslot->block_hash.uc, 0, sizeof(fd_hash_t) );
1907 0 : lslot->leader_start_time = LONG_MAX;
1908 0 : lslot->leader_end_time = LONG_MAX;
1909 0 : lslot->tile_timers_sample_cnt = 0UL;
1910 0 : lslot->scheduler_counts_sample_cnt = 0UL;
1911 0 : lslot->txs.microblocks_upper_bound = UINT_MAX;
1912 0 : lslot->txs.begin_microblocks = 0U;
1913 0 : lslot->txs.end_microblocks = 0U;
1914 0 : lslot->txs.start_offset = ULONG_MAX;
1915 0 : lslot->txs.end_offset = ULONG_MAX;
1916 0 : lslot->max_microblocks = ULONG_MAX;
1917 0 : lslot->unbecame_leader = 0;
1918 0 : }
1919 :
1920 0 : if( FD_UNLIKELY( !_slot ) ) {
1921 : /* Slot 0 is always rooted */
1922 0 : slot->level = FD_GUI_SLOT_LEVEL_ROOTED;
1923 0 : }
1924 :
1925 0 : return slot;
1926 0 : }
1927 :
1928 : void
1929 : fd_gui_handle_leader_schedule( fd_gui_t * gui,
1930 : fd_stake_weight_msg_t const * leader_schedule,
1931 0 : long now ) {
1932 0 : FD_TEST( leader_schedule->staked_vote_cnt<=MAX_STAKED_LEADERS );
1933 0 : FD_TEST( leader_schedule->slot_cnt<=MAX_SLOTS_PER_EPOCH );
1934 :
1935 0 : ulong idx = leader_schedule->epoch % 2UL;
1936 0 : gui->epoch.has_epoch[ idx ] = 1;
1937 :
1938 0 : gui->epoch.epochs[ idx ].epoch = leader_schedule->epoch;
1939 0 : gui->epoch.epochs[ idx ].start_slot = leader_schedule->start_slot;
1940 0 : gui->epoch.epochs[ idx ].end_slot = leader_schedule->start_slot + leader_schedule->slot_cnt - 1; // end_slot is inclusive.
1941 0 : gui->epoch.epochs[ idx ].my_total_slots = 0UL;
1942 0 : gui->epoch.epochs[ idx ].my_skipped_slots = 0UL;
1943 :
1944 0 : memset( gui->epoch.epochs[ idx ].rankings, (int)(UINT_MAX), sizeof(gui->epoch.epochs[ idx ].rankings) );
1945 0 : memset( gui->epoch.epochs[ idx ].my_rankings, (int)(UINT_MAX), sizeof(gui->epoch.epochs[ idx ].my_rankings) );
1946 :
1947 0 : gui->epoch.epochs[ idx ].rankings_slot = leader_schedule->start_slot;
1948 :
1949 0 : fd_vote_stake_weight_t const * stake_weights = fd_stake_weight_msg_stake_weights( leader_schedule );
1950 0 : fd_memcpy( gui->epoch.epochs[ idx ].stakes, stake_weights, leader_schedule->staked_vote_cnt*sizeof(fd_vote_stake_weight_t) );
1951 :
1952 0 : fd_epoch_leaders_delete( fd_epoch_leaders_leave( gui->epoch.epochs[ idx ].lsched ) );
1953 0 : gui->epoch.epochs[idx].lsched = fd_epoch_leaders_join( fd_epoch_leaders_new( gui->epoch.epochs[ idx ]._lsched,
1954 0 : leader_schedule->epoch,
1955 0 : gui->epoch.epochs[ idx ].start_slot,
1956 0 : leader_schedule->slot_cnt,
1957 0 : leader_schedule->staked_vote_cnt,
1958 0 : gui->epoch.epochs[ idx ].stakes,
1959 0 : 0UL ) );
1960 :
1961 0 : if( FD_UNLIKELY( leader_schedule->start_slot==0UL ) ) {
1962 0 : gui->epoch.epochs[ 0 ].start_time = now;
1963 0 : } else {
1964 0 : gui->epoch.epochs[ idx ].start_time = LONG_MAX;
1965 :
1966 0 : for( ulong i=0UL; i<fd_ulong_min( leader_schedule->start_slot-1UL, FD_GUI_SLOTS_CNT ); i++ ) {
1967 0 : fd_gui_slot_t const * slot = fd_gui_get_slot_const( gui, leader_schedule->start_slot-i );
1968 0 : if( FD_UNLIKELY( !slot ) ) break;
1969 0 : else if( FD_UNLIKELY( slot->skipped ) ) continue;
1970 :
1971 0 : gui->epoch.epochs[ idx ].start_time = slot->completed_time;
1972 0 : break;
1973 0 : }
1974 0 : }
1975 :
1976 0 : fd_gui_printf_epoch( gui, idx );
1977 0 : fd_http_server_ws_broadcast( gui->http );
1978 0 : }
1979 :
1980 : void
1981 : fd_gui_handle_epoch_info( fd_gui_t * gui,
1982 : fd_epoch_info_msg_t const * epoch_info,
1983 0 : long now ) {
1984 0 : FD_TEST( epoch_info->staked_vote_cnt<=MAX_COMPRESSED_STAKE_WEIGHTS );
1985 0 : FD_TEST( epoch_info->slot_cnt<=MAX_SLOTS_PER_EPOCH );
1986 :
1987 0 : ulong idx = epoch_info->epoch % 2UL;
1988 0 : gui->epoch.has_epoch[ idx ] = 1;
1989 :
1990 0 : gui->epoch.epochs[ idx ].epoch = epoch_info->epoch;
1991 0 : gui->epoch.epochs[ idx ].start_slot = epoch_info->start_slot;
1992 0 : gui->epoch.epochs[ idx ].end_slot = epoch_info->start_slot + epoch_info->slot_cnt - 1; // end_slot is inclusive.
1993 0 : gui->epoch.epochs[ idx ].my_total_slots = 0UL;
1994 0 : gui->epoch.epochs[ idx ].my_skipped_slots = 0UL;
1995 :
1996 0 : memset( gui->epoch.epochs[ idx ].rankings, (int)(UINT_MAX), sizeof(gui->epoch.epochs[ idx ].rankings) );
1997 0 : memset( gui->epoch.epochs[ idx ].my_rankings, (int)(UINT_MAX), sizeof(gui->epoch.epochs[ idx ].my_rankings) );
1998 :
1999 0 : gui->epoch.epochs[ idx ].rankings_slot = epoch_info->start_slot;
2000 :
2001 0 : fd_vote_stake_weight_t const * stake_weights = fd_epoch_info_msg_stake_weights( epoch_info );
2002 0 : fd_memcpy( gui->epoch.epochs[ idx ].stakes, stake_weights, epoch_info->staked_vote_cnt*sizeof(fd_vote_stake_weight_t) );
2003 :
2004 0 : fd_epoch_leaders_delete( fd_epoch_leaders_leave( gui->epoch.epochs[ idx ].lsched ) );
2005 0 : gui->epoch.epochs[idx].lsched = fd_epoch_leaders_join( fd_epoch_leaders_new( gui->epoch.epochs[ idx ]._lsched,
2006 0 : epoch_info->epoch,
2007 0 : gui->epoch.epochs[ idx ].start_slot,
2008 0 : epoch_info->slot_cnt,
2009 0 : epoch_info->staked_vote_cnt,
2010 0 : gui->epoch.epochs[ idx ].stakes,
2011 0 : 0UL ) );
2012 :
2013 0 : if( FD_UNLIKELY( epoch_info->start_slot==0UL ) ) {
2014 0 : gui->epoch.epochs[ 0 ].start_time = now;
2015 0 : } else {
2016 0 : gui->epoch.epochs[ idx ].start_time = LONG_MAX;
2017 :
2018 0 : for( ulong i=0UL; i<fd_ulong_min( epoch_info->start_slot-1UL, FD_GUI_SLOTS_CNT ); i++ ) {
2019 0 : fd_gui_slot_t const * slot = fd_gui_get_slot_const( gui, epoch_info->start_slot-i );
2020 0 : if( FD_UNLIKELY( !slot ) ) break;
2021 0 : else if( FD_UNLIKELY( slot->skipped ) ) continue;
2022 :
2023 0 : gui->epoch.epochs[ idx ].start_time = slot->completed_time;
2024 0 : break;
2025 0 : }
2026 0 : }
2027 :
2028 0 : fd_gui_printf_epoch( gui, idx );
2029 0 : fd_http_server_ws_broadcast( gui->http );
2030 0 : }
2031 :
2032 : static void
2033 : fd_gui_handle_slot_start( fd_gui_t * gui,
2034 : ulong _slot,
2035 : ulong parent_slot,
2036 0 : long now ) {
2037 0 : FD_TEST( gui->leader_slot==ULONG_MAX );
2038 0 : gui->leader_slot = _slot;
2039 :
2040 0 : fd_gui_slot_t * slot = fd_gui_get_slot( gui, _slot );
2041 0 : if( FD_UNLIKELY( !slot ) ) slot = fd_gui_clear_slot( gui, _slot, parent_slot );
2042 :
2043 0 : fd_gui_tile_timers_snap( gui );
2044 0 : gui->summary.tile_timers_snap_idx_slot_start = (gui->summary.tile_timers_snap_idx+(FD_GUI_TILE_TIMER_SNAP_CNT-1UL))%FD_GUI_TILE_TIMER_SNAP_CNT;
2045 :
2046 0 : fd_gui_scheduler_counts_snap( gui, now );
2047 0 : gui->summary.scheduler_counts_snap_idx_slot_start = (gui->summary.scheduler_counts_snap_idx+(FD_GUI_SCHEDULER_COUNT_SNAP_CNT-1UL))%FD_GUI_SCHEDULER_COUNT_SNAP_CNT;
2048 :
2049 0 : fd_gui_txn_waterfall_t waterfall[ 1 ];
2050 0 : fd_gui_txn_waterfall_snap( gui, waterfall );
2051 0 : fd_gui_tile_stats_snap( gui, waterfall, slot->tile_stats_begin, now );
2052 0 : }
2053 :
2054 : static void
2055 : fd_gui_handle_slot_end( fd_gui_t * gui,
2056 : ulong _slot,
2057 : ulong _cus_used,
2058 0 : long now ) {
2059 0 : if( FD_UNLIKELY( !gui->summary.is_full_client && gui->leader_slot!=_slot ) ) {
2060 0 : FD_LOG_ERR(( "gui->leader_slot %lu _slot %lu", gui->leader_slot, _slot ));
2061 0 : }
2062 0 : gui->leader_slot = ULONG_MAX;
2063 :
2064 0 : fd_gui_slot_t * slot = fd_gui_get_slot( gui, _slot );
2065 0 : if( FD_UNLIKELY( !slot ) ) return;
2066 :
2067 0 : if( FD_UNLIKELY( !gui->summary.is_full_client ) ) slot->compute_units = (uint)_cus_used;
2068 :
2069 0 : fd_gui_tile_timers_snap( gui );
2070 :
2071 0 : fd_gui_scheduler_counts_snap( gui, now );
2072 :
2073 0 : fd_gui_leader_slot_t * lslot = fd_gui_get_leader_slot( gui, _slot );
2074 0 : if( FD_LIKELY( lslot ) ) {
2075 0 : fd_rng_t rng[ 1 ];
2076 0 : fd_rng_new( rng, 0UL, 0UL);
2077 :
2078 0 : #define DOWNSAMPLE( a, a_start, a_end, a_capacity, b, b_sz, stride ) (__extension__({ \
2079 0 : ulong __cnt = 0UL; \
2080 0 : ulong __rsz = (stride); \
2081 0 : ulong __a_sz = (fd_ulong_if( a_end<a_start, a_end+a_capacity, a_end )-a_start); \
2082 0 : if( FD_UNLIKELY( __a_sz && b_sz ) ) { \
2083 0 : for( ulong a_idx=0UL; a_idx<__a_sz && __cnt<b_sz; a_idx++ ) { \
2084 0 : if( FD_UNLIKELY( fd_rng_float_robust( rng ) > (float)(b_sz-__cnt) / (float)(__a_sz-__cnt) ) ) continue; \
2085 0 : fd_memcpy( (b) + __cnt * __rsz, (a) + ((a_start+a_idx)%a_capacity) * __rsz, __rsz * sizeof(*(b)) ); \
2086 0 : __cnt++; \
2087 0 : } \
2088 0 : } \
2089 0 : __cnt; }))
2090 :
2091 0 : lslot->tile_timers_sample_cnt = DOWNSAMPLE(
2092 0 : gui->summary.tile_timers_snap,
2093 0 : gui->summary.tile_timers_snap_idx_slot_start,
2094 0 : gui->summary.tile_timers_snap_idx,
2095 0 : FD_GUI_TILE_TIMER_SNAP_CNT,
2096 0 : lslot->tile_timers,
2097 0 : FD_GUI_TILE_TIMER_LEADER_DOWNSAMPLE_CNT,
2098 0 : gui->tile_cnt );
2099 :
2100 0 : lslot->scheduler_counts_sample_cnt = DOWNSAMPLE(
2101 0 : gui->summary.scheduler_counts_snap,
2102 0 : gui->summary.scheduler_counts_snap_idx_slot_start,
2103 0 : gui->summary.scheduler_counts_snap_idx,
2104 0 : FD_GUI_SCHEDULER_COUNT_SNAP_CNT,
2105 0 : lslot->scheduler_counts,
2106 0 : FD_GUI_SCHEDULER_COUNT_LEADER_DOWNSAMPLE_CNT,
2107 0 : 1UL );
2108 0 : #undef DOWNSAMPLE
2109 0 : }
2110 :
2111 : /* When a slot ends, snap the state of the waterfall and save it into
2112 : that slot, and also reset the reference counters to the end of the
2113 : slot. */
2114 :
2115 0 : fd_gui_txn_waterfall_snap( gui, slot->waterfall_end );
2116 0 : memcpy( slot->waterfall_begin, gui->summary.txn_waterfall_reference, sizeof(slot->waterfall_begin) );
2117 0 : memcpy( gui->summary.txn_waterfall_reference, slot->waterfall_end, sizeof(gui->summary.txn_waterfall_reference) );
2118 :
2119 0 : fd_gui_tile_stats_snap( gui, slot->waterfall_end, slot->tile_stats_end, now );
2120 0 : }
2121 :
2122 : void
2123 : fd_gui_handle_shred( fd_gui_t * gui,
2124 : ulong slot,
2125 : ulong shred_idx,
2126 : int is_turbine,
2127 0 : long tsorig ) {
2128 0 : int was_sent = fd_gui_ephemeral_slots_contains( gui->summary.slots_max_turbine, FD_GUI_TURBINE_SLOT_HISTORY_SZ, slot );
2129 0 : if( FD_LIKELY( is_turbine ) ) fd_gui_try_insert_ephemeral_slot( gui->summary.slots_max_turbine, FD_GUI_TURBINE_SLOT_HISTORY_SZ, slot, tsorig );
2130 :
2131 : /* If we haven't caught up yet, update repair slot using received
2132 : shreds. This is not technically correct, but close enough and will
2133 : make the progress bar look correct. */
2134 0 : if( FD_UNLIKELY( !is_turbine && gui->summary.slot_caught_up==ULONG_MAX ) ) fd_gui_handle_repair_slot( gui, slot, tsorig );
2135 :
2136 0 : if( FD_UNLIKELY( !was_sent && is_turbine && slot!=gui->summary.slot_turbine ) ) {
2137 0 : gui->summary.slot_turbine = slot;
2138 :
2139 0 : fd_gui_printf_turbine_slot( gui );
2140 0 : fd_http_server_ws_broadcast( gui->http );
2141 :
2142 0 : gui->turbine_slots[ slot % FD_GUI_TURBINE_RECV_TIMESTAMPS ].slot = slot;
2143 0 : gui->turbine_slots[ slot % FD_GUI_TURBINE_RECV_TIMESTAMPS ].timestamp = tsorig;
2144 :
2145 0 : ulong duration_sum = 0UL;
2146 0 : ulong slot_cnt = 0UL;
2147 :
2148 0 : for( ulong i=0UL; i<FD_GUI_TURBINE_RECV_TIMESTAMPS; i++ ) {
2149 0 : fd_gui_turbine_slot_t * cur = &gui->turbine_slots[ i ];
2150 0 : fd_gui_turbine_slot_t * prev = &gui->turbine_slots[ (i+FD_GUI_TURBINE_RECV_TIMESTAMPS-1UL) % FD_GUI_TURBINE_RECV_TIMESTAMPS ];
2151 0 : if( FD_UNLIKELY( cur->slot==ULONG_MAX || prev->slot==ULONG_MAX || cur->slot!=prev->slot+1UL ) ) continue;
2152 :
2153 0 : long slot_duration = cur->timestamp - prev->timestamp;
2154 0 : duration_sum += (ulong)fd_long_max( slot_duration, 0UL );
2155 0 : slot_cnt++;
2156 0 : }
2157 :
2158 0 : if( FD_LIKELY( slot_cnt>0 ) ) {
2159 0 : gui->summary.estimated_slot_duration_nanos = (ulong)(duration_sum / slot_cnt);
2160 0 : fd_gui_printf_estimated_slot_duration_nanos( gui );
2161 0 : fd_http_server_ws_broadcast( gui->http );
2162 0 : }
2163 :
2164 0 : if( FD_UNLIKELY( gui->summary.slot_caught_up==ULONG_MAX ) ) fd_gui_try_insert_run_length_slot( gui->summary.catch_up_turbine, FD_GUI_TURBINE_CATCH_UP_HISTORY_SZ, &gui->summary.catch_up_turbine_sz, slot );
2165 0 : }
2166 :
2167 0 : fd_gui_slot_staged_shred_event_t * recv_event = fd_gui_staged_push( gui );
2168 0 : recv_event->timestamp = tsorig;
2169 0 : recv_event->shred_idx = (ushort)shred_idx;
2170 0 : recv_event->slot = slot;
2171 0 : recv_event->event = fd_uchar_if( is_turbine, FD_GUI_SLOT_SHRED_SHRED_RECEIVED_TURBINE, FD_GUI_SLOT_SHRED_SHRED_RECEIVED_REPAIR );
2172 0 : }
2173 :
2174 : void
2175 : fd_gui_handle_leader_fec( fd_gui_t * gui,
2176 : ulong slot,
2177 : ulong fec_shred_cnt,
2178 : int is_end_of_slot,
2179 0 : long tsorig ) {
2180 0 : for( ulong i=gui->shreds.leader_shred_cnt; i<gui->shreds.leader_shred_cnt+fec_shred_cnt; i++ ) {
2181 0 : fd_gui_slot_staged_shred_event_t * exec_end_event = fd_gui_staged_push( gui );
2182 0 : exec_end_event->timestamp = tsorig;
2183 0 : exec_end_event->shred_idx = (ushort)i;
2184 0 : exec_end_event->slot = slot;
2185 0 : exec_end_event->event = FD_GUI_SLOT_SHRED_SHRED_PUBLISHED;
2186 0 : }
2187 0 : gui->shreds.leader_shred_cnt += fec_shred_cnt;
2188 0 : if( FD_UNLIKELY( is_end_of_slot ) ) gui->shreds.leader_shred_cnt = 0UL;
2189 0 : }
2190 :
2191 : void
2192 : fd_gui_handle_exec_txn_done( fd_gui_t * gui,
2193 : ulong slot,
2194 : ulong start_shred_idx,
2195 : ulong end_shred_idx,
2196 : long tsorig_ns FD_PARAM_UNUSED,
2197 0 : long tspub_ns ) {
2198 0 : for( ulong i = start_shred_idx; i<end_shred_idx; i++ ) {
2199 : /*
2200 : We're leaving this state transition out due to its proximity to
2201 : FD_GUI_SLOT_SHRED_SHRED_REPLAY_EXEC_DONE, but if we ever wanted
2202 : to send this data to the frontend we could.
2203 :
2204 : fd_gui_slot_staged_shred_event_t * exec_start_event = &gui->shreds.staged[ gui->shreds.staged_tail % FD_GUI_SHREDS_STAGING_SZ ];
2205 : gui->shreds.staged_tail++;
2206 : exec_start_event->timestamp = tsorig_ns;
2207 : exec_start_event->shred_idx = (ushort)i;
2208 : exec_start_event->slot = slot;
2209 : exec_start_event->event = FD_GUI_SLOT_SHRED_SHRED_REPLAY_EXEC_START;
2210 : */
2211 :
2212 0 : fd_gui_slot_staged_shred_event_t * exec_end_event = fd_gui_staged_push( gui );
2213 0 : exec_end_event->timestamp = tspub_ns;
2214 0 : exec_end_event->shred_idx = (ushort)i;
2215 0 : exec_end_event->slot = slot;
2216 0 : exec_end_event->event = FD_GUI_SLOT_SHRED_SHRED_REPLAY_EXEC_DONE;
2217 0 : }
2218 0 : }
2219 :
2220 : static void
2221 : fd_gui_handle_reset_slot_legacy( fd_gui_t * gui,
2222 : uchar const * msg,
2223 0 : long now ) {
2224 0 : ulong last_landed_vote = FD_LOAD( ulong, msg );
2225 :
2226 0 : ulong parent_cnt = FD_LOAD( ulong, msg + 8UL );
2227 0 : FD_TEST( parent_cnt<4096UL );
2228 :
2229 0 : ulong _slot = FD_LOAD( ulong, msg + 16UL );
2230 :
2231 0 : for( ulong i=0UL; i<parent_cnt; i++ ) {
2232 0 : ulong parent_slot = FD_LOAD( ulong, msg + (2UL+i)*8UL );
2233 0 : fd_gui_slot_t * slot = fd_gui_get_slot( gui, parent_slot );
2234 0 : if( FD_UNLIKELY( !slot ) ) {
2235 0 : ulong parent_parent_slot = ULONG_MAX;
2236 0 : if( FD_UNLIKELY( i!=parent_cnt-1UL) ) parent_parent_slot = FD_LOAD( ulong, msg + (3UL+i)*8UL );
2237 0 : fd_gui_clear_slot( gui, parent_slot, parent_parent_slot );
2238 0 : }
2239 0 : }
2240 :
2241 0 : if( FD_UNLIKELY( gui->summary.vote_distance!=_slot-last_landed_vote ) ) {
2242 0 : gui->summary.vote_distance = _slot-last_landed_vote;
2243 0 : fd_gui_printf_vote_distance( gui );
2244 0 : fd_http_server_ws_broadcast( gui->http );
2245 0 : }
2246 :
2247 0 : if( FD_LIKELY( gui->summary.vote_state!=FD_GUI_VOTE_STATE_NON_VOTING ) ) {
2248 0 : if( FD_UNLIKELY( last_landed_vote==ULONG_MAX || (last_landed_vote+150UL)<_slot ) ) {
2249 0 : if( FD_UNLIKELY( gui->summary.vote_state!=FD_GUI_VOTE_STATE_DELINQUENT ) ) {
2250 0 : gui->summary.vote_state = FD_GUI_VOTE_STATE_DELINQUENT;
2251 0 : fd_gui_printf_vote_state( gui );
2252 0 : fd_http_server_ws_broadcast( gui->http );
2253 0 : }
2254 0 : } else {
2255 0 : if( FD_UNLIKELY( gui->summary.vote_state!=FD_GUI_VOTE_STATE_VOTING ) ) {
2256 0 : gui->summary.vote_state = FD_GUI_VOTE_STATE_VOTING;
2257 0 : fd_gui_printf_vote_state( gui );
2258 0 : fd_http_server_ws_broadcast( gui->http );
2259 0 : }
2260 0 : }
2261 0 : }
2262 :
2263 0 : ulong parent_slot_idx = 0UL;
2264 :
2265 0 : int republish_skip_rate[ 2 ] = {0};
2266 :
2267 0 : for( ulong i=0UL; i<fd_ulong_min( _slot+1, FD_GUI_SLOTS_CNT ); i++ ) {
2268 0 : ulong parent_slot = _slot - i;
2269 :
2270 0 : fd_gui_slot_t * slot = fd_gui_get_slot( gui, parent_slot );
2271 0 : if( FD_UNLIKELY( !slot ) ) slot = fd_gui_clear_slot( gui, parent_slot, ULONG_MAX );
2272 :
2273 : /* The chain of parents may stretch into already rooted slots if
2274 : they haven't been squashed yet, if we reach one of them we can
2275 : just exit, all the information prior to the root is already
2276 : correct. */
2277 :
2278 0 : if( FD_LIKELY( slot->level>=FD_GUI_SLOT_LEVEL_ROOTED ) ) break;
2279 :
2280 0 : int should_republish = slot->must_republish;
2281 0 : slot->must_republish = 0;
2282 :
2283 0 : if( FD_UNLIKELY( parent_slot!=FD_LOAD( ulong, msg + (2UL+parent_slot_idx)*8UL ) ) ) {
2284 : /* We are between two parents in the rooted chain, which means
2285 : we were skipped. */
2286 0 : if( FD_UNLIKELY( !slot->skipped ) ) {
2287 0 : slot->skipped = 1;
2288 0 : should_republish = 1;
2289 0 : if( FD_LIKELY( slot->mine ) ) {
2290 0 : for( ulong i=0UL; i<2UL; i++ ) {
2291 0 : if( FD_LIKELY( parent_slot>=gui->epoch.epochs[ i ].start_slot && parent_slot<=gui->epoch.epochs[ i ].end_slot ) ) {
2292 0 : gui->epoch.epochs[ i ].my_skipped_slots++;
2293 0 : republish_skip_rate[ i ] = 1;
2294 0 : break;
2295 0 : }
2296 0 : }
2297 0 : }
2298 0 : }
2299 0 : } else {
2300 : /* Reached the next parent... */
2301 0 : if( FD_UNLIKELY( slot->skipped ) ) {
2302 0 : slot->skipped = 0;
2303 0 : should_republish = 1;
2304 0 : if( FD_LIKELY( slot->mine ) ) {
2305 0 : for( ulong i=0UL; i<2UL; i++ ) {
2306 0 : if( FD_LIKELY( parent_slot>=gui->epoch.epochs[ i ].start_slot && parent_slot<=gui->epoch.epochs[ i ].end_slot ) ) {
2307 0 : gui->epoch.epochs[ i ].my_skipped_slots--;
2308 0 : republish_skip_rate[ i ] = 1;
2309 0 : break;
2310 0 : }
2311 0 : }
2312 0 : }
2313 0 : }
2314 0 : parent_slot_idx++;
2315 0 : }
2316 :
2317 0 : if( FD_LIKELY( should_republish ) ) {
2318 0 : fd_gui_printf_slot( gui, parent_slot );
2319 0 : fd_http_server_ws_broadcast( gui->http );
2320 0 : }
2321 :
2322 : /* We reached the last parent in the chain, everything above this
2323 : must have already been rooted, so we can exit. */
2324 :
2325 0 : if( FD_UNLIKELY( parent_slot_idx>=parent_cnt ) ) break;
2326 0 : }
2327 :
2328 0 : ulong duration_sum = 0UL;
2329 0 : ulong slot_cnt = 0UL;
2330 :
2331 : /* If we've just caught up we should truncate our slot history to avoid including catch-up slots */
2332 0 : int just_caught_up = gui->summary.slot_caught_up!=ULONG_MAX && _slot>gui->summary.slot_caught_up && _slot<gui->summary.slot_caught_up+750UL;
2333 0 : ulong slot_duration_history_sz = fd_ulong_if( just_caught_up, _slot-gui->summary.slot_caught_up, 750UL );
2334 0 : for( ulong i=0UL; i<fd_ulong_min( _slot+1, slot_duration_history_sz ); i++ ) {
2335 0 : ulong parent_slot = _slot - i;
2336 :
2337 0 : fd_gui_slot_t const * slot = fd_gui_get_slot_const( gui, parent_slot );
2338 0 : if( FD_UNLIKELY( !slot) ) break;
2339 0 : if( FD_UNLIKELY( slot->slot!=parent_slot ) ) {
2340 0 : FD_LOG_ERR(( "_slot %lu i %lu we expect _slot-i %lu got slot->slot %lu", _slot, i, _slot-i, slot->slot ));
2341 0 : }
2342 :
2343 0 : ulong slot_duration = fd_gui_slot_duration( gui, slot );
2344 0 : if( FD_LIKELY( slot_duration!=ULONG_MAX ) ) {
2345 0 : duration_sum += slot_duration;
2346 0 : slot_cnt++;
2347 0 : }
2348 0 : }
2349 :
2350 0 : if( FD_LIKELY( slot_cnt>0 ) ) {
2351 0 : gui->summary.estimated_slot_duration_nanos = (ulong)(duration_sum / slot_cnt);
2352 0 : fd_gui_printf_estimated_slot_duration_nanos( gui );
2353 0 : fd_http_server_ws_broadcast( gui->http );
2354 0 : }
2355 :
2356 0 : if( FD_LIKELY( gui->summary.slot_completed==ULONG_MAX || _slot!=gui->summary.slot_completed ) ) {
2357 0 : gui->summary.slot_completed = _slot;
2358 0 : fd_gui_printf_completed_slot( gui );
2359 0 : fd_http_server_ws_broadcast( gui->http );
2360 :
2361 : /* Also update slot_turbine which could be larger than the max
2362 : turbine slot if we are leader */
2363 0 : if( FD_UNLIKELY( gui->summary.slots_max_turbine[ 0 ].slot!=ULONG_MAX && gui->summary.slot_completed!=ULONG_MAX && gui->summary.slot_completed>gui->summary.slots_max_turbine[ 0 ].slot ) ) {
2364 0 : fd_gui_try_insert_ephemeral_slot( gui->summary.slots_max_turbine, FD_GUI_TURBINE_SLOT_HISTORY_SZ, gui->summary.slot_completed, now );
2365 0 : }
2366 :
2367 0 : int slot_turbine_hist_full = gui->summary.slots_max_turbine[ FD_GUI_TURBINE_SLOT_HISTORY_SZ-1UL ].slot!=ULONG_MAX;
2368 0 : if( FD_UNLIKELY( gui->summary.slot_caught_up==ULONG_MAX && slot_turbine_hist_full && gui->summary.slots_max_turbine[ 0 ].slot < (gui->summary.slot_completed + 3UL) ) ) {
2369 0 : gui->summary.slot_caught_up = gui->summary.slot_completed + 4UL;
2370 :
2371 0 : fd_gui_printf_slot_caught_up( gui );
2372 0 : fd_http_server_ws_broadcast( gui->http );
2373 0 : }
2374 0 : }
2375 :
2376 0 : for( ulong i=0UL; i<2UL; i++ ) {
2377 0 : if( FD_LIKELY( republish_skip_rate[ i ] ) ) {
2378 0 : fd_gui_printf_skip_rate( gui, i );
2379 0 : fd_http_server_ws_broadcast( gui->http );
2380 0 : }
2381 0 : }
2382 0 : }
2383 :
2384 : static void
2385 : fd_gui_handle_completed_slot( fd_gui_t * gui,
2386 : uchar const * msg,
2387 0 : long now ) {
2388 :
2389 : /* This is the slot used by frontend clients as the "startup slot". In
2390 : certain boot conditions, we don't receive this slot from Agave, so
2391 : we include a bit of a hacky assignment here to make sure it is
2392 : always present. */
2393 0 : if( FD_UNLIKELY( gui->summary.startup_progress.startup_ledger_max_slot==ULONG_MAX ) ) {
2394 0 : gui->summary.startup_progress.startup_ledger_max_slot = FD_LOAD( ulong, msg );
2395 0 : }
2396 :
2397 0 : ulong _slot = FD_LOAD( ulong, msg );
2398 0 : uint total_txn_count = (uint)FD_LOAD( ulong, msg + 1UL*8UL );
2399 0 : uint nonvote_txn_count = (uint)FD_LOAD( ulong, msg + 2UL*8UL );
2400 0 : uint failed_txn_count = (uint)FD_LOAD( ulong, msg + 3UL*8UL );
2401 0 : uint nonvote_failed_txn_count = (uint)FD_LOAD( ulong, msg + 4UL*8UL );
2402 0 : uint compute_units = (uint)FD_LOAD( ulong, msg + 5UL*8UL );
2403 0 : ulong transaction_fee = FD_LOAD( ulong, msg + 6UL*8UL );
2404 0 : ulong priority_fee = FD_LOAD( ulong, msg + 7UL*8UL );
2405 0 : ulong tips = FD_LOAD( ulong, msg + 8UL*8UL );
2406 0 : ulong _parent_slot = FD_LOAD( ulong, msg + 9UL*8UL );
2407 0 : ulong max_compute_units = FD_LOAD( ulong, msg + 10UL*8UL );
2408 :
2409 0 : fd_gui_slot_t * slot = fd_gui_get_slot( gui, _slot );
2410 0 : if( FD_UNLIKELY( !slot ) ) slot = fd_gui_clear_slot( gui, _slot, _parent_slot );
2411 :
2412 0 : slot->completed_time = now;
2413 0 : slot->parent_slot = _parent_slot;
2414 0 : slot->max_compute_units = (uint)max_compute_units;
2415 0 : if( FD_LIKELY( slot->level<FD_GUI_SLOT_LEVEL_COMPLETED ) ) {
2416 : /* Typically a slot goes from INCOMPLETE to COMPLETED but it can
2417 : happen that it starts higher. One such case is when we
2418 : optimistically confirm a higher slot that skips this one, but
2419 : then later we replay this one anyway to track the bank fork. */
2420 :
2421 0 : if( FD_LIKELY( gui->summary.slot_optimistically_confirmed!=ULONG_MAX && _slot<gui->summary.slot_optimistically_confirmed ) ) {
2422 : /* Cluster might have already optimistically confirmed by the time
2423 : we finish replaying it. */
2424 0 : slot->level = FD_GUI_SLOT_LEVEL_OPTIMISTICALLY_CONFIRMED;
2425 0 : } else {
2426 0 : slot->level = FD_GUI_SLOT_LEVEL_COMPLETED;
2427 0 : }
2428 0 : }
2429 :
2430 0 : slot->nonvote_success = nonvote_txn_count - nonvote_failed_txn_count;
2431 0 : slot->nonvote_failed = nonvote_failed_txn_count;
2432 0 : slot->vote_failed = failed_txn_count - nonvote_failed_txn_count;
2433 0 : slot->vote_success = total_txn_count - nonvote_txn_count - slot->vote_failed;
2434 :
2435 0 : slot->transaction_fee = transaction_fee;
2436 0 : slot->priority_fee = priority_fee;
2437 0 : slot->tips = tips;
2438 :
2439 : /* In Frankendancer, CUs come from our own leader pipeline (the field
2440 : sent from the Agave codepath is zero'd out) */
2441 0 : slot->compute_units = fd_uint_if( !gui->summary.is_full_client && slot->mine, slot->compute_units, compute_units );
2442 :
2443 0 : if( FD_UNLIKELY( gui->epoch.has_epoch[ 0 ] && _slot==gui->epoch.epochs[ 0 ].end_slot ) ) {
2444 0 : gui->epoch.epochs[ 0 ].end_time = slot->completed_time;
2445 0 : } else if( FD_UNLIKELY( gui->epoch.has_epoch[ 1 ] && _slot==gui->epoch.epochs[ 1 ].end_slot ) ) {
2446 0 : gui->epoch.epochs[ 1 ].end_time = slot->completed_time;
2447 0 : }
2448 :
2449 : /* Broadcast new skip rate if one of our slots got completed. */
2450 0 : if( FD_LIKELY( slot->mine ) ) {
2451 0 : for( ulong i=0UL; i<2UL; i++ ) {
2452 0 : if( FD_LIKELY( _slot>=gui->epoch.epochs[ i ].start_slot && _slot<=gui->epoch.epochs[ i ].end_slot ) ) {
2453 0 : fd_gui_printf_skip_rate( gui, i );
2454 0 : fd_http_server_ws_broadcast( gui->http );
2455 0 : break;
2456 0 : }
2457 0 : }
2458 0 : }
2459 0 : }
2460 :
2461 : static void
2462 : fd_gui_handle_rooted_slot_legacy( fd_gui_t * gui,
2463 0 : uchar const * msg ) {
2464 0 : ulong _slot = FD_LOAD( ulong, msg );
2465 :
2466 : // FD_LOG_WARNING(( "Got rooted slot %lu", _slot ));
2467 :
2468 : /* Slot 0 is always rooted. No need to iterate all the way back to
2469 : i==_slot */
2470 0 : for( ulong i=0UL; i<fd_ulong_min( _slot, FD_GUI_SLOTS_CNT ); i++ ) {
2471 0 : ulong parent_slot = _slot - i;
2472 :
2473 0 : fd_gui_slot_t * slot = fd_gui_get_slot( gui, parent_slot );
2474 0 : if( FD_UNLIKELY( !slot ) ) break;
2475 :
2476 0 : if( FD_UNLIKELY( slot->slot!=parent_slot ) ) {
2477 0 : FD_LOG_ERR(( "_slot %lu i %lu we expect parent_slot %lu got slot->slot %lu", _slot, i, parent_slot, slot->slot ));
2478 0 : }
2479 0 : if( FD_UNLIKELY( slot->level>=FD_GUI_SLOT_LEVEL_ROOTED ) ) break;
2480 :
2481 0 : slot->level = FD_GUI_SLOT_LEVEL_ROOTED;
2482 0 : fd_gui_printf_slot( gui, parent_slot );
2483 0 : fd_http_server_ws_broadcast( gui->http );
2484 0 : }
2485 :
2486 0 : gui->summary.slot_rooted = _slot;
2487 0 : fd_gui_printf_root_slot( gui );
2488 0 : fd_http_server_ws_broadcast( gui->http );
2489 0 : }
2490 :
2491 : static void
2492 : fd_gui_handle_optimistically_confirmed_slot( fd_gui_t * gui,
2493 0 : ulong _slot ) {
2494 : /* Slot 0 is always rooted. No need to iterate all the way back to
2495 : i==_slot */
2496 0 : for( ulong i=0UL; i<fd_ulong_min( _slot, FD_GUI_SLOTS_CNT ); i++ ) {
2497 0 : ulong parent_slot = _slot - i;
2498 :
2499 0 : fd_gui_slot_t * slot = fd_gui_get_slot( gui, parent_slot );
2500 0 : if( FD_UNLIKELY( !slot) ) break;
2501 :
2502 0 : if( FD_UNLIKELY( slot->slot>parent_slot ) ) {
2503 0 : FD_LOG_ERR(( "_slot %lu i %lu we expect parent_slot %lu got slot->slot %lu", _slot, i, parent_slot, slot->slot ));
2504 0 : } else if( FD_UNLIKELY( slot->slot<parent_slot ) ) {
2505 : /* Slot not even replayed yet ... will come out as optimistically confirmed */
2506 0 : continue;
2507 0 : }
2508 0 : if( FD_UNLIKELY( slot->level>=FD_GUI_SLOT_LEVEL_ROOTED ) ) break;
2509 :
2510 0 : if( FD_LIKELY( slot->level<FD_GUI_SLOT_LEVEL_OPTIMISTICALLY_CONFIRMED ) ) {
2511 0 : slot->level = FD_GUI_SLOT_LEVEL_OPTIMISTICALLY_CONFIRMED;
2512 0 : fd_gui_printf_slot( gui, parent_slot );
2513 0 : fd_http_server_ws_broadcast( gui->http );
2514 0 : }
2515 0 : }
2516 :
2517 0 : if( FD_UNLIKELY( gui->summary.slot_optimistically_confirmed!=ULONG_MAX && _slot<gui->summary.slot_optimistically_confirmed ) ) {
2518 : /* Optimistically confirmed slot went backwards ... mark some slots as no
2519 : longer optimistically confirmed. */
2520 0 : for( long i_=(long)gui->summary.slot_optimistically_confirmed; i_>=(long)_slot; i_-- ) {
2521 0 : ulong i = (ulong)i_;
2522 0 : fd_gui_slot_t * slot = fd_gui_get_slot( gui, i );
2523 0 : if( FD_UNLIKELY( !slot ) ) break;
2524 0 : if( FD_LIKELY( slot->slot==i ) ) {
2525 : /* It's possible for the optimistically confirmed slot to skip
2526 : backwards between two slots that we haven't yet replayed. In
2527 : that case we don't need to change anything, since they will
2528 : get marked properly when they get completed. */
2529 0 : slot->level = FD_GUI_SLOT_LEVEL_COMPLETED;
2530 0 : fd_gui_printf_slot( gui, i );
2531 0 : fd_http_server_ws_broadcast( gui->http );
2532 0 : }
2533 0 : }
2534 0 : }
2535 :
2536 0 : gui->summary.slot_optimistically_confirmed = _slot;
2537 0 : fd_gui_printf_optimistically_confirmed_slot( gui );
2538 0 : fd_http_server_ws_broadcast( gui->http );
2539 0 : }
2540 :
2541 : static void
2542 : fd_gui_handle_balance_update( fd_gui_t * gui,
2543 0 : uchar const * msg ) {
2544 0 : switch( FD_LOAD( ulong, msg ) ) {
2545 0 : case 0UL:
2546 0 : gui->summary.identity_account_balance = FD_LOAD( ulong, msg + 8UL );
2547 0 : fd_gui_printf_identity_balance( gui );
2548 0 : fd_http_server_ws_broadcast( gui->http );
2549 0 : break;
2550 0 : case 1UL:
2551 0 : gui->summary.vote_account_balance = FD_LOAD( ulong, msg + 8UL );
2552 0 : fd_gui_printf_vote_balance( gui );
2553 0 : fd_http_server_ws_broadcast( gui->http );
2554 0 : break;
2555 0 : default:
2556 0 : FD_LOG_ERR(( "balance: unknown account type: %lu", FD_LOAD( ulong, msg ) ));
2557 0 : }
2558 0 : }
2559 :
2560 : static void
2561 : fd_gui_handle_start_progress( fd_gui_t * gui,
2562 0 : uchar const * msg ) {
2563 0 : uchar type = msg[ 0 ];
2564 :
2565 0 : switch (type) {
2566 0 : case 0:
2567 0 : gui->summary.startup_progress.phase = FD_GUI_START_PROGRESS_TYPE_INITIALIZING;
2568 0 : FD_LOG_INFO(( "progress: initializing" ));
2569 0 : break;
2570 0 : case 1: {
2571 0 : char const * snapshot_type;
2572 0 : if( FD_UNLIKELY( gui->summary.startup_progress.startup_got_full_snapshot ) ) {
2573 0 : gui->summary.startup_progress.phase = FD_GUI_START_PROGRESS_TYPE_SEARCHING_FOR_INCREMENTAL_SNAPSHOT;
2574 0 : snapshot_type = "incremental";
2575 0 : } else {
2576 0 : gui->summary.startup_progress.phase = FD_GUI_START_PROGRESS_TYPE_SEARCHING_FOR_FULL_SNAPSHOT;
2577 0 : snapshot_type = "full";
2578 0 : }
2579 0 : FD_LOG_INFO(( "progress: searching for %s snapshot", snapshot_type ));
2580 0 : break;
2581 0 : }
2582 0 : case 2: {
2583 0 : uchar is_full_snapshot = msg[ 1 ];
2584 0 : if( FD_LIKELY( is_full_snapshot ) ) {
2585 0 : gui->summary.startup_progress.phase = FD_GUI_START_PROGRESS_TYPE_DOWNLOADING_FULL_SNAPSHOT;
2586 0 : gui->summary.startup_progress.startup_full_snapshot_slot = FD_LOAD( ulong, msg + 2 );
2587 0 : gui->summary.startup_progress.startup_full_snapshot_peer_ip_addr = FD_LOAD( uint, msg + 10 );
2588 0 : gui->summary.startup_progress.startup_full_snapshot_peer_port = FD_LOAD( ushort, msg + 14 );
2589 0 : gui->summary.startup_progress.startup_full_snapshot_total_bytes = FD_LOAD( ulong, msg + 16 );
2590 0 : gui->summary.startup_progress.startup_full_snapshot_current_bytes = FD_LOAD( ulong, msg + 24 );
2591 0 : gui->summary.startup_progress.startup_full_snapshot_elapsed_secs = FD_LOAD( double, msg + 32 );
2592 0 : gui->summary.startup_progress.startup_full_snapshot_remaining_secs = FD_LOAD( double, msg + 40 );
2593 0 : gui->summary.startup_progress.startup_full_snapshot_throughput = FD_LOAD( double, msg + 48 );
2594 0 : FD_LOG_INFO(( "progress: downloading full snapshot: slot=%lu", gui->summary.startup_progress.startup_full_snapshot_slot ));
2595 0 : } else {
2596 0 : gui->summary.startup_progress.phase = FD_GUI_START_PROGRESS_TYPE_DOWNLOADING_INCREMENTAL_SNAPSHOT;
2597 0 : gui->summary.startup_progress.startup_incremental_snapshot_slot = FD_LOAD( ulong, msg + 2 );
2598 0 : gui->summary.startup_progress.startup_incremental_snapshot_peer_ip_addr = FD_LOAD( uint, msg + 10 );
2599 0 : gui->summary.startup_progress.startup_incremental_snapshot_peer_port = FD_LOAD( ushort, msg + 14 );
2600 0 : gui->summary.startup_progress.startup_incremental_snapshot_total_bytes = FD_LOAD( ulong, msg + 16 );
2601 0 : gui->summary.startup_progress.startup_incremental_snapshot_current_bytes = FD_LOAD( ulong, msg + 24 );
2602 0 : gui->summary.startup_progress.startup_incremental_snapshot_elapsed_secs = FD_LOAD( double, msg + 32 );
2603 0 : gui->summary.startup_progress.startup_incremental_snapshot_remaining_secs = FD_LOAD( double, msg + 40 );
2604 0 : gui->summary.startup_progress.startup_incremental_snapshot_throughput = FD_LOAD( double, msg + 48 );
2605 0 : FD_LOG_INFO(( "progress: downloading incremental snapshot: slot=%lu", gui->summary.startup_progress.startup_incremental_snapshot_slot ));
2606 0 : }
2607 0 : break;
2608 0 : }
2609 0 : case 3: {
2610 0 : gui->summary.startup_progress.startup_got_full_snapshot = 1;
2611 0 : break;
2612 0 : }
2613 0 : case 4:
2614 0 : gui->summary.startup_progress.phase = FD_GUI_START_PROGRESS_TYPE_CLEANING_BLOCK_STORE;
2615 0 : FD_LOG_INFO(( "progress: cleaning block store" ));
2616 0 : break;
2617 0 : case 5:
2618 0 : gui->summary.startup_progress.phase = FD_GUI_START_PROGRESS_TYPE_CLEANING_ACCOUNTS;
2619 0 : FD_LOG_INFO(( "progress: cleaning accounts" ));
2620 0 : break;
2621 0 : case 6:
2622 0 : gui->summary.startup_progress.phase = FD_GUI_START_PROGRESS_TYPE_LOADING_LEDGER;
2623 0 : FD_LOG_INFO(( "progress: loading ledger" ));
2624 0 : break;
2625 0 : case 7: {
2626 0 : gui->summary.startup_progress.phase = FD_GUI_START_PROGRESS_TYPE_PROCESSING_LEDGER;
2627 0 : gui->summary.startup_progress.startup_ledger_slot = fd_ulong_load_8( msg + 1 );
2628 0 : gui->summary.startup_progress.startup_ledger_max_slot = fd_ulong_load_8( msg + 9 );
2629 0 : FD_LOG_INFO(( "progress: processing ledger: slot=%lu, max_slot=%lu", gui->summary.startup_progress.startup_ledger_slot, gui->summary.startup_progress.startup_ledger_max_slot ));
2630 0 : break;
2631 0 : }
2632 0 : case 8:
2633 0 : gui->summary.startup_progress.phase = FD_GUI_START_PROGRESS_TYPE_STARTING_SERVICES;
2634 0 : FD_LOG_INFO(( "progress: starting services" ));
2635 0 : break;
2636 0 : case 9:
2637 0 : gui->summary.startup_progress.phase = FD_GUI_START_PROGRESS_TYPE_HALTED;
2638 0 : FD_LOG_INFO(( "progress: halted" ));
2639 0 : break;
2640 0 : case 10: {
2641 0 : gui->summary.startup_progress.phase = FD_GUI_START_PROGRESS_TYPE_WAITING_FOR_SUPERMAJORITY;
2642 0 : gui->summary.startup_progress.startup_waiting_for_supermajority_slot = fd_ulong_load_8( msg + 1 );
2643 0 : gui->summary.startup_progress.startup_waiting_for_supermajority_stake_pct = fd_ulong_load_8( msg + 9 );
2644 0 : FD_LOG_INFO(( "progress: waiting for supermajority: slot=%lu, gossip_stake_percent=%lu", gui->summary.startup_progress.startup_waiting_for_supermajority_slot, gui->summary.startup_progress.startup_waiting_for_supermajority_stake_pct ));
2645 0 : break;
2646 0 : }
2647 0 : case 11:
2648 0 : gui->summary.startup_progress.phase = FD_GUI_START_PROGRESS_TYPE_RUNNING;
2649 0 : FD_LOG_INFO(( "progress: running" ));
2650 0 : break;
2651 0 : default:
2652 0 : FD_LOG_ERR(( "progress: unknown type: %u", type ));
2653 0 : }
2654 :
2655 0 : fd_gui_printf_startup_progress( gui );
2656 0 : fd_http_server_ws_broadcast( gui->http );
2657 0 : }
2658 :
2659 : void
2660 : fd_gui_handle_genesis_hash( fd_gui_t * gui,
2661 0 : fd_hash_t const * msg ) {
2662 0 : FD_BASE58_ENCODE_32_BYTES( msg->uc, hash_cstr );
2663 0 : ulong cluster = fd_genesis_cluster_identify(hash_cstr);
2664 0 : char const * cluster_name = fd_genesis_cluster_name(cluster);
2665 :
2666 0 : if( FD_LIKELY( strcmp( gui->summary.cluster, cluster_name ) ) ) {
2667 0 : gui->summary.cluster = fd_genesis_cluster_name(cluster);
2668 0 : fd_gui_printf_cluster( gui );
2669 0 : fd_http_server_ws_broadcast( gui->http );
2670 0 : }
2671 0 : }
2672 :
2673 : void
2674 : fd_gui_handle_block_engine_update( fd_gui_t * gui,
2675 0 : fd_bundle_block_engine_update_t const * update ) {
2676 0 : gui->block_engine.has_block_engine = 1;
2677 :
2678 : /* copy strings and ensure null termination within bounds */
2679 0 : FD_TEST( fd_cstr_nlen( update->name, sizeof(gui->block_engine.name ) ) < sizeof(gui->block_engine.name ) );
2680 0 : FD_TEST( fd_cstr_nlen( update->url, sizeof(gui->block_engine.url ) ) < sizeof(gui->block_engine.url ) );
2681 0 : FD_TEST( fd_cstr_nlen( update->ip_cstr, sizeof(gui->block_engine.ip_cstr) ) < sizeof(gui->block_engine.ip_cstr) );
2682 0 : ulong name_len = fd_cstr_nlen( update->name, sizeof(gui->block_engine.name ) );
2683 0 : ulong url_len = fd_cstr_nlen( update->url, sizeof(gui->block_engine.url ) );
2684 0 : ulong ip_cstr_len = fd_cstr_nlen( update->ip_cstr, sizeof(gui->block_engine.ip_cstr) );
2685 0 : fd_memcpy( gui->block_engine.name, update->name, name_len+1UL );
2686 0 : fd_memcpy( gui->block_engine.url, update->url, url_len+1UL );
2687 0 : fd_memcpy( gui->block_engine.ip_cstr, update->ip_cstr, ip_cstr_len+1UL );
2688 :
2689 0 : fd_gui_printf_block_engine( gui );
2690 0 : fd_http_server_ws_broadcast( gui->http );
2691 0 : }
2692 :
2693 : void
2694 : fd_gui_handle_snapshot_update( fd_gui_t * gui,
2695 0 : fd_snapct_update_t const * msg ) {
2696 0 : FD_TEST( msg && fd_cstr_nlen( msg->read_path, 1 ) );
2697 :
2698 0 : ulong snapshot_idx = fd_ulong_if( msg->type==FD_SNAPCT_SNAPSHOT_TYPE_FULL, FD_GUI_BOOT_PROGRESS_FULL_SNAPSHOT_IDX, FD_GUI_BOOT_PROGRESS_INCREMENTAL_SNAPSHOT_IDX );
2699 :
2700 0 : char const * filename = strrchr( msg->read_path, '/' );
2701 :
2702 : /* Skip the '/' */
2703 0 : if( FD_LIKELY( filename ) ) filename++;
2704 0 : else filename = msg->read_path;
2705 :
2706 0 : if (msg->type == FD_SNAPCT_SNAPSHOT_TYPE_INCREMENTAL) {
2707 0 : ulong slot1, slot2;
2708 0 : if ( FD_LIKELY( sscanf( filename, "incremental-snapshot-%lu-%lu-", &slot1, &slot2 )==2 ) )
2709 0 : gui->summary.boot_progress.loading_snapshot[ snapshot_idx ].slot = slot2;
2710 0 : else FD_LOG_ERR(("failed to scan filename: %s parsed from %s", filename, msg->read_path ));
2711 0 : } else if (msg->type == FD_SNAPCT_SNAPSHOT_TYPE_FULL) {
2712 0 : ulong slot1;
2713 0 : if ( FD_LIKELY( sscanf( filename, "snapshot-%lu-", &slot1 )==1 ) )
2714 0 : gui->summary.boot_progress.loading_snapshot[ snapshot_idx ].slot = slot1;
2715 0 : else FD_LOG_ERR(("failed to scan filename: %s parsed from %s", filename, msg->read_path ));
2716 0 : }
2717 0 : fd_cstr_printf_check( gui->summary.boot_progress.loading_snapshot[ snapshot_idx ].read_path, sizeof(gui->summary.boot_progress.loading_snapshot[ snapshot_idx ].read_path), NULL, "%s", msg->read_path );
2718 0 : }
2719 :
2720 : void
2721 : fd_gui_stage_snapshot_manifest( fd_gui_t * gui,
2722 0 : fd_snapshot_manifest_t const * manifest ) {
2723 0 : ulong attempt = 0UL;
2724 0 : for( ulong i=0UL; i<manifest->hard_fork_cnt; i++ ) {
2725 0 : if( FD_UNLIKELY( manifest->hard_forks[ i ].slot==manifest->slot ) ) {
2726 0 : attempt = manifest->hard_forks[ i ].cnt;
2727 0 : break;
2728 0 : }
2729 0 : }
2730 0 : gui->summary.boot_progress.wfs_attempt = attempt;
2731 0 : }
2732 :
2733 : static void
2734 0 : fd_gui_handle_reset_slot( fd_gui_t * gui, ulong reset_slot, long now ) {
2735 0 : FD_TEST( reset_slot!=ULONG_MAX );
2736 :
2737 : /* reset_slot has not changed */
2738 0 : if( FD_UNLIKELY( gui->summary.slot_completed!=ULONG_MAX && reset_slot==gui->summary.slot_completed ) ) return;
2739 :
2740 0 : ulong prev_slot_completed = gui->summary.slot_completed;
2741 0 : gui->summary.slot_completed = reset_slot;
2742 :
2743 0 : if( FD_LIKELY( fd_gui_get_slot( gui, gui->summary.slot_completed ) ) ) {
2744 0 : fd_gui_printf_slot( gui, gui->summary.slot_completed );
2745 0 : fd_http_server_ws_broadcast( gui->http );
2746 0 : }
2747 :
2748 0 : fd_gui_printf_completed_slot( gui );
2749 0 : fd_http_server_ws_broadcast( gui->http );
2750 :
2751 : /* Also update slot_turbine which could be larger than the max
2752 : turbine slot if we are leader */
2753 0 : if( FD_UNLIKELY( gui->summary.slots_max_turbine[ 0 ].slot!=ULONG_MAX && gui->summary.slot_completed > gui->summary.slots_max_turbine[ 0 ].slot ) ) {
2754 0 : fd_gui_try_insert_ephemeral_slot( gui->summary.slots_max_turbine, FD_GUI_TURBINE_SLOT_HISTORY_SZ, gui->summary.slot_completed, now );
2755 0 : }
2756 :
2757 0 : int slot_turbine_hist_full = gui->summary.slots_max_turbine[ FD_GUI_TURBINE_SLOT_HISTORY_SZ-1UL ].slot!=ULONG_MAX;
2758 0 : if( FD_UNLIKELY( gui->summary.slot_caught_up==ULONG_MAX && slot_turbine_hist_full && gui->summary.slots_max_turbine[ 0 ].slot < (gui->summary.slot_completed + 3UL) ) ) {
2759 0 : gui->summary.slot_caught_up = gui->summary.slot_completed + 4UL;
2760 :
2761 0 : fd_gui_printf_slot_caught_up( gui );
2762 0 : fd_http_server_ws_broadcast( gui->http );
2763 0 : }
2764 :
2765 : /* ensure a history exists */
2766 0 : if( FD_UNLIKELY( prev_slot_completed==ULONG_MAX || gui->summary.slot_rooted==ULONG_MAX ) ) return;
2767 :
2768 : /* slot complete received out of order on the same fork? */
2769 0 : FD_TEST( fd_gui_slot_is_ancestor( gui, prev_slot_completed, gui->summary.slot_completed ) || !fd_gui_slot_is_ancestor( gui, gui->summary.slot_completed, prev_slot_completed ) );
2770 :
2771 : /* fork switch: we need to "undo" the previous fork */
2772 0 : int republish_skip_rate[ 2 ] = {0};
2773 0 : if( FD_UNLIKELY( !fd_gui_slot_is_ancestor( gui, prev_slot_completed, gui->summary.slot_completed ) ) ) {
2774 : /* The handling for skipped slot on a fork switch is tricky. We
2775 : want to rebate back any slots that were skipped but are no
2776 : longer. We also need to make sure we count skipped slots
2777 : towards the correct epoch. */
2778 0 : for( ulong slot=fd_ulong_max( gui->summary.slot_completed, prev_slot_completed); slot>gui->summary.slot_rooted; slot-- ) {
2779 :
2780 0 : int is_skipped_on_old_fork = slot<=prev_slot_completed && fd_gui_is_skipped_on_fork( gui, gui->summary.slot_rooted, prev_slot_completed, slot );
2781 0 : int is_skipped_on_new_fork = slot<=gui->summary.slot_completed && fd_gui_is_skipped_on_fork( gui, gui->summary.slot_rooted, gui->summary.slot_completed, slot );
2782 :
2783 0 : if( FD_LIKELY( is_skipped_on_old_fork && !is_skipped_on_new_fork ) ) {
2784 0 : fd_gui_slot_t * skipped = fd_gui_get_slot( gui, slot );
2785 0 : if( FD_LIKELY( !skipped ) ) {
2786 0 : fd_gui_slot_t * p = fd_gui_get_parent_slot_on_fork( gui, prev_slot_completed, slot );
2787 0 : skipped = fd_gui_clear_slot( gui, slot, p ? p->slot : ULONG_MAX );
2788 0 : }
2789 :
2790 0 : int was_skipped = skipped->skipped;
2791 0 : skipped->skipped = 0;
2792 0 : fd_gui_printf_slot( gui, skipped->slot );
2793 0 : fd_http_server_ws_broadcast( gui->http );
2794 0 : skipped->must_republish = 0;
2795 :
2796 0 : if( FD_LIKELY( was_skipped && skipped->mine ) ) {
2797 0 : for( ulong epoch=0UL; epoch<2UL; epoch++ ) {
2798 0 : if( FD_LIKELY( slot>=gui->epoch.epochs[ epoch ].start_slot && slot<=gui->epoch.epochs[ epoch ].end_slot ) ) {
2799 0 : gui->epoch.epochs[ epoch ].my_skipped_slots--;
2800 0 : republish_skip_rate[ epoch ] = 1;
2801 0 : break;
2802 0 : }
2803 0 : }
2804 0 : }
2805 0 : }
2806 :
2807 0 : if( FD_LIKELY( !is_skipped_on_old_fork && is_skipped_on_new_fork ) ) {
2808 0 : fd_gui_slot_t * skipped = fd_gui_get_slot( gui, slot );
2809 0 : if( FD_LIKELY( !skipped ) ) {
2810 0 : fd_gui_slot_t * p = fd_gui_get_parent_slot_on_fork( gui, prev_slot_completed, slot );
2811 0 : skipped = fd_gui_clear_slot( gui, slot, p ? p->slot : ULONG_MAX );
2812 0 : }
2813 :
2814 0 : int was_skipped = skipped->skipped;
2815 0 : skipped->skipped = 1;
2816 0 : fd_gui_printf_slot( gui, skipped->slot );
2817 0 : fd_http_server_ws_broadcast( gui->http );
2818 0 : skipped->must_republish = 0;
2819 :
2820 0 : if( FD_LIKELY( !was_skipped && skipped->mine ) ) {
2821 0 : for( ulong epoch=0UL; epoch<2UL; epoch++ ) {
2822 0 : if( FD_LIKELY( slot>=gui->epoch.epochs[ epoch ].start_slot && slot<=gui->epoch.epochs[ epoch ].end_slot ) ) {
2823 0 : gui->epoch.epochs[ epoch ].my_skipped_slots++;
2824 0 : republish_skip_rate[ epoch ] = 1;
2825 0 : break;
2826 0 : }
2827 0 : }
2828 0 : }
2829 0 : }
2830 0 : }
2831 0 : } else {
2832 : /* publish new skipped slots */
2833 0 : fd_gui_slot_t * s = fd_gui_get_slot( gui, gui->summary.slot_completed );
2834 0 : while( s && s->slot>=prev_slot_completed ) {
2835 0 : fd_gui_slot_t * p = fd_gui_get_slot( gui, s->parent_slot );
2836 0 : if( FD_UNLIKELY( !p ) ) break;
2837 0 : for( ulong slot=p->slot+1; slot<s->slot; slot++ ) {
2838 0 : fd_gui_slot_t * skipped = fd_gui_get_slot( gui, slot );
2839 0 : if( FD_LIKELY( !skipped ) ) {
2840 0 : fd_gui_slot_t * p = fd_gui_get_parent_slot_on_fork( gui, gui->summary.slot_completed, slot );
2841 0 : skipped = fd_gui_clear_slot( gui, slot, p ? p->slot : ULONG_MAX );
2842 0 : }
2843 0 : if( FD_LIKELY( !skipped->skipped ) ) {
2844 0 : skipped->skipped = 1;
2845 0 : fd_gui_printf_slot( gui, skipped->slot );
2846 0 : fd_http_server_ws_broadcast( gui->http );
2847 0 : skipped->must_republish = 0;
2848 0 : if( FD_LIKELY( skipped->mine ) ) {
2849 0 : for( ulong epoch=0UL; epoch<2UL; epoch++ ) {
2850 0 : if( FD_LIKELY( slot>=gui->epoch.epochs[ epoch ].start_slot && slot<=gui->epoch.epochs[ epoch ].end_slot ) ) {
2851 0 : gui->epoch.epochs[ epoch ].my_skipped_slots++;
2852 0 : republish_skip_rate[ epoch ] = 1;
2853 0 : break;
2854 0 : }
2855 0 : }
2856 0 : }
2857 0 : }
2858 0 : }
2859 0 : s = p;
2860 0 : }
2861 0 : }
2862 :
2863 0 : for( ulong i=0UL; i<2UL; i++ ) {
2864 0 : if( FD_LIKELY( republish_skip_rate[ i ] ) ) {
2865 0 : fd_gui_printf_skip_rate( gui, i );
2866 0 : fd_http_server_ws_broadcast( gui->http );
2867 0 : }
2868 0 : }
2869 0 : }
2870 :
2871 : #define SORT_NAME fd_gui_slot_staged_shred_event_slot_sort
2872 0 : #define SORT_KEY_T fd_gui_slot_staged_shred_event_t
2873 0 : #define SORT_BEFORE(a,b) (((a).slot<(b).slot) || (((a).slot==(b).slot) && ((a).timestamp<(b).timestamp)))
2874 : #include "../../util/tmpl/fd_sort.c"
2875 :
2876 : static void
2877 0 : fd_gui_handle_rooted_slot( fd_gui_t * gui, ulong root_slot ) {
2878 0 : ulong epoch_idx = fd_gui_current_epoch_idx( gui );
2879 0 : ulong epoch_start = ULONG_MAX;
2880 0 : ulong epoch_end = ULONG_MAX;
2881 0 : if( FD_LIKELY( epoch_idx!=ULONG_MAX ) ) {
2882 0 : epoch_start = gui->epoch.epochs[ epoch_idx ].start_slot;
2883 0 : epoch_end = gui->epoch.epochs[ epoch_idx ].end_slot;
2884 0 : }
2885 :
2886 : /* Epoch boundary */
2887 0 : if( FD_UNLIKELY( gui->summary.late_votes_sz && epoch_idx!=ULONG_MAX && ( epoch_start>gui->summary.late_votes[ 0 ] || epoch_end<gui->summary.late_votes[ 0 ] ) ) ) {
2888 0 : gui->summary.late_votes_sz = 0;
2889 0 : }
2890 :
2891 : /* Epoch boundary or startup -- backfill history */
2892 0 : if( FD_UNLIKELY( epoch_idx!=ULONG_MAX && gui->summary.late_votes_sz==0UL ) ) {
2893 0 : for( ulong s=epoch_start; s<fd_ulong_min( root_slot, epoch_start+FD_GUI_SLOTS_CNT ); s++ ) {
2894 0 : fd_gui_slot_t * slot = fd_gui_get_slot( gui, s );
2895 0 : if( FD_UNLIKELY( !slot || slot->level<FD_GUI_SLOT_LEVEL_ROOTED ) ) break;
2896 :
2897 0 : int in_current_epoch = epoch_idx!=ULONG_MAX && epoch_start<=s && epoch_end>=s;
2898 0 : if( FD_UNLIKELY( in_current_epoch && ( ( !slot->skipped && slot->vote_latency==UCHAR_MAX ) || ( slot->vote_latency!=UCHAR_MAX && slot->vote_latency>1UL ) ) ) ) {
2899 0 : fd_gui_try_insert_run_length_slot( gui->summary.late_votes, MAX_SLOTS_PER_EPOCH, &gui->summary.late_votes_sz, s );
2900 0 : }
2901 0 : }
2902 0 : }
2903 :
2904 : /* start at the new root and move backwards towards the old root,
2905 : rooting everything in-between */
2906 0 : for( ulong i=0UL; i<fd_ulong_min( root_slot, FD_GUI_SLOTS_CNT ); i++ ) {
2907 0 : ulong parent_slot = root_slot - i;
2908 :
2909 0 : fd_gui_slot_t * slot = fd_gui_get_slot( gui, parent_slot );
2910 0 : if( FD_UNLIKELY( !slot ) ) break;
2911 :
2912 0 : if( FD_UNLIKELY( slot->slot!=parent_slot ) ) {
2913 0 : FD_LOG_ERR(( "_slot %lu i %lu we expect parent_slot %lu got slot->slot %lu", root_slot, i, parent_slot, slot->slot ));
2914 0 : }
2915 :
2916 0 : int in_current_epoch = epoch_idx!=ULONG_MAX && epoch_start<=slot->slot && epoch_end>=slot->slot;
2917 0 : if( FD_UNLIKELY( in_current_epoch && ( ( !slot->skipped && slot->vote_latency==UCHAR_MAX ) || ( slot->vote_latency!=UCHAR_MAX && slot->vote_latency>1UL ) ) ) ) {
2918 0 : fd_gui_try_insert_run_length_slot( gui->summary.late_votes, MAX_SLOTS_PER_EPOCH, &gui->summary.late_votes_sz, slot->slot );
2919 0 : }
2920 :
2921 0 : if( FD_UNLIKELY( slot->level>=FD_GUI_SLOT_LEVEL_ROOTED ) ) break;
2922 :
2923 : /* change votes levels and rebroadcast */
2924 0 : slot->level = FD_GUI_SLOT_LEVEL_ROOTED;
2925 0 : fd_gui_printf_slot( gui, parent_slot );
2926 0 : fd_http_server_ws_broadcast( gui->http );
2927 0 : }
2928 :
2929 : /* archive root shred events. We want to avoid n^2 iteration here
2930 : since it can significantly slow things down. Instead, we copy
2931 : over all rooted shreds to a scratch space, sort by (slot,
2932 : timestamp) and copy the sorted arrays to the shred history. */
2933 0 : ulong archive_cnt = 0UL;
2934 0 : ulong kept_cnt = 0UL;
2935 0 : ulong kept_before_next_cnt = 0UL;
2936 :
2937 0 : for( ulong i=gui->shreds.staged_head; i<gui->shreds.staged_tail; i++ ) {
2938 0 : fd_gui_slot_staged_shred_event_t const * src = &gui->shreds.staged[ i % FD_GUI_SHREDS_STAGING_SZ ];
2939 :
2940 0 : if( FD_UNLIKELY( gui->shreds.history_slot!=ULONG_MAX && src->slot<=gui->shreds.history_slot ) ) continue;
2941 :
2942 0 : if( FD_UNLIKELY( src->slot<=root_slot ) ) {
2943 0 : if( FD_UNLIKELY( archive_cnt>=FD_GUI_SHREDS_STAGING_SZ ) ) continue;
2944 0 : gui->shreds._staged_scratch[ archive_cnt++ ] = *src;
2945 0 : continue;
2946 0 : }
2947 :
2948 0 : if( FD_UNLIKELY( i<gui->shreds.staged_next_broadcast ) ) kept_before_next_cnt++;
2949 0 : gui->shreds.staged[ (gui->shreds.staged_head + kept_cnt) % FD_GUI_SHREDS_STAGING_SZ ] = *src;
2950 0 : kept_cnt++;
2951 0 : }
2952 :
2953 0 : gui->shreds.staged_tail = gui->shreds.staged_head + kept_cnt;
2954 : /* Remap next_broadcast to preserve continuity after compaction */
2955 0 : gui->shreds.staged_next_broadcast = gui->shreds.staged_head + kept_before_next_cnt;
2956 :
2957 0 : if( FD_LIKELY( archive_cnt ) ) {
2958 0 : fd_gui_slot_staged_shred_event_slot_sort_inplace( gui->shreds._staged_scratch, archive_cnt );
2959 :
2960 0 : for( ulong i=0UL; i<archive_cnt; i++ ) {
2961 0 : if( FD_UNLIKELY( gui->shreds._staged_scratch[ i ].slot!=gui->shreds.history_slot ) ) {
2962 0 : fd_gui_slot_t * prev_slot = fd_gui_get_slot( gui, gui->shreds.history_slot );
2963 0 : if( FD_LIKELY( prev_slot ) ) prev_slot->shreds.end_offset = gui->shreds.history_tail;
2964 :
2965 0 : gui->shreds.history_slot = gui->shreds._staged_scratch[ i ].slot;
2966 :
2967 0 : fd_gui_slot_t * next_slot = fd_gui_get_slot( gui, gui->shreds.history_slot );
2968 0 : if( FD_LIKELY( next_slot ) ) next_slot->shreds.start_offset = gui->shreds.history_tail;
2969 0 : }
2970 :
2971 0 : gui->shreds.history[ gui->shreds.history_tail % FD_GUI_SHREDS_HISTORY_SZ ].timestamp = gui->shreds._staged_scratch[ i ].timestamp;
2972 0 : gui->shreds.history[ gui->shreds.history_tail % FD_GUI_SHREDS_HISTORY_SZ ].shred_idx = gui->shreds._staged_scratch[ i ].shred_idx;
2973 0 : gui->shreds.history[ gui->shreds.history_tail % FD_GUI_SHREDS_HISTORY_SZ ].event = gui->shreds._staged_scratch[ i ].event;
2974 :
2975 0 : gui->shreds.history_tail++;
2976 0 : }
2977 0 : }
2978 :
2979 0 : gui->summary.slot_rooted = root_slot;
2980 0 : fd_gui_printf_root_slot( gui );
2981 0 : fd_http_server_ws_broadcast( gui->http );
2982 0 : }
2983 :
2984 : void
2985 : fd_gui_handle_votes_update( fd_gui_t * gui,
2986 0 : fd_tower_slot_confirmed_t const * votes ) {
2987 0 : if( FD_UNLIKELY( votes->slot!=ULONG_MAX && gui->summary.slot_optimistically_confirmed!=votes->slot && votes->level==FD_TOWER_SLOT_CONFIRMED_OPTIMISTIC && !votes->fwd ) ) {
2988 0 : fd_gui_handle_optimistically_confirmed_slot( gui, votes->slot );
2989 0 : }
2990 0 : }
2991 :
2992 : static inline void
2993 0 : try_publish_vote_status( fd_gui_t * gui, ulong _slot ) {
2994 0 : fd_gui_slot_t * slot = fd_gui_get_slot( gui, _slot );
2995 :
2996 : /* For unstaked nodes, slot->vote_slot will always be ULONG_MAX */
2997 0 : if( FD_UNLIKELY( !slot || slot->vote_slot==ULONG_MAX || slot->reset_slot==ULONG_MAX ) ) return;
2998 :
2999 0 : ulong vote_distance = slot->reset_slot-slot->vote_slot;
3000 0 : if( FD_LIKELY( vote_distance<FD_GUI_SLOTS_CNT ) ) {
3001 0 : for( ulong s=slot->vote_slot; s<slot->reset_slot; s++ ) {
3002 0 : fd_gui_slot_t * cur = fd_gui_get_slot( gui, s );
3003 0 : if( FD_UNLIKELY( cur && cur->skipped ) ) vote_distance--;
3004 0 : }
3005 0 : }
3006 :
3007 0 : if( FD_UNLIKELY( gui->summary.vote_distance!=vote_distance ) ) {
3008 0 : gui->summary.vote_distance = vote_distance;
3009 0 : fd_gui_printf_vote_distance( gui );
3010 0 : fd_http_server_ws_broadcast( gui->http );
3011 0 : }
3012 :
3013 0 : if( FD_LIKELY( gui->summary.vote_state!=FD_GUI_VOTE_STATE_NON_VOTING ) ) {
3014 0 : if( FD_UNLIKELY( slot->vote_slot==ULONG_MAX || vote_distance>150UL ) ) {
3015 0 : if( FD_UNLIKELY( gui->summary.vote_state!=FD_GUI_VOTE_STATE_DELINQUENT ) ) {
3016 0 : gui->summary.vote_state = FD_GUI_VOTE_STATE_DELINQUENT;
3017 0 : fd_gui_printf_vote_state( gui );
3018 0 : fd_http_server_ws_broadcast( gui->http );
3019 0 : }
3020 0 : } else {
3021 0 : if( FD_UNLIKELY( gui->summary.vote_state!=FD_GUI_VOTE_STATE_VOTING ) ) {
3022 0 : gui->summary.vote_state = FD_GUI_VOTE_STATE_VOTING;
3023 0 : fd_gui_printf_vote_state( gui );
3024 0 : fd_http_server_ws_broadcast( gui->http );
3025 0 : }
3026 0 : }
3027 0 : }
3028 0 : }
3029 :
3030 : /* fd_gui_handle_tower_update handles updates from the tower tile, which
3031 : manages consensus related fork switching, rooting, slot confirmation. */
3032 : void
3033 : fd_gui_handle_tower_update( fd_gui_t * gui,
3034 : fd_tower_slot_done_t const * tower,
3035 0 : long now ) {
3036 0 : (void)now;
3037 :
3038 0 : if( FD_UNLIKELY( tower->active_fork_cnt!=gui->summary.active_fork_cnt ) ) {
3039 0 : gui->summary.active_fork_cnt = tower->active_fork_cnt;
3040 0 : fd_gui_printf_active_fork_cnt( gui );
3041 0 : fd_http_server_ws_broadcast( gui->http );
3042 0 : }
3043 :
3044 0 : fd_gui_slot_t * slot = fd_gui_get_slot( gui, tower->replay_slot );
3045 0 : if( FD_UNLIKELY( !slot ) ) slot = fd_gui_clear_slot( gui, tower->replay_slot, ULONG_MAX );
3046 0 : slot->reset_slot = tower->reset_slot;
3047 :
3048 0 : try_publish_vote_status( gui, tower->replay_slot );
3049 :
3050 0 : if( FD_LIKELY( gui->summary.slot_reset!=tower->reset_slot ) ) {
3051 0 : gui->summary.slot_reset = tower->reset_slot;
3052 0 : fd_gui_printf_reset_slot( gui );
3053 0 : fd_http_server_ws_broadcast( gui->http );
3054 0 : }
3055 :
3056 0 : if( FD_UNLIKELY( tower->vote_acct_bal!=ULONG_MAX && gui->summary.vote_account_balance!=tower->vote_acct_bal ) ) {
3057 0 : gui->summary.vote_account_balance = tower->vote_acct_bal;
3058 0 : fd_gui_printf_vote_balance( gui );
3059 0 : fd_http_server_ws_broadcast( gui->http );
3060 0 : }
3061 :
3062 : /* update slot history vote latencies with new votes */
3063 0 : for( ulong i=0UL; i<tower->tower_cnt; i++ ) {
3064 0 : fd_gui_slot_t * slot = fd_gui_get_slot( gui, tower->tower[ i ].slot );
3065 0 : if( FD_UNLIKELY( slot && slot->vote_latency!=tower->tower[ i ].latency ) ) {
3066 0 : slot->vote_latency = tower->tower[ i ].latency;
3067 0 : fd_gui_printf_slot( gui, slot->slot );
3068 0 : fd_http_server_ws_broadcast( gui->http );
3069 0 : }
3070 0 : if( FD_UNLIKELY( i+1UL>=tower->tower_cnt ) ) break;
3071 0 : for( ulong s=tower->tower[ i ].slot+1UL; s<tower->tower[ i+1 ].slot; s++ ) {
3072 0 : fd_gui_slot_t * slot = fd_gui_get_slot( gui, s );
3073 0 : if( FD_LIKELY( slot && slot->vote_latency!=UCHAR_MAX ) ) {
3074 0 : slot->vote_latency = UCHAR_MAX;
3075 0 : fd_gui_printf_slot( gui, slot->slot );
3076 0 : fd_http_server_ws_broadcast( gui->http );
3077 0 : }
3078 0 : }
3079 0 : }
3080 0 : }
3081 :
3082 : void
3083 : fd_gui_handle_replay_update( fd_gui_t * gui,
3084 : fd_replay_slot_completed_t const * slot_completed,
3085 : ulong vote_slot,
3086 0 : long now ) {
3087 0 : (void)now;
3088 :
3089 0 : if( FD_LIKELY( slot_completed->root_slot!=ULONG_MAX && gui->summary.slot_rooted!=slot_completed->root_slot ) ) {
3090 0 : fd_gui_handle_rooted_slot( gui, slot_completed->root_slot );
3091 0 : }
3092 :
3093 0 : if( FD_LIKELY( gui->summary.slot_storage!=slot_completed->storage_slot ) ) {
3094 0 : gui->summary.slot_storage = slot_completed->storage_slot;
3095 0 : fd_gui_printf_storage_slot( gui );
3096 0 : fd_http_server_ws_broadcast( gui->http );
3097 0 : }
3098 :
3099 0 : if( FD_UNLIKELY( slot_completed->identity_balance!=ULONG_MAX && gui->summary.identity_account_balance!=slot_completed->identity_balance ) ) {
3100 0 : gui->summary.identity_account_balance = slot_completed->identity_balance;
3101 :
3102 0 : fd_gui_printf_identity_balance( gui );
3103 0 : fd_http_server_ws_broadcast( gui->http );
3104 0 : }
3105 :
3106 0 : if( FD_UNLIKELY( gui->summary.boot_progress.catching_up_first_replay_slot==ULONG_MAX ) ) {
3107 0 : gui->summary.boot_progress.catching_up_first_replay_slot = slot_completed->slot;
3108 0 : }
3109 :
3110 0 : fd_gui_slot_t * slot = fd_gui_get_slot( gui, slot_completed->slot );
3111 0 : if( FD_UNLIKELY( slot ) ) {
3112 : /* Its possible that this slot was labeled as skipped by another
3113 : consensus fork at some point in the past. In this case no need to
3114 : clear it, but we should update parent_slot */
3115 0 : slot->parent_slot = slot_completed->parent_slot;
3116 0 : } else {
3117 0 : slot = fd_gui_clear_slot( gui, slot_completed->slot, slot_completed->parent_slot );
3118 0 : }
3119 :
3120 0 : if( FD_UNLIKELY( slot->mine ) ) {
3121 0 : fd_gui_leader_slot_t * lslot = fd_gui_get_leader_slot( gui, slot->slot );
3122 0 : if( FD_LIKELY( lslot ) ) fd_memcpy( lslot->block_hash.uc, slot_completed->block_hash.uc, sizeof(fd_hash_t) );
3123 0 : }
3124 :
3125 0 : slot->completed_time = slot_completed->completion_time_nanos;
3126 0 : slot->parent_slot = slot_completed->parent_slot;
3127 0 : slot->max_compute_units = fd_uint_if( slot_completed->cost_tracker.block_cost_limit==ULONG_MAX, slot->max_compute_units, (uint)slot_completed->cost_tracker.block_cost_limit );
3128 0 : if( FD_LIKELY( slot->level<FD_GUI_SLOT_LEVEL_COMPLETED ) ) {
3129 : /* Typically a slot goes from INCOMPLETE to COMPLETED but it can
3130 : happen that it starts higher. One such case is when we
3131 : optimistically confirm a higher slot that skips this one, but
3132 : then later we replay this one anyway to track the bank fork. */
3133 :
3134 0 : if( FD_LIKELY( gui->summary.slot_optimistically_confirmed!=ULONG_MAX && slot->slot<gui->summary.slot_optimistically_confirmed ) ) {
3135 : /* Cluster might have already optimistically confirmed by the time
3136 : we finish replaying it. */
3137 0 : slot->level = FD_GUI_SLOT_LEVEL_OPTIMISTICALLY_CONFIRMED;
3138 0 : } else {
3139 0 : slot->level = FD_GUI_SLOT_LEVEL_COMPLETED;
3140 0 : }
3141 0 : }
3142 0 : slot->vote_failed = fd_uint_if( slot_completed->vote_failed==ULONG_MAX, slot->vote_failed, (uint)slot_completed->vote_failed );
3143 0 : slot->vote_success = fd_uint_if( slot_completed->vote_success==ULONG_MAX, slot->vote_success, (uint)slot_completed->vote_success );
3144 0 : slot->nonvote_success = fd_uint_if( slot_completed->nonvote_success==ULONG_MAX, slot->nonvote_success, (uint)slot_completed->nonvote_success );
3145 0 : slot->nonvote_failed = fd_uint_if( slot_completed->nonvote_failed==ULONG_MAX, slot->nonvote_failed, (uint)slot_completed->nonvote_failed );
3146 :
3147 0 : slot->transaction_fee = slot_completed->transaction_fee;
3148 0 : slot->priority_fee = slot_completed->priority_fee;
3149 0 : slot->tips = slot_completed->tips;
3150 0 : slot->compute_units = fd_uint_if( slot_completed->cost_tracker.block_cost==ULONG_MAX, slot->compute_units, (uint)slot_completed->cost_tracker.block_cost );
3151 0 : slot->shred_cnt = fd_uint_if( slot_completed->shred_cnt==ULONG_MAX, slot->shred_cnt, (uint)slot_completed->shred_cnt );
3152 0 : slot->vote_slot = vote_slot;
3153 :
3154 0 : try_publish_vote_status( gui, slot_completed->slot );
3155 :
3156 0 : if( FD_UNLIKELY( gui->epoch.has_epoch[ 0 ] && slot->slot==gui->epoch.epochs[ 0 ].end_slot ) ) {
3157 0 : gui->epoch.epochs[ 0 ].end_time = slot->completed_time;
3158 0 : } else if( FD_UNLIKELY( gui->epoch.has_epoch[ 1 ] && slot->slot==gui->epoch.epochs[ 1 ].end_slot ) ) {
3159 0 : gui->epoch.epochs[ 1 ].end_time = slot->completed_time;
3160 0 : }
3161 :
3162 : /* Broadcast new skip rate if one of our slots got completed. */
3163 0 : if( FD_LIKELY( slot->mine ) ) {
3164 0 : for( ulong i=0UL; i<2UL; i++ ) {
3165 0 : if( FD_LIKELY( slot->slot>=gui->epoch.epochs[ i ].start_slot && slot->slot<=gui->epoch.epochs[ i ].end_slot ) ) {
3166 0 : fd_gui_printf_skip_rate( gui, i );
3167 0 : fd_http_server_ws_broadcast( gui->http );
3168 0 : break;
3169 0 : }
3170 0 : }
3171 0 : }
3172 :
3173 : /* We'll treat the latest slot_complete from replay as the reset slot.
3174 : We get an explicit reset_slot from tower, but that message may come
3175 : in before we get the slot_complete from replay. */
3176 0 : if( FD_UNLIKELY( gui->summary.slot_completed!=slot->slot ) ) {
3177 0 : fd_gui_handle_reset_slot( gui, slot->slot, now );
3178 0 : }
3179 :
3180 : /* Add a "slot complete" event for all of the shreds in this slot */
3181 0 : if( FD_UNLIKELY( slot->shred_cnt > FD_GUI_MAX_SHREDS_PER_BLOCK ) ) FD_LOG_ERR(( "unexpected shred_cnt=%lu", (ulong)slot->shred_cnt ));
3182 0 : fd_gui_slot_staged_shred_event_t * slot_complete_event = fd_gui_staged_push( gui );
3183 0 : slot_complete_event->event = FD_GUI_SLOT_SHRED_SHRED_SLOT_COMPLETE;
3184 0 : slot_complete_event->timestamp = slot_completed->completion_time_nanos;
3185 0 : slot_complete_event->shred_idx = USHORT_MAX;
3186 0 : slot_complete_event->slot = slot->slot;
3187 :
3188 : /* addresses racey behavior if we just sample at 400ms */
3189 0 : if( FD_LIKELY( gui->summary.slot_caught_up!=ULONG_MAX ) ) {
3190 0 : fd_topo_tile_t const * repair = &gui->topo->tiles[ fd_topo_find_tile( gui->topo, "repair", 0UL ) ];
3191 0 : volatile ulong const * repair_metrics = fd_metrics_tile( repair->metrics );
3192 0 : ulong slot = repair_metrics[ MIDX( GAUGE, REPAIR, REPAIRED_SLOTS ) ];
3193 0 : fd_gui_handle_repair_slot( gui, slot, now );
3194 0 : }
3195 0 : }
3196 :
3197 : void
3198 : fd_gui_plugin_message( fd_gui_t * gui,
3199 : ulong plugin_msg,
3200 : void const * msg,
3201 0 : long now ) {
3202 :
3203 0 : switch( plugin_msg ) {
3204 0 : case FD_PLUGIN_MSG_SLOT_ROOTED:
3205 0 : fd_gui_handle_rooted_slot_legacy( gui, msg );
3206 0 : break;
3207 0 : case FD_PLUGIN_MSG_SLOT_OPTIMISTICALLY_CONFIRMED:
3208 0 : fd_gui_handle_optimistically_confirmed_slot( gui, FD_LOAD( ulong, msg ) );
3209 0 : break;
3210 0 : case FD_PLUGIN_MSG_SLOT_COMPLETED: {
3211 0 : fd_gui_handle_completed_slot( gui, msg, now );
3212 0 : break;
3213 0 : }
3214 0 : case FD_PLUGIN_MSG_LEADER_SCHEDULE: {
3215 0 : FD_STATIC_ASSERT( sizeof(fd_stake_weight_msg_t)==6*sizeof(ulong), "new fields breaks things" );
3216 0 : fd_gui_handle_leader_schedule( gui, (fd_stake_weight_msg_t *)msg, now );
3217 0 : break;
3218 0 : }
3219 0 : case FD_PLUGIN_MSG_SLOT_START: {
3220 0 : ulong slot = FD_LOAD( ulong, msg );
3221 0 : ulong parent_slot = FD_LOAD( ulong, (uchar const *)msg + 8UL );
3222 0 : fd_gui_handle_slot_start( gui, slot, parent_slot, now );
3223 0 : break;
3224 0 : }
3225 0 : case FD_PLUGIN_MSG_SLOT_END: {
3226 0 : ulong slot = FD_LOAD( ulong, msg );
3227 0 : ulong cus_used = FD_LOAD( ulong, (uchar const *)msg + 8UL );
3228 0 : fd_gui_handle_slot_end( gui, slot, cus_used, now );
3229 0 : break;
3230 0 : }
3231 0 : case FD_PLUGIN_MSG_GOSSIP_UPDATE: {
3232 0 : fd_gui_handle_gossip_update( gui, msg );
3233 0 : break;
3234 0 : }
3235 0 : case FD_PLUGIN_MSG_VOTE_ACCOUNT_UPDATE: {
3236 0 : fd_gui_handle_vote_account_update( gui, msg );
3237 0 : break;
3238 0 : }
3239 0 : case FD_PLUGIN_MSG_VALIDATOR_INFO: {
3240 0 : fd_gui_handle_validator_info_update( gui, msg );
3241 0 : break;
3242 0 : }
3243 0 : case FD_PLUGIN_MSG_SLOT_RESET: {
3244 0 : fd_gui_handle_reset_slot_legacy( gui, msg, now );
3245 0 : break;
3246 0 : }
3247 0 : case FD_PLUGIN_MSG_BALANCE: {
3248 0 : fd_gui_handle_balance_update( gui, msg );
3249 0 : break;
3250 0 : }
3251 0 : case FD_PLUGIN_MSG_START_PROGRESS: {
3252 0 : fd_gui_handle_start_progress( gui, msg );
3253 0 : break;
3254 0 : }
3255 0 : case FD_PLUGIN_MSG_GENESIS_HASH_KNOWN: {
3256 0 : fd_gui_handle_genesis_hash( gui, msg );
3257 0 : break;
3258 0 : }
3259 0 : default:
3260 0 : FD_LOG_ERR(( "Unhandled plugin msg: 0x%lx", plugin_msg ));
3261 0 : break;
3262 0 : }
3263 0 : }
3264 :
3265 : void
3266 : fd_gui_became_leader( fd_gui_t * gui,
3267 : ulong _slot,
3268 : long start_time_nanos,
3269 : long end_time_nanos,
3270 : ulong max_compute_units,
3271 0 : ulong max_microblocks ) {
3272 0 : if( FD_LIKELY( gui->summary.is_full_client && gui->leader_slot!=ULONG_MAX ) ) {
3273 : /* stop sampling for other leader slot in progress */
3274 0 : fd_gui_handle_slot_end( gui, gui->leader_slot, ULONG_MAX, start_time_nanos );
3275 0 : }
3276 :
3277 0 : fd_gui_slot_t * slot = fd_gui_get_slot( gui, _slot );
3278 0 : if( FD_UNLIKELY( !slot ) ) slot = fd_gui_clear_slot( gui, _slot, ULONG_MAX );
3279 0 : fd_gui_leader_slot_t * lslot = fd_gui_get_leader_slot( gui, _slot );
3280 0 : if( FD_UNLIKELY( !lslot ) ) return;
3281 :
3282 0 : slot->max_compute_units = (uint)max_compute_units;
3283 0 : lslot->leader_start_time = fd_long_if( lslot->leader_start_time==LONG_MAX, start_time_nanos, lslot->leader_start_time );
3284 0 : lslot->leader_end_time = end_time_nanos;
3285 0 : lslot->max_microblocks = max_microblocks;
3286 0 : if( FD_LIKELY( lslot->txs.microblocks_upper_bound==UINT_MAX ) ) lslot->txs.microblocks_upper_bound = (uint)max_microblocks;
3287 :
3288 0 : if( FD_UNLIKELY( gui->summary.is_full_client ) ) fd_gui_handle_slot_start( gui, slot->slot, slot->parent_slot, start_time_nanos );
3289 0 : }
3290 :
3291 : void
3292 : fd_gui_unbecame_leader( fd_gui_t * gui,
3293 : ulong _slot,
3294 : fd_done_packing_t const * done_packing,
3295 0 : long now ) {
3296 0 : fd_gui_slot_t * slot = fd_gui_get_slot( gui, _slot );
3297 0 : if( FD_UNLIKELY( !slot ) ) slot = fd_gui_clear_slot( gui, _slot, ULONG_MAX );
3298 0 : fd_gui_leader_slot_t * lslot = fd_gui_get_leader_slot( gui, _slot );
3299 0 : if( FD_LIKELY( !lslot ) ) return;
3300 0 : lslot->txs.microblocks_upper_bound = (uint)done_packing->microblocks_in_slot;
3301 0 : fd_memcpy( lslot->scheduler_stats, done_packing, sizeof(fd_done_packing_t) );
3302 :
3303 : /* fd_gui_handle_slot_end may have already been called in response to
3304 : a "became_leader" message for a subseqeunt slot. */
3305 0 : if( FD_UNLIKELY( gui->summary.is_full_client && gui->leader_slot==_slot ) ) fd_gui_handle_slot_end( gui, slot->slot, ULONG_MAX, now );
3306 :
3307 0 : lslot->unbecame_leader = 1;
3308 0 : }
3309 :
3310 : void
3311 : fd_gui_microblock_execution_begin( fd_gui_t * gui,
3312 : long tspub_ns,
3313 : ulong _slot,
3314 : fd_txn_e_t * txns,
3315 : ulong txn_cnt,
3316 : uint microblock_idx,
3317 0 : ulong pack_txn_idx ) {
3318 0 : fd_gui_slot_t * slot = fd_gui_get_slot( gui, _slot );
3319 0 : if( FD_UNLIKELY( !slot ) ) slot = fd_gui_clear_slot( gui, _slot, ULONG_MAX );
3320 :
3321 0 : fd_gui_leader_slot_t * lslot = fd_gui_get_leader_slot( gui, _slot );
3322 0 : if( FD_UNLIKELY( !lslot ) ) return;
3323 :
3324 0 : lslot->leader_start_time = fd_long_if( lslot->leader_start_time==LONG_MAX, tspub_ns, lslot->leader_start_time );
3325 :
3326 0 : if( FD_UNLIKELY( lslot->txs.start_offset==ULONG_MAX ) ) lslot->txs.start_offset = pack_txn_idx;
3327 0 : else lslot->txs.start_offset = fd_ulong_min( lslot->txs.start_offset, pack_txn_idx );
3328 :
3329 0 : gui->pack_txn_idx = fd_ulong_max( gui->pack_txn_idx, pack_txn_idx+txn_cnt-1UL );
3330 :
3331 0 : for( ulong i=0UL; i<txn_cnt; i++ ) {
3332 0 : fd_txn_p_t * txn_payload = txns[ i ].txnp;
3333 0 : fd_txn_t * txn = TXN( txn_payload );
3334 :
3335 0 : ulong sig_rewards = FD_PACK_FEE_PER_SIGNATURE * txn->signature_cnt;
3336 0 : ulong priority_rewards = ULONG_MAX;
3337 0 : ulong requested_execution_cus = ULONG_MAX;
3338 0 : ulong precompile_sigs = ULONG_MAX;
3339 0 : ulong requested_loaded_accounts_data_cost = ULONG_MAX;
3340 0 : ulong allocated_data = ULONG_MAX;
3341 0 : uint _flags;
3342 0 : ulong cost_estimate = fd_pack_compute_cost( txn, txn_payload->payload, &_flags, &requested_execution_cus, &priority_rewards, &precompile_sigs, &requested_loaded_accounts_data_cost, &allocated_data );
3343 0 : sig_rewards += FD_PACK_FEE_PER_SIGNATURE * precompile_sigs;
3344 0 : sig_rewards = sig_rewards * FD_PACK_TXN_FEE_BURN_PCT / 100UL;
3345 :
3346 0 : fd_gui_txn_t * txn_entry = gui->txs[ (pack_txn_idx + i)%FD_GUI_TXN_HISTORY_SZ ];
3347 :
3348 : /* If execution_end already ran for this txn, the arrival timestamp
3349 : it stamped will match. Preserve all existing flags. Otherwise
3350 : the entry is stale from a ring buffer wrap-around, so clear all
3351 : flags. */
3352 0 : if( FD_LIKELY( txn_entry->timestamp_arrival_nanos!=txn_payload->scheduler_arrival_time_nanos ) ) txn_entry->flags = (uchar)0;
3353 :
3354 0 : fd_memcpy( txn_entry->signature, txn_payload->payload + txn->signature_off, FD_SHA512_HASH_SZ );
3355 0 : txn_entry->timestamp_arrival_nanos = txn_payload->scheduler_arrival_time_nanos;
3356 0 : txn_entry->compute_units_requested = cost_estimate & 0x1FFFFFU;
3357 0 : txn_entry->priority_fee = priority_rewards;
3358 0 : txn_entry->transaction_fee = sig_rewards;
3359 0 : txn_entry->microblock_start_ns_dt = (float)(tspub_ns - lslot->leader_start_time);
3360 0 : txn_entry->source_ipv4 = txn_payload->source_ipv4;
3361 0 : txn_entry->source_tpu = txn_payload->source_tpu;
3362 0 : txn_entry->microblock_idx = microblock_idx;
3363 0 : txn_entry->flags |= (uchar)FD_GUI_TXN_FLAGS_STARTED;
3364 0 : txn_entry->flags |= (uchar)fd_uint_if( !!(txn_payload->flags & FD_TXN_P_FLAGS_IS_SIMPLE_VOTE), FD_GUI_TXN_FLAGS_IS_SIMPLE_VOTE, 0U );
3365 0 : txn_entry->flags |= (uchar)fd_uint_if( (txn_payload->flags & FD_TXN_P_FLAGS_BUNDLE) || (txn_payload->flags & FD_TXN_P_FLAGS_INITIALIZER_BUNDLE), FD_GUI_TXN_FLAGS_FROM_BUNDLE, 0U );
3366 0 : }
3367 :
3368 : /* At the moment, bank publishes at most 1 transaction per microblock,
3369 : even if it received microblocks with multiple transactions
3370 : (i.e. a bundle). This means that we need to calculate microblock
3371 : count here based on the transaction count. */
3372 0 : lslot->txs.begin_microblocks += (uint)txn_cnt;
3373 0 : }
3374 :
3375 : void
3376 : fd_gui_microblock_execution_end( fd_gui_t * gui,
3377 : long tspub_ns,
3378 : ulong bank_idx,
3379 : ulong _slot,
3380 : ulong txn_cnt,
3381 : fd_txn_p_t * txns,
3382 : ulong pack_txn_idx,
3383 : fd_txn_ns_dt_t txn_ns_dt,
3384 0 : ulong tips ) {
3385 0 : if( FD_UNLIKELY( 1UL!=txn_cnt ) ) FD_LOG_ERR(( "gui expects 1 txn per microblock from bank, found %lu", txn_cnt ));
3386 :
3387 0 : fd_gui_slot_t * slot = fd_gui_get_slot( gui, _slot );
3388 0 : if( FD_UNLIKELY( !slot ) ) slot = fd_gui_clear_slot( gui, _slot, ULONG_MAX );
3389 :
3390 0 : fd_gui_leader_slot_t * lslot = fd_gui_get_leader_slot( gui, _slot );
3391 0 : if( FD_UNLIKELY( !lslot ) ) return;
3392 :
3393 0 : lslot->leader_start_time = fd_long_if( lslot->leader_start_time==LONG_MAX, tspub_ns, lslot->leader_start_time );
3394 :
3395 0 : if( FD_UNLIKELY( lslot->txs.end_offset==ULONG_MAX ) ) lslot->txs.end_offset = pack_txn_idx + txn_cnt;
3396 0 : else lslot->txs.end_offset = fd_ulong_max( lslot->txs.end_offset, pack_txn_idx+txn_cnt );
3397 :
3398 0 : gui->pack_txn_idx = fd_ulong_max( gui->pack_txn_idx, pack_txn_idx+txn_cnt-1UL );
3399 :
3400 0 : for( ulong i=0UL; i<txn_cnt; i++ ) {
3401 0 : fd_txn_p_t * txn_p = &txns[ i ];
3402 :
3403 0 : fd_gui_txn_t * txn_entry = gui->txs[ (pack_txn_idx + i)%FD_GUI_TXN_HISTORY_SZ ];
3404 :
3405 : /* If execution_begin already ran for this txn, the arrival
3406 : timestamp it stamped will match. Preserve all existing flags.
3407 : Otherwise the entry is stale from a ring buffer wrap-around, so
3408 : clear all flags. */
3409 0 : if( FD_UNLIKELY( txn_entry->timestamp_arrival_nanos!=txn_p->scheduler_arrival_time_nanos ) ) txn_entry->flags = (uchar)0;
3410 :
3411 0 : txn_entry->timestamp_arrival_nanos = txn_p->scheduler_arrival_time_nanos;
3412 0 : txn_entry->bank_idx = bank_idx & 0x3FU;
3413 0 : txn_entry->compute_units_consumed = txn_p->execle_cu.actual_consumed_cus & 0x1FFFFFU;
3414 0 : txn_entry->error_code = (txn_p->flags >> 24) & 0x3FU;
3415 0 : txn_entry->microblock_end_ns_dt = (float)(tspub_ns - lslot->leader_start_time);
3416 0 : txn_entry->txn_ns_dt = txn_ns_dt;
3417 0 : txn_entry->tips = tips;
3418 0 : txn_entry->flags |= (uchar)FD_GUI_TXN_FLAGS_ENDED;
3419 0 : txn_entry->flags &= (uchar)(~(uchar)FD_GUI_TXN_FLAGS_LANDED_IN_BLOCK);
3420 0 : txn_entry->flags |= (uchar)fd_uint_if( !!(txn_p->flags & FD_TXN_P_FLAGS_EXECUTE_SUCCESS), FD_GUI_TXN_FLAGS_LANDED_IN_BLOCK, 0U );
3421 0 : }
3422 :
3423 0 : lslot->txs.end_microblocks = lslot->txs.end_microblocks + (uint)txn_cnt;
3424 0 : }
|