Line data Source code
1 : #include "fd_gui.h"
2 : #include "fd_gui_printf.h"
3 :
4 : #include "../metrics/fd_metrics.h"
5 : #include "../plugin/fd_plugin.h"
6 :
7 : #include "../../ballet/base58/fd_base58.h"
8 : #include "../../ballet/json/cJSON.h"
9 : #include "../../disco/genesis/fd_genesis_cluster.h"
10 : #include "../../disco/pack/fd_pack.h"
11 : #include "../../disco/pack/fd_pack_cost.h"
12 :
13 : #include <stdio.h>
14 :
15 : FD_FN_CONST ulong
16 0 : fd_gui_align( void ) {
17 0 : return 128UL;
18 0 : }
19 :
20 : FD_FN_CONST ulong
21 0 : fd_gui_footprint( void ) {
22 0 : return sizeof(fd_gui_t);
23 0 : }
24 :
25 : void *
26 : fd_gui_new( void * shmem,
27 : fd_http_server_t * http,
28 : char const * version,
29 : char const * cluster,
30 : uchar const * identity_key,
31 : int has_vote_key,
32 : uchar const * vote_key,
33 : int is_full_client,
34 : int snapshots_enabled,
35 : int is_voting,
36 : int schedule_strategy,
37 : fd_topo_t * topo,
38 0 : long now ) {
39 :
40 0 : if( FD_UNLIKELY( !shmem ) ) {
41 0 : FD_LOG_WARNING(( "NULL shmem" ));
42 0 : return NULL;
43 0 : }
44 :
45 0 : if( FD_UNLIKELY( !fd_ulong_is_aligned( (ulong)shmem, fd_gui_align() ) ) ) {
46 0 : FD_LOG_WARNING(( "misaligned shmem" ));
47 0 : return NULL;
48 0 : }
49 :
50 0 : if( FD_UNLIKELY( topo->tile_cnt>FD_GUI_TILE_TIMER_TILE_CNT ) ) {
51 0 : FD_LOG_WARNING(( "too many tiles" ));
52 0 : return NULL;
53 0 : }
54 :
55 0 : fd_gui_t * gui = (fd_gui_t *)shmem;
56 :
57 0 : gui->http = http;
58 0 : gui->topo = topo;
59 :
60 0 : gui->debug_in_leader_slot = ULONG_MAX;
61 0 : gui->summary.schedule_strategy = schedule_strategy;
62 :
63 :
64 0 : gui->next_sample_400millis = now;
65 0 : gui->next_sample_100millis = now;
66 0 : gui->next_sample_10millis = now;
67 :
68 0 : memcpy( gui->summary.identity_key->uc, identity_key, 32UL );
69 0 : fd_base58_encode_32( identity_key, NULL, gui->summary.identity_key_base58 );
70 0 : gui->summary.identity_key_base58[ FD_BASE58_ENCODED_32_SZ-1UL ] = '\0';
71 :
72 0 : if( FD_LIKELY( has_vote_key ) ) {
73 0 : gui->summary.has_vote_key = 1;
74 0 : memcpy( gui->summary.vote_key->uc, vote_key, 32UL );
75 0 : fd_base58_encode_32( vote_key, NULL, gui->summary.vote_key_base58 );
76 0 : gui->summary.vote_key_base58[ FD_BASE58_ENCODED_32_SZ-1UL ] = '\0';
77 0 : } else {
78 0 : gui->summary.has_vote_key = 0;
79 0 : memset( gui->summary.vote_key_base58, 0, sizeof(gui->summary.vote_key_base58) );
80 0 : }
81 :
82 0 : gui->summary.is_full_client = is_full_client;
83 0 : gui->summary.version = version;
84 0 : gui->summary.cluster = cluster;
85 0 : gui->summary.startup_time_nanos = gui->next_sample_400millis;
86 :
87 0 : if( FD_UNLIKELY( is_full_client ) ) {
88 0 : if( FD_UNLIKELY( snapshots_enabled ) ) {
89 0 : gui->summary.boot_progress.phase = FD_GUI_BOOT_PROGRESS_TYPE_JOINING_GOSSIP;
90 0 : gui->summary.boot_progress.joining_gossip_time_nanos = gui->next_sample_400millis;
91 0 : for( ulong i=0UL; i<FD_GUI_BOOT_PROGRESS_SNAPSHOT_CNT; i++ ) {
92 0 : gui->summary.boot_progress.loading_snapshot[ i ].reset_cnt = ULONG_MAX; /* ensures other fields are reset initially */
93 0 : gui->summary.boot_progress.loading_snapshot[ i ].read_path[ 0 ] = '\0';
94 0 : gui->summary.boot_progress.loading_snapshot[ i ].insert_path[ 0 ] = '\0';
95 0 : }
96 0 : } else {
97 0 : fd_memset( &gui->summary.boot_progress, 0, sizeof(gui->summary.boot_progress) );
98 0 : gui->summary.boot_progress.phase = FD_GUI_BOOT_PROGRESS_TYPE_RUNNING;
99 0 : }
100 0 : } else {
101 0 : gui->summary.startup_progress.phase = FD_GUI_START_PROGRESS_TYPE_INITIALIZING;
102 0 : gui->summary.startup_progress.startup_got_full_snapshot = 0;
103 0 : gui->summary.startup_progress.startup_full_snapshot_slot = 0;
104 0 : gui->summary.startup_progress.startup_incremental_snapshot_slot = 0;
105 0 : gui->summary.startup_progress.startup_waiting_for_supermajority_slot = ULONG_MAX;
106 0 : gui->summary.startup_progress.startup_ledger_max_slot = ULONG_MAX;
107 0 : }
108 :
109 0 : gui->summary.identity_account_balance = 0UL;
110 0 : gui->summary.vote_account_balance = 0UL;
111 0 : gui->summary.estimated_slot_duration_nanos = 0UL;
112 :
113 0 : gui->summary.vote_distance = 0UL;
114 0 : gui->summary.vote_state = is_voting ? FD_GUI_VOTE_STATE_VOTING : FD_GUI_VOTE_STATE_NON_VOTING;
115 :
116 0 : gui->summary.sock_tile_cnt = fd_topo_tile_name_cnt( gui->topo, "sock" );
117 0 : gui->summary.net_tile_cnt = fd_topo_tile_name_cnt( gui->topo, "net" );
118 0 : gui->summary.quic_tile_cnt = fd_topo_tile_name_cnt( gui->topo, "quic" );
119 0 : gui->summary.verify_tile_cnt = fd_topo_tile_name_cnt( gui->topo, "verify" );
120 0 : gui->summary.resolv_tile_cnt = fd_topo_tile_name_cnt( gui->topo, "resolv" );
121 0 : gui->summary.bank_tile_cnt = fd_topo_tile_name_cnt( gui->topo, "bank" );
122 0 : gui->summary.shred_tile_cnt = fd_topo_tile_name_cnt( gui->topo, "shred" );
123 :
124 0 : gui->summary.slot_rooted = ULONG_MAX;
125 0 : gui->summary.slot_optimistically_confirmed = ULONG_MAX;
126 0 : gui->summary.slot_completed = ULONG_MAX;
127 0 : gui->summary.slot_estimated = ULONG_MAX;
128 0 : gui->summary.slot_caught_up = ULONG_MAX;
129 0 : gui->summary.slot_repair = ULONG_MAX;
130 0 : gui->summary.slot_turbine = ULONG_MAX;
131 :
132 0 : for( ulong i=0UL; i < (FD_GUI_REPAIR_SLOT_HISTORY_SZ+1UL); i++ ) gui->summary.slots_max_repair[ i ].slot = ULONG_MAX;
133 0 : for( ulong i=0UL; i < (FD_GUI_TURBINE_SLOT_HISTORY_SZ+1UL); i++ ) gui->summary.slots_max_turbine[ i ].slot = ULONG_MAX;
134 :
135 0 : gui->summary.estimated_tps_history_idx = 0UL;
136 0 : memset( gui->summary.estimated_tps_history, 0, sizeof(gui->summary.estimated_tps_history) );
137 :
138 0 : memset( gui->summary.txn_waterfall_reference, 0, sizeof(gui->summary.txn_waterfall_reference) );
139 0 : memset( gui->summary.txn_waterfall_current, 0, sizeof(gui->summary.txn_waterfall_current) );
140 :
141 0 : memset( gui->summary.tile_stats_reference, 0, sizeof(gui->summary.tile_stats_reference) );
142 0 : memset( gui->summary.tile_stats_current, 0, sizeof(gui->summary.tile_stats_current) );
143 :
144 0 : memset( gui->summary.tile_timers_snap[ 0 ], 0, sizeof(gui->summary.tile_timers_snap[ 0 ]) );
145 0 : memset( gui->summary.tile_timers_snap[ 1 ], 0, sizeof(gui->summary.tile_timers_snap[ 1 ]) );
146 0 : gui->summary.tile_timers_snap_idx = 2UL;
147 :
148 0 : for( ulong i=0UL; i<FD_GUI_SLOTS_CNT; i++ ) gui->slots[ i ]->slot = ULONG_MAX;
149 0 : for( ulong i=0UL; i<FD_GUI_LEADER_CNT; i++ ) gui->leader_slots[ i ]->slot = ULONG_MAX;
150 0 : gui->leader_slots_cnt = 0UL;
151 :
152 :
153 0 : gui->block_engine.has_block_engine = 0;
154 :
155 0 : gui->epoch.has_epoch[ 0 ] = 0;
156 0 : gui->epoch.has_epoch[ 1 ] = 0;
157 :
158 0 : gui->gossip.peer_cnt = 0UL;
159 0 : gui->vote_account.vote_account_cnt = 0UL;
160 0 : gui->validator_info.info_cnt = 0UL;
161 :
162 0 : gui->pack_txn_idx = 0UL;
163 :
164 0 : gui->shreds.staged_next_broadcast = 0UL;
165 0 : gui->shreds.staged_head = 0UL;
166 0 : gui->shreds.staged_tail = 0UL;
167 0 : gui->shreds.history_tail = 0UL;
168 0 : gui->shreds.history_slot = ULONG_MAX;
169 0 : gui->summary.catch_up_repair_sz = 0UL;
170 0 : gui->summary.catch_up_turbine_sz = 0UL;
171 :
172 0 : return gui;
173 0 : }
174 :
175 : fd_gui_t *
176 0 : fd_gui_join( void * shmem ) {
177 0 : return (fd_gui_t *)shmem;
178 0 : }
179 :
180 : void
181 : fd_gui_set_identity( fd_gui_t * gui,
182 0 : uchar const * identity_pubkey ) {
183 0 : memcpy( gui->summary.identity_key->uc, identity_pubkey, 32UL );
184 0 : fd_base58_encode_32( identity_pubkey, NULL, gui->summary.identity_key_base58 );
185 0 : gui->summary.identity_key_base58[ FD_BASE58_ENCODED_32_SZ-1UL ] = '\0';
186 :
187 0 : fd_gui_printf_identity_key( gui );
188 0 : fd_http_server_ws_broadcast( gui->http );
189 :
190 0 : fd_gui_printf_identity_balance( gui );
191 0 : fd_http_server_ws_broadcast( gui->http );
192 0 : }
193 :
194 : void
195 : fd_gui_ws_open( fd_gui_t * gui,
196 0 : ulong ws_conn_id ) {
197 0 : void (* printers[] )( fd_gui_t * gui ) = {
198 0 : gui->summary.is_full_client ? fd_gui_printf_boot_progress : fd_gui_printf_startup_progress,
199 0 : fd_gui_printf_version,
200 0 : fd_gui_printf_cluster,
201 0 : fd_gui_printf_commit_hash,
202 0 : fd_gui_printf_identity_key,
203 0 : fd_gui_printf_vote_key,
204 0 : fd_gui_printf_startup_time_nanos,
205 0 : fd_gui_printf_vote_state,
206 0 : fd_gui_printf_vote_distance,
207 0 : fd_gui_printf_turbine_slot,
208 0 : fd_gui_printf_repair_slot,
209 0 : fd_gui_printf_slot_caught_up,
210 0 : fd_gui_printf_skipped_history,
211 0 : fd_gui_printf_skipped_history_cluster,
212 0 : fd_gui_printf_tps_history,
213 0 : fd_gui_printf_tiles,
214 0 : fd_gui_printf_schedule_strategy,
215 0 : fd_gui_printf_identity_balance,
216 0 : fd_gui_printf_vote_balance,
217 0 : fd_gui_printf_estimated_slot_duration_nanos,
218 0 : fd_gui_printf_root_slot,
219 0 : fd_gui_printf_optimistically_confirmed_slot,
220 0 : fd_gui_printf_completed_slot,
221 0 : fd_gui_printf_estimated_slot,
222 0 : fd_gui_printf_live_tile_timers,
223 0 : fd_gui_printf_catch_up_history,
224 0 : };
225 :
226 0 : ulong printers_len = sizeof(printers) / sizeof(printers[0]);
227 0 : for( ulong i=0UL; i<printers_len; i++ ) {
228 0 : printers[ i ]( gui );
229 0 : FD_TEST( !fd_http_server_ws_send( gui->http, ws_conn_id ) );
230 0 : }
231 :
232 0 : if( FD_LIKELY( gui->block_engine.has_block_engine ) ) {
233 0 : fd_gui_printf_block_engine( gui );
234 0 : FD_TEST( !fd_http_server_ws_send( gui->http, ws_conn_id ) );
235 0 : }
236 :
237 0 : for( ulong i=0UL; i<2UL; i++ ) {
238 0 : if( FD_LIKELY( gui->epoch.has_epoch[ i ] ) ) {
239 0 : fd_gui_printf_skip_rate( gui, i );
240 0 : FD_TEST( !fd_http_server_ws_send( gui->http, ws_conn_id ) );
241 0 : fd_gui_printf_epoch( gui, i );
242 0 : FD_TEST( !fd_http_server_ws_send( gui->http, ws_conn_id ) );
243 0 : }
244 0 : }
245 :
246 : /* Print peers last because it's the largest message and would
247 : block other information. */
248 0 : fd_gui_printf_peers_all( gui );
249 0 : FD_TEST( !fd_http_server_ws_send( gui->http, ws_conn_id ) );
250 0 : }
251 :
252 : static void
253 0 : fd_gui_tile_timers_snap( fd_gui_t * gui ) {
254 0 : fd_gui_tile_timers_t * cur = gui->summary.tile_timers_snap[ gui->summary.tile_timers_snap_idx ];
255 0 : gui->summary.tile_timers_snap_idx = (gui->summary.tile_timers_snap_idx+1UL)%FD_GUI_TILE_TIMER_SNAP_CNT;
256 0 : for( ulong i=0UL; i<gui->topo->tile_cnt; i++ ) {
257 0 : fd_topo_tile_t * tile = &gui->topo->tiles[ i ];
258 0 : if ( FD_UNLIKELY( !tile->metrics ) ) {
259 : /* bench tiles might not have been booted initially.
260 : This check shouldn't be necessary if all tiles barrier after boot. */
261 : // TODO(FIXME) this probably isn't the right fix but it makes fddev bench work for now
262 0 : return;
263 0 : }
264 0 : volatile ulong const * tile_metrics = fd_metrics_tile( tile->metrics );
265 :
266 0 : cur[ i ].caughtup_housekeeping_ticks = tile_metrics[ MIDX( COUNTER, TILE, REGIME_DURATION_NANOS_CAUGHT_UP_HOUSEKEEPING ) ];
267 0 : cur[ i ].processing_housekeeping_ticks = tile_metrics[ MIDX( COUNTER, TILE, REGIME_DURATION_NANOS_PROCESSING_HOUSEKEEPING ) ];
268 0 : cur[ i ].backpressure_housekeeping_ticks = tile_metrics[ MIDX( COUNTER, TILE, REGIME_DURATION_NANOS_BACKPRESSURE_HOUSEKEEPING ) ];
269 0 : cur[ i ].caughtup_prefrag_ticks = tile_metrics[ MIDX( COUNTER, TILE, REGIME_DURATION_NANOS_CAUGHT_UP_PREFRAG ) ];
270 0 : cur[ i ].processing_prefrag_ticks = tile_metrics[ MIDX( COUNTER, TILE, REGIME_DURATION_NANOS_PROCESSING_PREFRAG ) ];
271 0 : cur[ i ].backpressure_prefrag_ticks = tile_metrics[ MIDX( COUNTER, TILE, REGIME_DURATION_NANOS_BACKPRESSURE_PREFRAG ) ];
272 0 : cur[ i ].caughtup_postfrag_ticks = tile_metrics[ MIDX( COUNTER, TILE, REGIME_DURATION_NANOS_CAUGHT_UP_POSTFRAG ) ];
273 0 : cur[ i ].processing_postfrag_ticks = tile_metrics[ MIDX( COUNTER, TILE, REGIME_DURATION_NANOS_PROCESSING_POSTFRAG ) ];
274 0 : }
275 0 : }
276 :
277 : static void
278 0 : fd_gui_estimated_tps_snap( fd_gui_t * gui ) {
279 0 : ulong total_txn_cnt = 0UL;
280 0 : ulong vote_txn_cnt = 0UL;
281 0 : ulong nonvote_failed_txn_cnt = 0UL;
282 :
283 0 : if( FD_LIKELY( gui->summary.slot_completed==ULONG_MAX ) ) return;
284 0 : for( ulong i=0UL; i<fd_ulong_min( gui->summary.slot_completed+1UL, FD_GUI_SLOTS_CNT ); i++ ) {
285 0 : ulong _slot = gui->summary.slot_completed-i;
286 0 : fd_gui_slot_t const * slot = fd_gui_get_slot_const( gui, _slot );
287 0 : if( FD_UNLIKELY( !slot ) ) break; /* Slot no longer exists, no TPS. */
288 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. */
289 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. */
290 0 : if( FD_UNLIKELY( slot->skipped ) ) continue; /* Skipped slots don't count to TPS. */
291 :
292 0 : total_txn_cnt += slot->total_txn_cnt;
293 0 : vote_txn_cnt += slot->vote_txn_cnt;
294 0 : nonvote_failed_txn_cnt += slot->nonvote_failed_txn_cnt;
295 0 : }
296 :
297 0 : gui->summary.estimated_tps_history[ gui->summary.estimated_tps_history_idx ][ 0 ] = total_txn_cnt;
298 0 : gui->summary.estimated_tps_history[ gui->summary.estimated_tps_history_idx ][ 1 ] = vote_txn_cnt;
299 0 : gui->summary.estimated_tps_history[ gui->summary.estimated_tps_history_idx ][ 2 ] = nonvote_failed_txn_cnt;
300 0 : gui->summary.estimated_tps_history_idx = (gui->summary.estimated_tps_history_idx+1UL) % FD_GUI_TPS_HISTORY_SAMPLE_CNT;
301 0 : }
302 :
303 : /* Snapshot all of the data from metrics to construct a view of the
304 : transaction waterfall.
305 :
306 : Tiles are sampled in reverse pipeline order: this helps prevent data
307 : discrepancies where a later tile has "seen" more transactions than an
308 : earlier tile, which shouldn't typically happen. */
309 :
310 : static void
311 : fd_gui_txn_waterfall_snap( fd_gui_t * gui,
312 0 : fd_gui_txn_waterfall_t * cur ) {
313 0 : fd_topo_t * topo = gui->topo;
314 :
315 0 : cur->out.block_success = 0UL;
316 0 : cur->out.block_fail = 0UL;
317 :
318 0 : cur->out.bank_invalid = 0UL;
319 0 : for( ulong i=0UL; i<gui->summary.bank_tile_cnt; i++ ) {
320 0 : fd_topo_tile_t const * bank = &topo->tiles[ fd_topo_find_tile( topo, "bank", i ) ];
321 :
322 0 : volatile ulong const * bank_metrics = fd_metrics_tile( bank->metrics );
323 :
324 0 : cur->out.block_success += bank_metrics[ MIDX( COUNTER, BANK, SUCCESSFUL_TRANSACTIONS ) ];
325 :
326 0 : cur->out.block_fail +=
327 0 : bank_metrics[ MIDX( COUNTER, BANK, EXECUTED_FAILED_TRANSACTIONS ) ]
328 0 : + bank_metrics[ MIDX( COUNTER, BANK, FEE_ONLY_TRANSACTIONS ) ];
329 :
330 0 : cur->out.bank_invalid +=
331 0 : bank_metrics[ MIDX( COUNTER, BANK, TRANSACTION_LOAD_ADDRESS_TABLES_SLOT_HASHES_SYSVAR_NOT_FOUND ) ]
332 0 : + bank_metrics[ MIDX( COUNTER, BANK, TRANSACTION_LOAD_ADDRESS_TABLES_ACCOUNT_NOT_FOUND ) ]
333 0 : + bank_metrics[ MIDX( COUNTER, BANK, TRANSACTION_LOAD_ADDRESS_TABLES_INVALID_ACCOUNT_OWNER ) ]
334 0 : + bank_metrics[ MIDX( COUNTER, BANK, TRANSACTION_LOAD_ADDRESS_TABLES_INVALID_ACCOUNT_DATA ) ]
335 0 : + bank_metrics[ MIDX( COUNTER, BANK, TRANSACTION_LOAD_ADDRESS_TABLES_INVALID_INDEX ) ];
336 :
337 0 : cur->out.bank_invalid +=
338 0 : bank_metrics[ MIDX( COUNTER, BANK, PROCESSING_FAILED ) ];
339 0 : }
340 :
341 :
342 0 : fd_topo_tile_t const * pack = &topo->tiles[ fd_topo_find_tile( topo, "pack", 0UL ) ];
343 0 : volatile ulong const * pack_metrics = fd_metrics_tile( pack->metrics );
344 :
345 0 : cur->out.pack_invalid_bundle =
346 0 : pack_metrics[ MIDX( COUNTER, PACK, TRANSACTION_DROPPED_PARTIAL_BUNDLE ) ]
347 0 : + pack_metrics[ MIDX( COUNTER, PACK, BUNDLE_CRANK_STATUS_INSERTION_FAILED ) ]
348 0 : + pack_metrics[ MIDX( COUNTER, PACK, BUNDLE_CRANK_STATUS_CREATION_FAILED ) ];
349 :
350 0 : cur->out.pack_invalid =
351 0 : pack_metrics[ MIDX( COUNTER, PACK, TRANSACTION_INSERTED_NONCE_CONFLICT ) ]
352 0 : + pack_metrics[ MIDX( COUNTER, PACK, TRANSACTION_INSERTED_BUNDLE_BLACKLIST ) ]
353 0 : + pack_metrics[ MIDX( COUNTER, PACK, TRANSACTION_INSERTED_INVALID_NONCE ) ]
354 0 : + pack_metrics[ MIDX( COUNTER, PACK, TRANSACTION_INSERTED_WRITE_SYSVAR ) ]
355 0 : + pack_metrics[ MIDX( COUNTER, PACK, TRANSACTION_INSERTED_ESTIMATION_FAIL ) ]
356 0 : + pack_metrics[ MIDX( COUNTER, PACK, TRANSACTION_INSERTED_DUPLICATE_ACCOUNT ) ]
357 0 : + pack_metrics[ MIDX( COUNTER, PACK, TRANSACTION_INSERTED_TOO_MANY_ACCOUNTS ) ]
358 0 : + pack_metrics[ MIDX( COUNTER, PACK, TRANSACTION_INSERTED_TOO_LARGE ) ]
359 0 : + pack_metrics[ MIDX( COUNTER, PACK, TRANSACTION_INSERTED_ADDR_LUT ) ]
360 0 : + pack_metrics[ MIDX( COUNTER, PACK, TRANSACTION_INSERTED_UNAFFORDABLE ) ]
361 0 : + pack_metrics[ MIDX( COUNTER, PACK, TRANSACTION_INSERTED_DUPLICATE ) ]
362 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 */
363 :
364 0 : cur->out.pack_expired = pack_metrics[ MIDX( COUNTER, PACK, TRANSACTION_INSERTED_EXPIRED ) ] +
365 0 : pack_metrics[ MIDX( COUNTER, PACK, TRANSACTION_EXPIRED ) ] +
366 0 : pack_metrics[ MIDX( COUNTER, PACK, TRANSACTION_DELETED ) ] +
367 0 : pack_metrics[ MIDX( COUNTER, PACK, TRANSACTION_INSERTED_NONCE_PRIORITY ) ];
368 :
369 0 : cur->out.pack_leader_slow = pack_metrics[ MIDX( COUNTER, PACK, TRANSACTION_INSERTED_PRIORITY ) ];
370 :
371 0 : cur->out.pack_wait_full =
372 0 : pack_metrics[ MIDX( COUNTER, PACK, TRANSACTION_DROPPED_FROM_EXTRA ) ];
373 :
374 0 : cur->out.pack_retained = pack_metrics[ MIDX( GAUGE, PACK, AVAILABLE_TRANSACTIONS ) ];
375 :
376 0 : ulong inserted_to_extra = pack_metrics[ MIDX( COUNTER, PACK, TRANSACTION_INSERTED_TO_EXTRA ) ];
377 0 : ulong inserted_from_extra = pack_metrics[ MIDX( COUNTER, PACK, TRANSACTION_INSERTED_FROM_EXTRA ) ]
378 0 : + pack_metrics[ MIDX( COUNTER, PACK, TRANSACTION_DROPPED_FROM_EXTRA ) ];
379 0 : cur->out.pack_retained += fd_ulong_if( inserted_to_extra>=inserted_from_extra, inserted_to_extra-inserted_from_extra, 0UL );
380 :
381 0 : cur->out.resolv_lut_failed = 0UL;
382 0 : cur->out.resolv_expired = 0UL;
383 0 : cur->out.resolv_ancient = 0UL;
384 0 : cur->out.resolv_no_ledger = 0UL;
385 0 : cur->out.resolv_retained = 0UL;
386 0 : for( ulong i=0UL; i<gui->summary.resolv_tile_cnt; i++ ) {
387 0 : fd_topo_tile_t const * resolv = &topo->tiles[ fd_topo_find_tile( topo, "resolv", i ) ];
388 0 : volatile ulong const * resolv_metrics = fd_metrics_tile( resolv->metrics );
389 :
390 0 : cur->out.resolv_no_ledger += resolv_metrics[ MIDX( COUNTER, RESOLV, NO_BANK_DROP ) ];
391 0 : cur->out.resolv_expired += resolv_metrics[ MIDX( COUNTER, RESOLV, BLOCKHASH_EXPIRED ) ]
392 0 : + resolv_metrics[ MIDX( COUNTER, RESOLV, TRANSACTION_BUNDLE_PEER_FAILURE ) ];
393 0 : cur->out.resolv_lut_failed += resolv_metrics[ MIDX( COUNTER, RESOLV, LUT_RESOLVED_ACCOUNT_NOT_FOUND ) ]
394 0 : + resolv_metrics[ MIDX( COUNTER, RESOLV, LUT_RESOLVED_INVALID_ACCOUNT_OWNER ) ]
395 0 : + resolv_metrics[ MIDX( COUNTER, RESOLV, LUT_RESOLVED_INVALID_ACCOUNT_DATA ) ]
396 0 : + resolv_metrics[ MIDX( COUNTER, RESOLV, LUT_RESOLVED_ACCOUNT_UNINITIALIZED ) ]
397 0 : + resolv_metrics[ MIDX( COUNTER, RESOLV, LUT_RESOLVED_INVALID_LOOKUP_INDEX ) ];
398 0 : cur->out.resolv_ancient += resolv_metrics[ MIDX( COUNTER, RESOLV, STASH_OPERATION_OVERRUN ) ];
399 :
400 0 : ulong inserted_to_resolv = resolv_metrics[ MIDX( COUNTER, RESOLV, STASH_OPERATION_INSERTED ) ];
401 0 : ulong removed_from_resolv = resolv_metrics[ MIDX( COUNTER, RESOLV, STASH_OPERATION_OVERRUN ) ]
402 0 : + resolv_metrics[ MIDX( COUNTER, RESOLV, STASH_OPERATION_PUBLISHED ) ]
403 0 : + resolv_metrics[ MIDX( COUNTER, RESOLV, STASH_OPERATION_REMOVED ) ];
404 0 : cur->out.resolv_retained += fd_ulong_if( inserted_to_resolv>=removed_from_resolv, inserted_to_resolv-removed_from_resolv, 0UL );
405 0 : }
406 :
407 :
408 0 : fd_topo_tile_t const * dedup = &topo->tiles[ fd_topo_find_tile( topo, "dedup", 0UL ) ];
409 0 : volatile ulong const * dedup_metrics = fd_metrics_tile( dedup->metrics );
410 :
411 0 : cur->out.dedup_duplicate = dedup_metrics[ MIDX( COUNTER, DEDUP, TRANSACTION_DEDUP_FAILURE ) ]
412 0 : + dedup_metrics[ MIDX( COUNTER, DEDUP, TRANSACTION_BUNDLE_PEER_FAILURE ) ];
413 :
414 :
415 0 : cur->out.verify_overrun = 0UL;
416 0 : cur->out.verify_duplicate = 0UL;
417 0 : cur->out.verify_parse = 0UL;
418 0 : cur->out.verify_failed = 0UL;
419 :
420 0 : for( ulong i=0UL; i<gui->summary.verify_tile_cnt; i++ ) {
421 0 : fd_topo_tile_t const * verify = &topo->tiles[ fd_topo_find_tile( topo, "verify", i ) ];
422 0 : volatile ulong const * verify_metrics = fd_metrics_tile( verify->metrics );
423 :
424 0 : for( ulong j=0UL; j<gui->summary.quic_tile_cnt; j++ ) {
425 : /* TODO: Not precise... even if 1 frag gets skipped, it could have been for this verify tile. */
426 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;
427 0 : cur->out.verify_overrun += fd_metrics_link_in( verify->metrics, j )[ FD_METRICS_COUNTER_LINK_OVERRUN_READING_FRAG_COUNT_OFF ];
428 0 : }
429 :
430 0 : cur->out.verify_failed += verify_metrics[ MIDX( COUNTER, VERIFY, TRANSACTION_VERIFY_FAILURE ) ] +
431 0 : verify_metrics[ MIDX( COUNTER, VERIFY, TRANSACTION_BUNDLE_PEER_FAILURE ) ];
432 0 : cur->out.verify_parse += verify_metrics[ MIDX( COUNTER, VERIFY, TRANSACTION_PARSE_FAILURE ) ];
433 0 : cur->out.verify_duplicate += verify_metrics[ MIDX( COUNTER, VERIFY, TRANSACTION_DEDUP_FAILURE ) ];
434 0 : }
435 :
436 :
437 0 : cur->out.quic_overrun = 0UL;
438 0 : cur->out.quic_frag_drop = 0UL;
439 0 : cur->out.quic_abandoned = 0UL;
440 0 : cur->out.tpu_quic_invalid = 0UL;
441 0 : cur->out.tpu_udp_invalid = 0UL;
442 0 : for( ulong i=0UL; i<gui->summary.quic_tile_cnt; i++ ) {
443 0 : fd_topo_tile_t const * quic = &topo->tiles[ fd_topo_find_tile( topo, "quic", i ) ];
444 0 : volatile ulong * quic_metrics = fd_metrics_tile( quic->metrics );
445 :
446 0 : cur->out.tpu_udp_invalid += quic_metrics[ MIDX( COUNTER, QUIC, LEGACY_TXN_UNDERSZ ) ];
447 0 : cur->out.tpu_udp_invalid += quic_metrics[ MIDX( COUNTER, QUIC, LEGACY_TXN_OVERSZ ) ];
448 0 : cur->out.tpu_quic_invalid += quic_metrics[ MIDX( COUNTER, QUIC, PKT_UNDERSZ ) ];
449 0 : cur->out.tpu_quic_invalid += quic_metrics[ MIDX( COUNTER, QUIC, PKT_OVERSZ ) ];
450 0 : cur->out.tpu_quic_invalid += quic_metrics[ MIDX( COUNTER, QUIC, TXN_OVERSZ ) ];
451 0 : cur->out.tpu_quic_invalid += quic_metrics[ MIDX( COUNTER, QUIC, PKT_CRYPTO_FAILED ) ];
452 0 : cur->out.tpu_quic_invalid += quic_metrics[ MIDX( COUNTER, QUIC, PKT_NO_CONN ) ];
453 0 : cur->out.tpu_quic_invalid += quic_metrics[ MIDX( COUNTER, QUIC, PKT_NET_HEADER_INVALID ) ];
454 0 : cur->out.tpu_quic_invalid += quic_metrics[ MIDX( COUNTER, QUIC, PKT_QUIC_HEADER_INVALID ) ];
455 0 : cur->out.quic_abandoned += quic_metrics[ MIDX( COUNTER, QUIC, TXNS_ABANDONED ) ];
456 0 : cur->out.quic_frag_drop += quic_metrics[ MIDX( COUNTER, QUIC, TXNS_OVERRUN ) ];
457 :
458 0 : for( ulong j=0UL; j<gui->summary.net_tile_cnt; j++ ) {
459 : /* TODO: Not precise... net frags that were skipped might not have been destined for QUIC tile */
460 : /* TODO: Not precise... even if 1 frag gets skipped, it could have been for this QUIC tile */
461 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;
462 0 : cur->out.quic_overrun += fd_metrics_link_in( quic->metrics, j )[ FD_METRICS_COUNTER_LINK_OVERRUN_READING_FRAG_COUNT_OFF ];
463 0 : }
464 0 : }
465 :
466 0 : cur->out.net_overrun = 0UL;
467 0 : for( ulong i=0UL; i<gui->summary.net_tile_cnt; i++ ) {
468 0 : fd_topo_tile_t const * net = &topo->tiles[ fd_topo_find_tile( topo, "net", i ) ];
469 0 : volatile ulong * net_metrics = fd_metrics_tile( net->metrics );
470 :
471 0 : cur->out.net_overrun += net_metrics[ MIDX( COUNTER, NET, XDP_RX_RING_FULL ) ];
472 0 : cur->out.net_overrun += net_metrics[ MIDX( COUNTER, NET, XDP_RX_DROPPED_OTHER ) ];
473 0 : cur->out.net_overrun += net_metrics[ MIDX( COUNTER, NET, XDP_RX_FILL_RING_EMPTY_DESCS ) ];
474 0 : }
475 :
476 0 : ulong bundle_txns_received = 0UL;
477 0 : ulong bundle_tile_idx = fd_topo_find_tile( topo, "bundle", 0UL );
478 0 : if( FD_LIKELY( bundle_tile_idx!=ULONG_MAX ) ) {
479 0 : fd_topo_tile_t const * bundle = &topo->tiles[ bundle_tile_idx ];
480 0 : volatile ulong const * bundle_metrics = fd_metrics_tile( bundle->metrics );
481 :
482 0 : bundle_txns_received = bundle_metrics[ MIDX( COUNTER, BUNDLE, TRANSACTION_RECEIVED ) ];
483 0 : }
484 :
485 0 : cur->in.pack_cranked =
486 0 : pack_metrics[ MIDX( COUNTER, PACK, BUNDLE_CRANK_STATUS_INSERTED ) ]
487 0 : + pack_metrics[ MIDX( COUNTER, PACK, BUNDLE_CRANK_STATUS_INSERTION_FAILED ) ]
488 0 : + pack_metrics[ MIDX( COUNTER, PACK, BUNDLE_CRANK_STATUS_CREATION_FAILED ) ];
489 :
490 0 : cur->in.gossip = dedup_metrics[ MIDX( COUNTER, DEDUP, GOSSIPED_VOTES_RECEIVED ) ];
491 0 : cur->in.quic = cur->out.tpu_quic_invalid +
492 0 : cur->out.quic_overrun +
493 0 : cur->out.quic_frag_drop +
494 0 : cur->out.quic_abandoned +
495 0 : cur->out.net_overrun;
496 0 : cur->in.udp = cur->out.tpu_udp_invalid;
497 0 : cur->in.block_engine = bundle_txns_received;
498 0 : for( ulong i=0UL; i<gui->summary.quic_tile_cnt; i++ ) {
499 0 : fd_topo_tile_t const * quic = &topo->tiles[ fd_topo_find_tile( topo, "quic", i ) ];
500 0 : volatile ulong * quic_metrics = fd_metrics_tile( quic->metrics );
501 :
502 0 : cur->in.quic += quic_metrics[ MIDX( COUNTER, QUIC, TXNS_RECEIVED_QUIC_FAST ) ];
503 0 : cur->in.quic += quic_metrics[ MIDX( COUNTER, QUIC, TXNS_RECEIVED_QUIC_FRAG ) ];
504 0 : cur->in.udp += quic_metrics[ MIDX( COUNTER, QUIC, TXNS_RECEIVED_UDP ) ];
505 0 : }
506 0 : }
507 :
508 : static void
509 : fd_gui_tile_stats_snap( fd_gui_t * gui,
510 : fd_gui_txn_waterfall_t const * waterfall,
511 : fd_gui_tile_stats_t * stats,
512 0 : long now ) {
513 0 : fd_topo_t const * topo = gui->topo;
514 :
515 0 : stats->sample_time_nanos = now;
516 :
517 0 : stats->net_in_rx_bytes = 0UL;
518 0 : stats->net_out_tx_bytes = 0UL;
519 0 : for( ulong i=0UL; i<gui->summary.net_tile_cnt; i++ ) {
520 0 : fd_topo_tile_t const * net = &topo->tiles[ fd_topo_find_tile( topo, "net", i ) ];
521 0 : volatile ulong * net_metrics = fd_metrics_tile( net->metrics );
522 :
523 0 : stats->net_in_rx_bytes += net_metrics[ MIDX( COUNTER, NET, RX_BYTES_TOTAL ) ];
524 0 : stats->net_out_tx_bytes += net_metrics[ MIDX( COUNTER, NET, TX_BYTES_TOTAL ) ];
525 0 : }
526 :
527 0 : for( ulong i=0UL; i<gui->summary.sock_tile_cnt; i++ ) {
528 0 : fd_topo_tile_t const * sock = &topo->tiles[ fd_topo_find_tile( topo, "sock", i ) ];
529 0 : volatile ulong * sock_metrics = fd_metrics_tile( sock->metrics );
530 :
531 0 : stats->net_in_rx_bytes += sock_metrics[ MIDX( COUNTER, SOCK, RX_BYTES_TOTAL ) ];
532 0 : stats->net_out_tx_bytes += sock_metrics[ MIDX( COUNTER, SOCK, TX_BYTES_TOTAL ) ];
533 0 : }
534 :
535 0 : stats->quic_conn_cnt = 0UL;
536 0 : for( ulong i=0UL; i<gui->summary.quic_tile_cnt; i++ ) {
537 0 : fd_topo_tile_t const * quic = &topo->tiles[ fd_topo_find_tile( topo, "quic", i ) ];
538 0 : volatile ulong * quic_metrics = fd_metrics_tile( quic->metrics );
539 :
540 0 : stats->quic_conn_cnt += quic_metrics[ MIDX( GAUGE, QUIC, CONNECTIONS_ALLOC ) ];
541 0 : }
542 :
543 0 : ulong bundle_tile_idx = fd_topo_find_tile( topo, "bundle", 0UL );
544 0 : if( FD_LIKELY( bundle_tile_idx!=ULONG_MAX ) ) {
545 0 : fd_topo_tile_t const * bundle = &topo->tiles[ bundle_tile_idx ];
546 0 : volatile ulong * bundle_metrics = fd_metrics_tile( bundle->metrics );
547 0 : stats->bundle_rtt_smoothed_nanos = bundle_metrics[ MIDX( GAUGE, BUNDLE, RTT_SMOOTHED ) ];
548 :
549 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 ) );
550 0 : stats->bundle_rx_delay_hist.sum = bundle_metrics[ MIDX( HISTOGRAM, BUNDLE, MESSAGE_RX_DELAY_NANOS ) + FD_HISTF_BUCKET_CNT ];
551 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 ];
552 0 : }
553 :
554 0 : stats->verify_drop_cnt = waterfall->out.verify_duplicate +
555 0 : waterfall->out.verify_parse +
556 0 : waterfall->out.verify_failed;
557 0 : stats->verify_total_cnt = waterfall->in.gossip +
558 0 : waterfall->in.quic +
559 0 : waterfall->in.udp -
560 0 : waterfall->out.net_overrun -
561 0 : waterfall->out.tpu_quic_invalid -
562 0 : waterfall->out.tpu_udp_invalid -
563 0 : waterfall->out.quic_abandoned -
564 0 : waterfall->out.quic_frag_drop -
565 0 : waterfall->out.quic_overrun -
566 0 : waterfall->out.verify_overrun;
567 0 : stats->dedup_drop_cnt = waterfall->out.dedup_duplicate;
568 0 : stats->dedup_total_cnt = stats->verify_total_cnt -
569 0 : waterfall->out.verify_duplicate -
570 0 : waterfall->out.verify_parse -
571 0 : waterfall->out.verify_failed;
572 :
573 0 : fd_topo_tile_t const * pack = &topo->tiles[ fd_topo_find_tile( topo, "pack", 0UL ) ];
574 0 : volatile ulong const * pack_metrics = fd_metrics_tile( pack->metrics );
575 0 : stats->pack_buffer_cnt = pack_metrics[ MIDX( GAUGE, PACK, AVAILABLE_TRANSACTIONS ) ];
576 0 : stats->pack_buffer_capacity = pack->pack.max_pending_transactions;
577 :
578 0 : stats->bank_txn_exec_cnt = waterfall->out.block_fail + waterfall->out.block_success;
579 0 : }
580 :
581 : static void
582 0 : fd_gui_run_boot_progress( fd_gui_t * gui, long now ) {
583 0 : fd_topo_tile_t const * snaprd = &gui->topo->tiles[ fd_topo_find_tile( gui->topo, "snaprd", 0UL ) ];
584 0 : volatile ulong * snaprd_metrics = fd_metrics_tile( snaprd->metrics );
585 :
586 0 : fd_topo_tile_t const * snapdc = &gui->topo->tiles[ fd_topo_find_tile( gui->topo, "snapdc", 0UL ) ];
587 0 : volatile ulong * snapdc_metrics = fd_metrics_tile( snapdc->metrics );
588 :
589 0 : fd_topo_tile_t const * snapin = &gui->topo->tiles[ fd_topo_find_tile( gui->topo, "snapin", 0UL ) ];
590 0 : volatile ulong * snapin_metrics = fd_metrics_tile( snapin->metrics );
591 :
592 0 : ulong snapshot_phase = snaprd_metrics[ MIDX( GAUGE, SNAPRD, STATE ) ];
593 :
594 : /* state transitions */
595 0 : if( FD_UNLIKELY( gui->summary.slot_caught_up!=ULONG_MAX ) ) {
596 0 : gui->summary.boot_progress.phase = FD_GUI_BOOT_PROGRESS_TYPE_RUNNING;
597 0 : } else if( FD_LIKELY( snapshot_phase == FD_SNAPRD_STATE_SHUTDOWN && gui->summary.slots_max_turbine[ 0 ].slot!=ULONG_MAX && gui->summary.slot_completed!=ULONG_MAX ) ) {
598 0 : gui->summary.boot_progress.phase = FD_GUI_BOOT_PROGRESS_TYPE_CATCHING_UP;
599 0 : } else if( FD_LIKELY( snapshot_phase==FD_SNAPRD_STATE_READING_FULL_FILE
600 0 : || snapshot_phase==FD_SNAPRD_STATE_FLUSHING_FULL_FILE
601 0 : || snapshot_phase==FD_SNAPRD_STATE_READING_FULL_HTTP
602 0 : || snapshot_phase==FD_SNAPRD_STATE_FLUSHING_FULL_HTTP ) ) {
603 0 : gui->summary.boot_progress.phase = FD_GUI_BOOT_PROGRESS_TYPE_LOADING_FULL_SNAPSHOT;
604 0 : } else if( FD_LIKELY( snapshot_phase==FD_SNAPRD_STATE_READING_INCREMENTAL_FILE
605 0 : || snapshot_phase==FD_SNAPRD_STATE_FLUSHING_INCREMENTAL_FILE
606 0 : || snapshot_phase==FD_SNAPRD_STATE_READING_INCREMENTAL_HTTP
607 0 : || snapshot_phase==FD_SNAPRD_STATE_FLUSHING_INCREMENTAL_HTTP ) ) {
608 0 : gui->summary.boot_progress.phase = FD_GUI_BOOT_PROGRESS_TYPE_LOADING_FULL_SNAPSHOT;
609 0 : }
610 :
611 0 : switch ( gui->summary.boot_progress.phase ) {
612 0 : case FD_GUI_BOOT_PROGRESS_TYPE_JOINING_GOSSIP: {
613 0 : gui->summary.boot_progress.joining_gossip_time_nanos = now;
614 0 : break;
615 0 : }
616 0 : case FD_GUI_BOOT_PROGRESS_TYPE_LOADING_FULL_SNAPSHOT:
617 0 : case FD_GUI_BOOT_PROGRESS_TYPE_LOADING_INCREMENTAL_SNAPSHOT: {
618 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 );
619 0 : ulong _retry_cnt = fd_ulong_if( snapshot_idx==FD_GUI_BOOT_PROGRESS_FULL_SNAPSHOT_IDX, snaprd_metrics[ MIDX( GAUGE, SNAPRD, FULL_DOWNLOAD_RETRIES ) ], snaprd_metrics[ MIDX( GAUGE, SNAPRD, INCREMENTAL_DOWNLOAD_RETRIES ) ]);
620 :
621 : /* reset boot state if necessary */
622 0 : if( FD_UNLIKELY( gui->summary.boot_progress.loading_snapshot[ snapshot_idx ].reset_cnt!=_retry_cnt ) ) {
623 0 : gui->summary.boot_progress.loading_snapshot[ snapshot_idx ].reset_time_nanos = now;
624 0 : gui->summary.boot_progress.loading_snapshot[ snapshot_idx ].reset_cnt = _retry_cnt;
625 0 : }
626 :
627 0 : ulong _total_bytes = fd_ulong_if( snapshot_idx==FD_GUI_BOOT_PROGRESS_FULL_SNAPSHOT_IDX, snaprd_metrics[ MIDX( GAUGE, SNAPRD, FULL_BYTES_TOTAL ) ], snaprd_metrics[ MIDX( GAUGE, SNAPRD, INCREMENTAL_BYTES_TOTAL ) ] );
628 0 : ulong _read_bytes = fd_ulong_if( snapshot_idx==FD_GUI_BOOT_PROGRESS_FULL_SNAPSHOT_IDX, snaprd_metrics[ MIDX( GAUGE, SNAPRD, FULL_BYTES_READ ) ], snaprd_metrics[ MIDX( GAUGE, SNAPRD, INCREMENTAL_BYTES_READ ) ] );
629 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_READ ) ], snapdc_metrics[ MIDX( GAUGE, SNAPDC, INCREMENTAL_DECOMPRESSED_BYTES_READ ) ] );
630 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 ) ] );
631 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 ) ] );
632 0 : ulong _insert_accounts = snapin_metrics[ MIDX( GAUGE, SNAPIN, ACCOUNTS_INSERTED ) ];
633 :
634 : /* metadata */
635 0 : gui->summary.boot_progress.loading_snapshot[ snapshot_idx ].total_bytes_compressed = _total_bytes;
636 0 : gui->summary.boot_progress.loading_snapshot[ snapshot_idx ].sample_time_nanos = now;
637 :
638 : /* read stage */
639 0 : gui->summary.boot_progress.loading_snapshot[ snapshot_idx ].read_bytes_compressed = _read_bytes;
640 :
641 : /* decompress stage */
642 0 : gui->summary.boot_progress.loading_snapshot[ snapshot_idx ].decompress_bytes_compressed = _decompress_compressed_bytes;
643 0 : gui->summary.boot_progress.loading_snapshot[ snapshot_idx ].decompress_bytes_decompressed = _decompress_decompressed_bytes;
644 :
645 : /* insert stage */
646 0 : gui->summary.boot_progress.loading_snapshot[ snapshot_idx ].insert_bytes_decompressed = _insert_bytes;
647 :
648 : /* Use the latest compression ratio to estimate decompressed size */
649 0 : gui->summary.boot_progress.loading_snapshot[ snapshot_idx ].insert_accounts_current = _insert_accounts;
650 :
651 0 : break;
652 0 : }
653 0 : case FD_GUI_BOOT_PROGRESS_TYPE_CATCHING_UP: {
654 0 : gui->summary.boot_progress.catching_up_time_nanos = now;
655 0 : break;
656 0 : }
657 0 : case FD_GUI_BOOT_PROGRESS_TYPE_RUNNING: break;
658 0 : default: FD_LOG_ERR(( "unknown boot progress phase: %d", gui->summary.boot_progress.phase ));
659 0 : }
660 0 : }
661 :
662 : int
663 0 : fd_gui_poll( fd_gui_t * gui, long now ) {
664 0 : int did_work = 0;
665 :
666 0 : if( FD_LIKELY( now>gui->next_sample_400millis ) ) {
667 0 : fd_gui_estimated_tps_snap( gui );
668 0 : fd_gui_printf_estimated_tps( gui );
669 0 : fd_http_server_ws_broadcast( gui->http );
670 :
671 0 : gui->next_sample_400millis += 400L*1000L*1000L;
672 0 : did_work = 1;
673 0 : }
674 :
675 0 : if( FD_LIKELY( now>gui->next_sample_100millis ) ) {
676 0 : fd_gui_txn_waterfall_snap( gui, gui->summary.txn_waterfall_current );
677 0 : fd_gui_printf_live_txn_waterfall( gui, gui->summary.txn_waterfall_reference, gui->summary.txn_waterfall_current, 0UL /* TODO: REAL NEXT LEADER SLOT */ );
678 0 : fd_http_server_ws_broadcast( gui->http );
679 :
680 0 : *gui->summary.tile_stats_reference = *gui->summary.tile_stats_current;
681 0 : fd_gui_tile_stats_snap( gui, gui->summary.txn_waterfall_current, gui->summary.tile_stats_current, now );
682 0 : fd_gui_printf_live_tile_stats( gui, gui->summary.tile_stats_reference, gui->summary.tile_stats_current );
683 0 : fd_http_server_ws_broadcast( gui->http );
684 :
685 0 : if( FD_UNLIKELY( gui->summary.is_full_client && gui->summary.boot_progress.phase!=FD_GUI_BOOT_PROGRESS_TYPE_RUNNING ) ) {
686 0 : fd_gui_run_boot_progress( gui, now );
687 0 : fd_gui_printf_boot_progress( gui );
688 0 : fd_http_server_ws_broadcast( gui->http );
689 0 : }
690 :
691 0 : gui->next_sample_100millis += 100L*1000L*1000L;
692 0 : did_work = 1;
693 0 : }
694 :
695 0 : if( FD_LIKELY( now>gui->next_sample_10millis ) ) {
696 0 : fd_gui_tile_timers_snap( gui );
697 :
698 0 : fd_gui_printf_live_tile_timers( gui );
699 0 : fd_http_server_ws_broadcast( gui->http );
700 :
701 0 : if( FD_LIKELY( gui->summary.is_full_client && gui->shreds.staged_next_broadcast<gui->shreds.staged_tail ) ) {
702 0 : fd_gui_printf_shred_updates( gui );
703 0 : fd_http_server_ws_broadcast( gui->http );
704 0 : gui->shreds.staged_next_broadcast = gui->shreds.staged_tail;
705 0 : }
706 :
707 0 : gui->next_sample_10millis += 10L*1000L*1000L;
708 0 : did_work = 1;
709 0 : }
710 :
711 0 : return did_work;
712 0 : }
713 :
714 : static void
715 : fd_gui_handle_gossip_update( fd_gui_t * gui,
716 0 : uchar const * msg ) {
717 0 : if( FD_UNLIKELY( gui->gossip.peer_cnt == FD_GUI_MAX_PEER_CNT ) ) {
718 0 : FD_LOG_DEBUG(("gossip peer cnt exceeds 40200 %lu, ignoring additional entries", gui->gossip.peer_cnt ));
719 0 : return;
720 0 : }
721 0 : ulong const * header = (ulong const *)fd_type_pun_const( msg );
722 0 : ulong peer_cnt = header[ 0 ];
723 :
724 0 : FD_TEST( peer_cnt<=FD_GUI_MAX_PEER_CNT );
725 :
726 0 : ulong added_cnt = 0UL;
727 0 : ulong added[ FD_GUI_MAX_PEER_CNT ] = {0};
728 :
729 0 : ulong update_cnt = 0UL;
730 0 : ulong updated[ FD_GUI_MAX_PEER_CNT ] = {0};
731 :
732 0 : ulong removed_cnt = 0UL;
733 0 : fd_pubkey_t removed[ FD_GUI_MAX_PEER_CNT ] = {0};
734 :
735 0 : uchar const * data = (uchar const *)(header+1UL);
736 0 : for( ulong i=0UL; i<gui->gossip.peer_cnt; i++ ) {
737 0 : int found = 0;
738 0 : for( ulong j=0UL; j<peer_cnt; j++ ) {
739 0 : if( FD_UNLIKELY( !memcmp( gui->gossip.peers[ i ].pubkey, data+j*(58UL+12UL*6UL), 32UL ) ) ) {
740 0 : found = 1;
741 0 : break;
742 0 : }
743 0 : }
744 :
745 0 : if( FD_UNLIKELY( !found ) ) {
746 0 : fd_memcpy( removed[ removed_cnt++ ].uc, gui->gossip.peers[ i ].pubkey->uc, 32UL );
747 0 : if( FD_LIKELY( i+1UL!=gui->gossip.peer_cnt ) ) {
748 0 : gui->gossip.peers[ i ] = gui->gossip.peers[ gui->gossip.peer_cnt-1UL ];
749 0 : gui->gossip.peer_cnt--;
750 0 : i--;
751 0 : }
752 0 : }
753 0 : }
754 :
755 0 : ulong before_peer_cnt = gui->gossip.peer_cnt;
756 0 : for( ulong i=0UL; i<peer_cnt; i++ ) {
757 0 : int found = 0;
758 0 : ulong found_idx = 0;
759 0 : for( ulong j=0UL; j<gui->gossip.peer_cnt; j++ ) {
760 0 : if( FD_UNLIKELY( !memcmp( gui->gossip.peers[ j ].pubkey, data+i*(58UL+12UL*6UL), 32UL ) ) ) {
761 0 : found_idx = j;
762 0 : found = 1;
763 0 : break;
764 0 : }
765 0 : }
766 :
767 0 : if( FD_UNLIKELY( !found ) ) {
768 0 : fd_memcpy( gui->gossip.peers[ gui->gossip.peer_cnt ].pubkey->uc, data+i*(58UL+12UL*6UL), 32UL );
769 0 : gui->gossip.peers[ gui->gossip.peer_cnt ].wallclock = *(ulong const *)(data+i*(58UL+12UL*6UL)+32UL);
770 0 : gui->gossip.peers[ gui->gossip.peer_cnt ].shred_version = *(ushort const *)(data+i*(58UL+12UL*6UL)+40UL);
771 0 : gui->gossip.peers[ gui->gossip.peer_cnt ].has_version = *(data+i*(58UL+12UL*6UL)+42UL);
772 0 : if( FD_LIKELY( gui->gossip.peers[ gui->gossip.peer_cnt ].has_version ) ) {
773 0 : gui->gossip.peers[ gui->gossip.peer_cnt ].version.major = *(ushort const *)(data+i*(58UL+12UL*6UL)+43UL);
774 0 : gui->gossip.peers[ gui->gossip.peer_cnt ].version.minor = *(ushort const *)(data+i*(58UL+12UL*6UL)+45UL);
775 0 : gui->gossip.peers[ gui->gossip.peer_cnt ].version.patch = *(ushort const *)(data+i*(58UL+12UL*6UL)+47UL);
776 0 : gui->gossip.peers[ gui->gossip.peer_cnt ].version.has_commit = *(data+i*(58UL+12UL*6UL)+49UL);
777 0 : if( FD_LIKELY( gui->gossip.peers[ gui->gossip.peer_cnt ].version.has_commit ) ) {
778 0 : gui->gossip.peers[ gui->gossip.peer_cnt ].version.commit = *(uint const *)(data+i*(58UL+12UL*6UL)+50UL);
779 0 : }
780 0 : gui->gossip.peers[ gui->gossip.peer_cnt ].version.feature_set = *(uint const *)(data+i*(58UL+12UL*6UL)+54UL);
781 0 : }
782 :
783 0 : for( ulong j=0UL; j<12UL; j++ ) {
784 0 : gui->gossip.peers[ gui->gossip.peer_cnt ].sockets[ j ].ipv4 = *(uint const *)(data+i*(58UL+12UL*6UL)+58UL+j*6UL);
785 0 : gui->gossip.peers[ gui->gossip.peer_cnt ].sockets[ j ].port = *(ushort const *)(data+i*(58UL+12UL*6UL)+58UL+j*6UL+4UL);
786 0 : }
787 :
788 0 : gui->gossip.peer_cnt++;
789 0 : } else {
790 0 : int peer_updated = gui->gossip.peers[ found_idx ].shred_version!=*(ushort const *)(data+i*(58UL+12UL*6UL)+40UL) ||
791 : // gui->gossip.peers[ found_idx ].wallclock!=*(ulong const *)(data+i*(58UL+12UL*6UL)+32UL) ||
792 0 : gui->gossip.peers[ found_idx ].has_version!=*(data+i*(58UL+12UL*6UL)+42UL);
793 :
794 0 : if( FD_LIKELY( !peer_updated && gui->gossip.peers[ found_idx ].has_version ) ) {
795 0 : peer_updated = gui->gossip.peers[ found_idx ].version.major!=*(ushort const *)(data+i*(58UL+12UL*6UL)+43UL) ||
796 0 : gui->gossip.peers[ found_idx ].version.minor!=*(ushort const *)(data+i*(58UL+12UL*6UL)+45UL) ||
797 0 : gui->gossip.peers[ found_idx ].version.patch!=*(ushort const *)(data+i*(58UL+12UL*6UL)+47UL) ||
798 0 : gui->gossip.peers[ found_idx ].version.has_commit!=*(data+i*(58UL+12UL*6UL)+49UL) ||
799 0 : (gui->gossip.peers[ found_idx ].version.has_commit && gui->gossip.peers[ found_idx ].version.commit!=*(uint const *)(data+i*(58UL+12UL*6UL)+50UL)) ||
800 0 : gui->gossip.peers[ found_idx ].version.feature_set!=*(uint const *)(data+i*(58UL+12UL*6UL)+54UL);
801 0 : }
802 :
803 0 : if( FD_LIKELY( !peer_updated ) ) {
804 0 : for( ulong j=0UL; j<12UL; j++ ) {
805 0 : peer_updated = gui->gossip.peers[ found_idx ].sockets[ j ].ipv4!=*(uint const *)(data+i*(58UL+12UL*6UL)+58UL+j*6UL) ||
806 0 : gui->gossip.peers[ found_idx ].sockets[ j ].port!=*(ushort const *)(data+i*(58UL+12UL*6UL)+58UL+j*6UL+4UL);
807 0 : if( FD_LIKELY( peer_updated ) ) break;
808 0 : }
809 0 : }
810 :
811 0 : if( FD_UNLIKELY( peer_updated ) ) {
812 0 : updated[ update_cnt++ ] = found_idx;
813 0 : gui->gossip.peers[ found_idx ].shred_version = *(ushort const *)(data+i*(58UL+12UL*6UL)+40UL);
814 0 : gui->gossip.peers[ found_idx ].wallclock = *(ulong const *)(data+i*(58UL+12UL*6UL)+32UL);
815 0 : gui->gossip.peers[ found_idx ].has_version = *(data+i*(58UL+12UL*6UL)+42UL);
816 0 : if( FD_LIKELY( gui->gossip.peers[ found_idx ].has_version ) ) {
817 0 : gui->gossip.peers[ found_idx ].version.major = *(ushort const *)(data+i*(58UL+12UL*6UL)+43UL);
818 0 : gui->gossip.peers[ found_idx ].version.minor = *(ushort const *)(data+i*(58UL+12UL*6UL)+45UL);
819 0 : gui->gossip.peers[ found_idx ].version.patch = *(ushort const *)(data+i*(58UL+12UL*6UL)+47UL);
820 0 : gui->gossip.peers[ found_idx ].version.has_commit = *(data+i*(58UL+12UL*6UL)+49UL);
821 0 : if( FD_LIKELY( gui->gossip.peers[ found_idx ].version.has_commit ) ) {
822 0 : gui->gossip.peers[ found_idx ].version.commit = *(uint const *)(data+i*(58UL+12UL*6UL)+50UL);
823 0 : }
824 0 : gui->gossip.peers[ found_idx ].version.feature_set = *(uint const *)(data+i*(58UL+12UL*6UL)+54UL);
825 0 : }
826 :
827 0 : for( ulong j=0UL; j<12UL; j++ ) {
828 0 : gui->gossip.peers[ found_idx ].sockets[ j ].ipv4 = *(uint const *)(data+i*(58UL+12UL*6UL)+58UL+j*6UL);
829 0 : gui->gossip.peers[ found_idx ].sockets[ j ].port = *(ushort const *)(data+i*(58UL+12UL*6UL)+58UL+j*6UL+4UL);
830 0 : }
831 0 : }
832 0 : }
833 0 : }
834 :
835 0 : added_cnt = gui->gossip.peer_cnt - before_peer_cnt;
836 0 : for( ulong i=before_peer_cnt; i<gui->gossip.peer_cnt; i++ ) added[ i-before_peer_cnt ] = i;
837 :
838 0 : fd_gui_printf_peers_gossip_update( gui, updated, update_cnt, removed, removed_cnt, added, added_cnt );
839 0 : fd_http_server_ws_broadcast( gui->http );
840 0 : }
841 :
842 : static void
843 : fd_gui_handle_vote_account_update( fd_gui_t * gui,
844 0 : uchar const * msg ) {
845 0 : if( FD_UNLIKELY( gui->vote_account.vote_account_cnt==FD_GUI_MAX_PEER_CNT ) ) {
846 0 : FD_LOG_DEBUG(("vote account cnt exceeds 40200 %lu, ignoring additional entries", gui->vote_account.vote_account_cnt ));
847 0 : return;
848 0 : }
849 0 : ulong const * header = (ulong const *)fd_type_pun_const( msg );
850 0 : ulong peer_cnt = header[ 0 ];
851 :
852 0 : FD_TEST( peer_cnt<=FD_GUI_MAX_PEER_CNT );
853 :
854 0 : ulong added_cnt = 0UL;
855 0 : ulong added[ FD_GUI_MAX_PEER_CNT ] = {0};
856 :
857 0 : ulong update_cnt = 0UL;
858 0 : ulong updated[ FD_GUI_MAX_PEER_CNT ] = {0};
859 :
860 0 : ulong removed_cnt = 0UL;
861 0 : fd_pubkey_t removed[ FD_GUI_MAX_PEER_CNT ] = {0};
862 :
863 0 : uchar const * data = (uchar const *)(header+1UL);
864 0 : for( ulong i=0UL; i<gui->vote_account.vote_account_cnt; i++ ) {
865 0 : int found = 0;
866 0 : for( ulong j=0UL; j<peer_cnt; j++ ) {
867 0 : if( FD_UNLIKELY( !memcmp( gui->vote_account.vote_accounts[ i ].vote_account, data+j*112UL, 32UL ) ) ) {
868 0 : found = 1;
869 0 : break;
870 0 : }
871 0 : }
872 :
873 0 : if( FD_UNLIKELY( !found ) ) {
874 0 : fd_memcpy( removed[ removed_cnt++ ].uc, gui->vote_account.vote_accounts[ i ].vote_account->uc, 32UL );
875 0 : if( FD_LIKELY( i+1UL!=gui->vote_account.vote_account_cnt ) ) {
876 0 : gui->vote_account.vote_accounts[ i ] = gui->vote_account.vote_accounts[ gui->vote_account.vote_account_cnt-1UL ];
877 0 : gui->vote_account.vote_account_cnt--;
878 0 : i--;
879 0 : }
880 0 : }
881 0 : }
882 :
883 0 : ulong before_peer_cnt = gui->vote_account.vote_account_cnt;
884 0 : for( ulong i=0UL; i<peer_cnt; i++ ) {
885 0 : int found = 0;
886 0 : ulong found_idx;
887 0 : for( ulong j=0UL; j<gui->vote_account.vote_account_cnt; j++ ) {
888 0 : if( FD_UNLIKELY( !memcmp( gui->vote_account.vote_accounts[ j ].vote_account, data+i*112UL, 32UL ) ) ) {
889 0 : found_idx = j;
890 0 : found = 1;
891 0 : break;
892 0 : }
893 0 : }
894 :
895 0 : if( FD_UNLIKELY( !found ) ) {
896 0 : fd_memcpy( gui->vote_account.vote_accounts[ gui->vote_account.vote_account_cnt ].vote_account->uc, data+i*112UL, 32UL );
897 0 : fd_memcpy( gui->vote_account.vote_accounts[ gui->vote_account.vote_account_cnt ].pubkey->uc, data+i*112UL+32UL, 32UL );
898 :
899 0 : gui->vote_account.vote_accounts[ gui->vote_account.vote_account_cnt ].activated_stake = *(ulong const *)(data+i*112UL+64UL);
900 0 : gui->vote_account.vote_accounts[ gui->vote_account.vote_account_cnt ].last_vote = *(ulong const *)(data+i*112UL+72UL);
901 0 : gui->vote_account.vote_accounts[ gui->vote_account.vote_account_cnt ].root_slot = *(ulong const *)(data+i*112UL+80UL);
902 0 : gui->vote_account.vote_accounts[ gui->vote_account.vote_account_cnt ].epoch_credits = *(ulong const *)(data+i*112UL+88UL);
903 0 : gui->vote_account.vote_accounts[ gui->vote_account.vote_account_cnt ].commission = *(data+i*112UL+96UL);
904 0 : gui->vote_account.vote_accounts[ gui->vote_account.vote_account_cnt ].delinquent = *(data+i*112UL+97UL);
905 :
906 0 : gui->vote_account.vote_account_cnt++;
907 0 : } else {
908 0 : int peer_updated =
909 0 : memcmp( gui->vote_account.vote_accounts[ found_idx ].pubkey->uc, data+i*112UL+32UL, 32UL ) ||
910 0 : gui->vote_account.vote_accounts[ found_idx ].activated_stake != *(ulong const *)(data+i*112UL+64UL) ||
911 : // gui->vote_account.vote_accounts[ found_idx ].last_vote != *(ulong const *)(data+i*112UL+72UL) ||
912 : // gui->vote_account.vote_accounts[ found_idx ].root_slot != *(ulong const *)(data+i*112UL+80UL) ||
913 : // gui->vote_account.vote_accounts[ found_idx ].epoch_credits != *(ulong const *)(data+i*112UL+88UL) ||
914 0 : gui->vote_account.vote_accounts[ found_idx ].commission != *(data+i*112UL+96UL) ||
915 0 : gui->vote_account.vote_accounts[ found_idx ].delinquent != *(data+i*112UL+97UL);
916 :
917 0 : if( FD_UNLIKELY( peer_updated ) ) {
918 0 : updated[ update_cnt++ ] = found_idx;
919 :
920 0 : fd_memcpy( gui->vote_account.vote_accounts[ found_idx ].pubkey->uc, data+i*112UL+32UL, 32UL );
921 0 : gui->vote_account.vote_accounts[ found_idx ].activated_stake = *(ulong const *)(data+i*112UL+64UL);
922 0 : gui->vote_account.vote_accounts[ found_idx ].last_vote = *(ulong const *)(data+i*112UL+72UL);
923 0 : gui->vote_account.vote_accounts[ found_idx ].root_slot = *(ulong const *)(data+i*112UL+80UL);
924 0 : gui->vote_account.vote_accounts[ found_idx ].epoch_credits = *(ulong const *)(data+i*112UL+88UL);
925 0 : gui->vote_account.vote_accounts[ found_idx ].commission = *(data+i*112UL+96UL);
926 0 : gui->vote_account.vote_accounts[ found_idx ].delinquent = *(data+i*112UL+97UL);
927 0 : }
928 0 : }
929 0 : }
930 :
931 0 : added_cnt = gui->vote_account.vote_account_cnt - before_peer_cnt;
932 0 : for( ulong i=before_peer_cnt; i<gui->vote_account.vote_account_cnt; i++ ) added[ i-before_peer_cnt ] = i;
933 :
934 0 : fd_gui_printf_peers_vote_account_update( gui, updated, update_cnt, removed, removed_cnt, added, added_cnt );
935 0 : fd_http_server_ws_broadcast( gui->http );
936 0 : }
937 :
938 : static void
939 : fd_gui_handle_validator_info_update( fd_gui_t * gui,
940 0 : uchar const * msg ) {
941 0 : if( FD_UNLIKELY( gui->validator_info.info_cnt == FD_GUI_MAX_PEER_CNT ) ) {
942 0 : FD_LOG_DEBUG(("validator info cnt exceeds 40200 %lu, ignoring additional entries", gui->validator_info.info_cnt ));
943 0 : return;
944 0 : }
945 0 : uchar const * data = (uchar const *)fd_type_pun_const( msg );
946 :
947 0 : ulong added_cnt = 0UL;
948 0 : ulong added[ 1 ] = {0};
949 :
950 0 : ulong update_cnt = 0UL;
951 0 : ulong updated[ 1 ] = {0};
952 :
953 0 : ulong removed_cnt = 0UL;
954 : /* Unlike gossip or vote account updates, validator info messages come
955 : in as info is discovered, and may contain as little as 1 validator
956 : per message. Therefore, it doesn't make sense to use the remove
957 : mechanism. */
958 :
959 0 : ulong before_peer_cnt = gui->validator_info.info_cnt;
960 0 : int found = 0;
961 0 : ulong found_idx;
962 0 : for( ulong j=0UL; j<gui->validator_info.info_cnt; j++ ) {
963 0 : if( FD_UNLIKELY( !memcmp( gui->validator_info.info[ j ].pubkey, data, 32UL ) ) ) {
964 0 : found_idx = j;
965 0 : found = 1;
966 0 : break;
967 0 : }
968 0 : }
969 :
970 0 : if( FD_UNLIKELY( !found ) ) {
971 0 : fd_memcpy( gui->validator_info.info[ gui->validator_info.info_cnt ].pubkey->uc, data, 32UL );
972 :
973 0 : strncpy( gui->validator_info.info[ gui->validator_info.info_cnt ].name, (char const *)(data+32UL), 64 );
974 0 : gui->validator_info.info[ gui->validator_info.info_cnt ].name[ 63 ] = '\0';
975 :
976 0 : strncpy( gui->validator_info.info[ gui->validator_info.info_cnt ].website, (char const *)(data+96UL), 128 );
977 0 : gui->validator_info.info[ gui->validator_info.info_cnt ].website[ 127 ] = '\0';
978 :
979 0 : strncpy( gui->validator_info.info[ gui->validator_info.info_cnt ].details, (char const *)(data+224UL), 256 );
980 0 : gui->validator_info.info[ gui->validator_info.info_cnt ].details[ 255 ] = '\0';
981 :
982 0 : strncpy( gui->validator_info.info[ gui->validator_info.info_cnt ].icon_uri, (char const *)(data+480UL), 128 );
983 0 : gui->validator_info.info[ gui->validator_info.info_cnt ].icon_uri[ 127 ] = '\0';
984 :
985 0 : gui->validator_info.info_cnt++;
986 0 : } else {
987 0 : int peer_updated =
988 0 : memcmp( gui->validator_info.info[ found_idx ].pubkey->uc, data, 32UL ) ||
989 0 : strncmp( gui->validator_info.info[ found_idx ].name, (char const *)(data+32UL), 64 ) ||
990 0 : strncmp( gui->validator_info.info[ found_idx ].website, (char const *)(data+96UL), 128 ) ||
991 0 : strncmp( gui->validator_info.info[ found_idx ].details, (char const *)(data+224UL), 256 ) ||
992 0 : strncmp( gui->validator_info.info[ found_idx ].icon_uri, (char const *)(data+480UL), 128 );
993 :
994 0 : if( FD_UNLIKELY( peer_updated ) ) {
995 0 : updated[ update_cnt++ ] = found_idx;
996 :
997 0 : fd_memcpy( gui->validator_info.info[ found_idx ].pubkey->uc, data, 32UL );
998 :
999 0 : strncpy( gui->validator_info.info[ found_idx ].name, (char const *)(data+32UL), 64 );
1000 0 : gui->validator_info.info[ found_idx ].name[ 63 ] = '\0';
1001 :
1002 0 : strncpy( gui->validator_info.info[ found_idx ].website, (char const *)(data+96UL), 128 );
1003 0 : gui->validator_info.info[ found_idx ].website[ 127 ] = '\0';
1004 :
1005 0 : strncpy( gui->validator_info.info[ found_idx ].details, (char const *)(data+224UL), 256 );
1006 0 : gui->validator_info.info[ found_idx ].details[ 255 ] = '\0';
1007 :
1008 0 : strncpy( gui->validator_info.info[ found_idx ].icon_uri, (char const *)(data+480UL), 128 );
1009 0 : gui->validator_info.info[ found_idx ].icon_uri[ 127 ] = '\0';
1010 0 : }
1011 0 : }
1012 :
1013 0 : added_cnt = gui->validator_info.info_cnt - before_peer_cnt;
1014 0 : for( ulong i=before_peer_cnt; i<gui->validator_info.info_cnt; i++ ) added[ i-before_peer_cnt ] = i;
1015 :
1016 0 : fd_gui_printf_peers_validator_info_update( gui, updated, update_cnt, NULL, removed_cnt, added, added_cnt );
1017 0 : fd_http_server_ws_broadcast( gui->http );
1018 0 : }
1019 :
1020 : int
1021 : fd_gui_request_slot( fd_gui_t * gui,
1022 : ulong ws_conn_id,
1023 : ulong request_id,
1024 0 : cJSON const * params ) {
1025 0 : const cJSON * slot_param = cJSON_GetObjectItemCaseSensitive( params, "slot" );
1026 0 : if( FD_UNLIKELY( !cJSON_IsNumber( slot_param ) ) ) return FD_HTTP_SERVER_CONNECTION_CLOSE_BAD_REQUEST;
1027 :
1028 0 : ulong _slot = slot_param->valueulong;
1029 0 : fd_gui_slot_t const * slot = fd_gui_get_slot_const( gui, _slot );
1030 0 : if( FD_UNLIKELY( !slot ) ) {
1031 0 : fd_gui_printf_null_query_response( gui->http, "slot", "query", request_id );
1032 0 : FD_TEST( !fd_http_server_ws_send( gui->http, ws_conn_id ) );
1033 0 : return 0;
1034 0 : }
1035 :
1036 0 : fd_gui_printf_slot_request( gui, _slot, request_id );
1037 0 : FD_TEST( !fd_http_server_ws_send( gui->http, ws_conn_id ) );
1038 0 : return 0;
1039 0 : }
1040 :
1041 : int
1042 : fd_gui_request_slot_transactions( fd_gui_t * gui,
1043 : ulong ws_conn_id,
1044 : ulong request_id,
1045 0 : cJSON const * params ) {
1046 0 : const cJSON * slot_param = cJSON_GetObjectItemCaseSensitive( params, "slot" );
1047 0 : if( FD_UNLIKELY( !cJSON_IsNumber( slot_param ) ) ) return FD_HTTP_SERVER_CONNECTION_CLOSE_BAD_REQUEST;
1048 :
1049 0 : ulong _slot = slot_param->valueulong;
1050 0 : fd_gui_slot_t const * slot = fd_gui_get_slot_const( gui, _slot );
1051 0 : if( FD_UNLIKELY( !slot ) ) {
1052 0 : fd_gui_printf_null_query_response( gui->http, "slot", "query", request_id );
1053 0 : FD_TEST( !fd_http_server_ws_send( gui->http, ws_conn_id ) );
1054 0 : return 0;
1055 0 : }
1056 :
1057 0 : fd_gui_printf_slot_transactions_request( gui, _slot, request_id );
1058 0 : FD_TEST( !fd_http_server_ws_send( gui->http, ws_conn_id ) );
1059 0 : return 0;
1060 0 : }
1061 :
1062 : int
1063 : fd_gui_request_slot_detailed( fd_gui_t * gui,
1064 : ulong ws_conn_id,
1065 : ulong request_id,
1066 0 : cJSON const * params ) {
1067 0 : const cJSON * slot_param = cJSON_GetObjectItemCaseSensitive( params, "slot" );
1068 0 : if( FD_UNLIKELY( !cJSON_IsNumber( slot_param ) ) ) return FD_HTTP_SERVER_CONNECTION_CLOSE_BAD_REQUEST;
1069 :
1070 0 : ulong _slot = slot_param->valueulong;
1071 0 : fd_gui_slot_t const * slot = fd_gui_get_slot_const( gui, _slot );
1072 0 : if( FD_UNLIKELY( !slot ) ) {
1073 0 : fd_gui_printf_null_query_response( gui->http, "slot", "query", request_id );
1074 0 : FD_TEST( !fd_http_server_ws_send( gui->http, ws_conn_id ) );
1075 0 : return 0;
1076 0 : }
1077 :
1078 0 : fd_gui_printf_slot_request_detailed( gui, _slot, request_id );
1079 0 : FD_TEST( !fd_http_server_ws_send( gui->http, ws_conn_id ) );
1080 0 : return 0;
1081 0 : }
1082 :
1083 : static inline ulong
1084 0 : fd_gui_slot_duration( fd_gui_t const * gui, fd_gui_slot_t const * cur ) {
1085 0 : fd_gui_slot_t const * prev = fd_gui_get_slot_const( gui, cur->slot-1UL );
1086 0 : if( FD_UNLIKELY( !prev ||
1087 0 : prev->skipped ||
1088 0 : prev->completed_time == LONG_MAX ||
1089 0 : prev->slot != (cur->slot - 1UL) ||
1090 0 : cur->skipped ||
1091 0 : cur->completed_time == LONG_MAX ) ) return ULONG_MAX;
1092 :
1093 0 : return (ulong)(cur->completed_time - prev->completed_time);
1094 0 : }
1095 :
1096 : static inline void
1097 : fd_gui_try_insert_ranking( fd_gui_t * gui,
1098 : fd_gui_slot_rankings_t * rankings,
1099 0 : fd_gui_slot_t const * slot ) {
1100 : /* Rankings are inserted into an extra slot at the end of the ranking
1101 : array, then the array is sorted. */
1102 0 : #define TRY_INSERT_SLOT( ranking_name, ranking_slot, ranking_value ) \
1103 0 : do { \
1104 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 }; \
1105 0 : fd_gui_slot_ranking_sort_insert( rankings->FD_CONCAT2(largest_, ranking_name), FD_GUI_SLOT_RANKINGS_SZ+1UL ); \
1106 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 }; \
1107 0 : fd_gui_slot_ranking_sort_insert( rankings->FD_CONCAT2(smallest_, ranking_name), FD_GUI_SLOT_RANKINGS_SZ+1UL ); \
1108 0 : } while (0)
1109 :
1110 0 : if( slot->skipped ) {
1111 0 : TRY_INSERT_SLOT( skipped, slot->slot, slot->slot );
1112 0 : return;
1113 0 : }
1114 :
1115 0 : ulong dur = fd_gui_slot_duration( gui, slot );
1116 0 : if( FD_LIKELY( dur!=ULONG_MAX ) ) TRY_INSERT_SLOT( duration, slot->slot, dur );
1117 0 : TRY_INSERT_SLOT( tips, slot->slot, slot->tips );
1118 0 : TRY_INSERT_SLOT( fees, slot->slot, slot->priority_fee );
1119 0 : TRY_INSERT_SLOT( rewards, slot->slot, slot->tips + slot->priority_fee );
1120 0 : TRY_INSERT_SLOT( compute_units, slot->slot, slot->compute_units );
1121 0 : #undef TRY_INSERT_SLOT
1122 0 : }
1123 :
1124 : static void
1125 0 : fd_gui_update_slot_rankings( fd_gui_t * gui ) {
1126 0 : if( FD_UNLIKELY( gui->summary.startup_progress.startup_ledger_max_slot==ULONG_MAX ) ) return;
1127 0 : if( FD_UNLIKELY( gui->summary.slot_rooted==ULONG_MAX ) ) return;
1128 :
1129 0 : ulong epoch_start_slot = ULONG_MAX;
1130 0 : ulong epoch = ULONG_MAX;
1131 0 : for( ulong i = 0UL; i<2UL; i++ ) {
1132 0 : if( FD_LIKELY( gui->epoch.has_epoch[ i ] ) ) {
1133 : /* the "current" epoch is the smallest */
1134 0 : epoch_start_slot = fd_ulong_min( epoch_start_slot, gui->epoch.epochs[ i ].start_slot );
1135 0 : epoch = fd_ulong_min( epoch, gui->epoch.epochs[ i ].epoch );
1136 0 : }
1137 0 : }
1138 :
1139 0 : if( FD_UNLIKELY( epoch==ULONG_MAX ) ) return;
1140 0 : ulong epoch_idx = epoch % 2UL;
1141 :
1142 : /* No new slots since the last update */
1143 0 : if( FD_UNLIKELY( gui->epoch.epochs[ epoch_idx ].rankings_slot>gui->summary.slot_rooted ) ) return;
1144 :
1145 : /* Slots before startup_ledger_max_slot are unavailable. */
1146 0 : gui->epoch.epochs[ epoch_idx ].rankings_slot = fd_ulong_max( gui->epoch.epochs[ epoch_idx ].rankings_slot, gui->summary.startup_progress.startup_ledger_max_slot+1UL );
1147 :
1148 : /* Update the rankings. Only look through slots we haven't already. */
1149 0 : for( ulong s = gui->summary.slot_rooted; s>=gui->epoch.epochs[ epoch_idx ].rankings_slot; s--) {
1150 0 : fd_gui_slot_t const * slot = fd_gui_get_slot_const( gui, s );
1151 0 : if( FD_UNLIKELY( !slot ) ) break;
1152 :
1153 0 : fd_gui_try_insert_ranking( gui, gui->epoch.epochs[ epoch_idx ].rankings, slot );
1154 0 : if( FD_UNLIKELY( slot->mine ) ) fd_gui_try_insert_ranking( gui, gui->epoch.epochs[ epoch_idx ].my_rankings, slot );
1155 0 : }
1156 :
1157 0 : gui->epoch.epochs[ epoch_idx ].rankings_slot = gui->summary.slot_rooted + 1UL;
1158 0 : }
1159 :
1160 : int
1161 : fd_gui_request_slot_rankings( fd_gui_t * gui,
1162 : ulong ws_conn_id,
1163 : ulong request_id,
1164 0 : cJSON const * params ) {
1165 0 : const cJSON * slot_param = cJSON_GetObjectItemCaseSensitive( params, "mine" );
1166 0 : if( FD_UNLIKELY( !cJSON_IsBool( slot_param ) ) ) return FD_HTTP_SERVER_CONNECTION_CLOSE_BAD_REQUEST;
1167 :
1168 0 : int mine = !!(slot_param->type & cJSON_True);
1169 0 : fd_gui_update_slot_rankings( gui );
1170 0 : fd_gui_printf_slot_rankings_request( gui, request_id, mine );
1171 0 : FD_TEST( !fd_http_server_ws_send( gui->http, ws_conn_id ) );
1172 0 : return 0;
1173 0 : }
1174 :
1175 : int
1176 : fd_gui_request_slot_shreds( fd_gui_t * gui,
1177 : ulong ws_conn_id,
1178 : ulong request_id,
1179 0 : cJSON const * params ) {
1180 0 : const cJSON * slot_param = cJSON_GetObjectItemCaseSensitive( params, "slot" );
1181 0 : if( FD_UNLIKELY( !cJSON_IsNumber( slot_param ) ) ) return FD_HTTP_SERVER_CONNECTION_CLOSE_BAD_REQUEST;
1182 :
1183 0 : ulong _slot = slot_param->valueulong;
1184 :
1185 0 : fd_gui_slot_t const * slot = fd_gui_get_slot( gui, _slot );
1186 0 : if( FD_UNLIKELY( !slot || gui->shreds.history_tail > slot->shreds.end_offset + FD_GUI_SHREDS_HISTORY_SZ ) ) {
1187 0 : fd_gui_printf_null_query_response( gui->http, "slot", "query_rankings", request_id );
1188 0 : FD_TEST( !fd_http_server_ws_send( gui->http, ws_conn_id ) );
1189 0 : return 0;
1190 0 : }
1191 :
1192 0 : fd_gui_printf_slot_shred_updates( gui, _slot, request_id );
1193 0 : FD_TEST( !fd_http_server_ws_send( gui->http, ws_conn_id ) );
1194 0 : return 0;
1195 0 : }
1196 :
1197 : int
1198 : fd_gui_ws_message( fd_gui_t * gui,
1199 : ulong ws_conn_id,
1200 : uchar const * data,
1201 0 : ulong data_len ) {
1202 : /* TODO: cJSON allocates, might fail SIGSYS due to brk(2)...
1203 : switch off this (or use wksp allocator) */
1204 0 : const char * parse_end;
1205 0 : cJSON * json = cJSON_ParseWithLengthOpts( (char *)data, data_len, &parse_end, 0 );
1206 0 : if( FD_UNLIKELY( !json ) ) {
1207 0 : return FD_HTTP_SERVER_CONNECTION_CLOSE_BAD_REQUEST;
1208 0 : }
1209 :
1210 0 : const cJSON * node = cJSON_GetObjectItemCaseSensitive( json, "id" );
1211 0 : if( FD_UNLIKELY( !cJSON_IsNumber( node ) ) ) {
1212 0 : cJSON_Delete( json );
1213 0 : return FD_HTTP_SERVER_CONNECTION_CLOSE_BAD_REQUEST;
1214 0 : }
1215 0 : ulong id = node->valueulong;
1216 :
1217 0 : const cJSON * topic = cJSON_GetObjectItemCaseSensitive( json, "topic" );
1218 0 : if( FD_UNLIKELY( !cJSON_IsString( topic ) || topic->valuestring==NULL ) ) {
1219 0 : cJSON_Delete( json );
1220 0 : return FD_HTTP_SERVER_CONNECTION_CLOSE_BAD_REQUEST;
1221 0 : }
1222 :
1223 0 : const cJSON * key = cJSON_GetObjectItemCaseSensitive( json, "key" );
1224 0 : if( FD_UNLIKELY( !cJSON_IsString( key ) || key->valuestring==NULL ) ) {
1225 0 : cJSON_Delete( json );
1226 0 : return FD_HTTP_SERVER_CONNECTION_CLOSE_BAD_REQUEST;
1227 0 : }
1228 :
1229 0 : if( FD_LIKELY( !strcmp( topic->valuestring, "slot" ) && !strcmp( key->valuestring, "query" ) ) ) {
1230 0 : const cJSON * params = cJSON_GetObjectItemCaseSensitive( json, "params" );
1231 0 : if( FD_UNLIKELY( !cJSON_IsObject( params ) ) ) {
1232 0 : cJSON_Delete( json );
1233 0 : return FD_HTTP_SERVER_CONNECTION_CLOSE_BAD_REQUEST;
1234 0 : }
1235 :
1236 0 : int result = fd_gui_request_slot( gui, ws_conn_id, id, params );
1237 0 : cJSON_Delete( json );
1238 0 : return result;
1239 0 : } else if( FD_LIKELY( !strcmp( topic->valuestring, "slot" ) && !strcmp( key->valuestring, "query_detailed" ) ) ) {
1240 0 : const cJSON * params = cJSON_GetObjectItemCaseSensitive( json, "params" );
1241 0 : if( FD_UNLIKELY( !cJSON_IsObject( params ) ) ) {
1242 0 : cJSON_Delete( json );
1243 0 : return FD_HTTP_SERVER_CONNECTION_CLOSE_BAD_REQUEST;
1244 0 : }
1245 :
1246 0 : int result = fd_gui_request_slot_detailed( gui, ws_conn_id, id, params );
1247 0 : cJSON_Delete( json );
1248 0 : return result;
1249 0 : } else if( FD_LIKELY( !strcmp( topic->valuestring, "slot" ) && !strcmp( key->valuestring, "query_transactions" ) ) ) {
1250 0 : const cJSON * params = cJSON_GetObjectItemCaseSensitive( json, "params" );
1251 0 : if( FD_UNLIKELY( !cJSON_IsObject( params ) ) ) {
1252 0 : cJSON_Delete( json );
1253 0 : return FD_HTTP_SERVER_CONNECTION_CLOSE_BAD_REQUEST;
1254 0 : }
1255 :
1256 0 : int result = fd_gui_request_slot_transactions( gui, ws_conn_id, id, params );
1257 0 : cJSON_Delete( json );
1258 0 : return result;
1259 0 : } else if( FD_LIKELY( !strcmp( topic->valuestring, "slot" ) && !strcmp( key->valuestring, "query_rankings" ) ) ) {
1260 0 : const cJSON * params = cJSON_GetObjectItemCaseSensitive( json, "params" );
1261 0 : if( FD_UNLIKELY( !cJSON_IsObject( params ) ) ) {
1262 0 : cJSON_Delete( json );
1263 0 : return FD_HTTP_SERVER_CONNECTION_CLOSE_BAD_REQUEST;
1264 0 : }
1265 :
1266 0 : int result = fd_gui_request_slot_rankings( gui, ws_conn_id, id, params );
1267 0 : cJSON_Delete( json );
1268 0 : return result;
1269 0 : } else if( FD_LIKELY( !strcmp( topic->valuestring, "slot" ) && !strcmp( key->valuestring, "query_shreds" ) ) ) {
1270 0 : const cJSON * params = cJSON_GetObjectItemCaseSensitive( json, "params" );
1271 0 : if( FD_UNLIKELY( !cJSON_IsObject( params ) ) ) {
1272 0 : cJSON_Delete( json );
1273 0 : return FD_HTTP_SERVER_CONNECTION_CLOSE_BAD_REQUEST;
1274 0 : }
1275 :
1276 0 : int result = fd_gui_request_slot_shreds( gui, ws_conn_id, id, params );
1277 0 : cJSON_Delete( json );
1278 0 : return result;
1279 0 : } else if( FD_LIKELY( !strcmp( topic->valuestring, "summary" ) && !strcmp( key->valuestring, "ping" ) ) ) {
1280 0 : fd_gui_printf_summary_ping( gui, id );
1281 0 : FD_TEST( !fd_http_server_ws_send( gui->http, ws_conn_id ) );
1282 :
1283 0 : cJSON_Delete( json );
1284 0 : return 0;
1285 0 : }
1286 :
1287 0 : cJSON_Delete( json );
1288 0 : return FD_HTTP_SERVER_CONNECTION_CLOSE_UNKNOWN_METHOD;
1289 0 : }
1290 :
1291 : static fd_gui_slot_t *
1292 : fd_gui_clear_slot( fd_gui_t * gui,
1293 : ulong _slot,
1294 0 : ulong _parent_slot ) {
1295 0 : fd_gui_slot_t * slot = gui->slots[ _slot % FD_GUI_SLOTS_CNT ];
1296 :
1297 0 : int mine = 0;
1298 0 : ulong epoch_idx = 0UL;
1299 0 : for( ulong i=0UL; i<2UL; i++) {
1300 0 : if( FD_UNLIKELY( !gui->epoch.has_epoch[ i ] ) ) continue;
1301 0 : if( FD_LIKELY( _slot>=gui->epoch.epochs[ i ].start_slot && _slot<=gui->epoch.epochs[ i ].end_slot ) ) {
1302 0 : fd_pubkey_t const * slot_leader = fd_epoch_leaders_get( gui->epoch.epochs[ i ].lsched, _slot );
1303 0 : mine = !memcmp( slot_leader->uc, gui->summary.identity_key->uc, 32UL );
1304 0 : epoch_idx = i;
1305 0 : break;
1306 0 : }
1307 0 : }
1308 :
1309 0 : slot->slot = _slot;
1310 0 : slot->parent_slot = _parent_slot;
1311 0 : slot->max_compute_units = UINT_MAX;
1312 0 : slot->completed_time = LONG_MAX;
1313 0 : slot->mine = mine;
1314 0 : slot->skipped = 0;
1315 0 : slot->must_republish = 1;
1316 0 : slot->level = FD_GUI_SLOT_LEVEL_INCOMPLETE;
1317 0 : slot->total_txn_cnt = UINT_MAX;
1318 0 : slot->vote_txn_cnt = UINT_MAX;
1319 0 : slot->failed_txn_cnt = UINT_MAX;
1320 0 : slot->nonvote_failed_txn_cnt = UINT_MAX;
1321 0 : slot->compute_units = UINT_MAX;
1322 0 : slot->transaction_fee = ULONG_MAX;
1323 0 : slot->priority_fee = ULONG_MAX;
1324 0 : slot->tips = ULONG_MAX;
1325 0 : slot->shred_cnt = UINT_MAX;
1326 0 : slot->shreds.start_offset = ULONG_MAX;
1327 0 : slot->shreds.end_offset = ULONG_MAX;
1328 :
1329 0 : if( FD_LIKELY( slot->mine ) ) {
1330 : /* All slots start off not skipped, until we see it get off the reset
1331 : chain. */
1332 0 : gui->epoch.epochs[ epoch_idx ].my_total_slots++;
1333 :
1334 0 : slot->leader_history_idx = gui->leader_slots_cnt++;
1335 0 : fd_gui_leader_slot_t * lslot = gui->leader_slots[ slot->leader_history_idx % FD_GUI_LEADER_CNT ];
1336 :
1337 0 : lslot->slot = _slot;
1338 0 : lslot->leader_start_time = LONG_MAX;
1339 0 : lslot->leader_end_time = LONG_MAX;
1340 0 : lslot->tile_timers_sample_cnt = ULONG_MAX;
1341 0 : lslot->txs.microblocks_upper_bound = USHORT_MAX;
1342 0 : lslot->txs.begin_microblocks = 0U;
1343 0 : lslot->txs.end_microblocks = 0U;
1344 0 : lslot->txs.start_offset = ULONG_MAX;
1345 0 : lslot->txs.end_offset = ULONG_MAX;
1346 0 : }
1347 :
1348 0 : if( FD_UNLIKELY( !_slot ) ) {
1349 : /* Slot 0 is always rooted */
1350 0 : slot->level = FD_GUI_SLOT_LEVEL_ROOTED;
1351 0 : }
1352 :
1353 0 : return slot;
1354 0 : }
1355 :
1356 : static void
1357 : fd_gui_handle_leader_schedule( fd_gui_t * gui,
1358 : ulong const * msg,
1359 0 : long now ) {
1360 0 : ulong epoch = msg[ 0 ];
1361 0 : ulong staked_cnt = msg[ 1 ];
1362 0 : ulong start_slot = msg[ 2 ];
1363 0 : ulong slot_cnt = msg[ 3 ];
1364 0 : ulong excluded_stake = msg[ 4 ];
1365 0 : ulong vote_keyed_lsched = msg[ 5 ];
1366 :
1367 0 : FD_TEST( staked_cnt<=MAX_STAKED_LEADERS );
1368 0 : FD_TEST( slot_cnt<=MAX_SLOTS_PER_EPOCH );
1369 :
1370 0 : ulong idx = epoch % 2UL;
1371 0 : gui->epoch.has_epoch[ idx ] = 1;
1372 :
1373 0 : gui->epoch.epochs[ idx ].epoch = epoch;
1374 0 : gui->epoch.epochs[ idx ].start_slot = start_slot;
1375 0 : gui->epoch.epochs[ idx ].end_slot = start_slot + slot_cnt - 1; // end_slot is inclusive.
1376 0 : gui->epoch.epochs[ idx ].excluded_stake = excluded_stake;
1377 0 : gui->epoch.epochs[ idx ].my_total_slots = 0UL;
1378 0 : gui->epoch.epochs[ idx ].my_skipped_slots = 0UL;
1379 :
1380 0 : memset( gui->epoch.epochs[ idx ].rankings, (int)(UINT_MAX), sizeof(gui->epoch.epochs[ idx ].rankings) );
1381 0 : memset( gui->epoch.epochs[ idx ].my_rankings, (int)(UINT_MAX), sizeof(gui->epoch.epochs[ idx ].my_rankings) );
1382 :
1383 0 : gui->epoch.epochs[ idx ].rankings_slot = start_slot;
1384 :
1385 0 : fd_vote_stake_weight_t const * stake_weights = fd_type_pun_const( msg+6UL );
1386 0 : memcpy( gui->epoch.epochs[ idx ].stakes, stake_weights, staked_cnt*sizeof(fd_vote_stake_weight_t) );
1387 :
1388 0 : fd_epoch_leaders_delete( fd_epoch_leaders_leave( gui->epoch.epochs[ idx ].lsched ) );
1389 0 : gui->epoch.epochs[idx].lsched = fd_epoch_leaders_join( fd_epoch_leaders_new( gui->epoch.epochs[ idx ]._lsched,
1390 0 : epoch,
1391 0 : gui->epoch.epochs[ idx ].start_slot,
1392 0 : slot_cnt,
1393 0 : staked_cnt,
1394 0 : gui->epoch.epochs[ idx ].stakes,
1395 0 : excluded_stake,
1396 0 : vote_keyed_lsched ) );
1397 :
1398 0 : if( FD_UNLIKELY( start_slot==0UL ) ) {
1399 0 : gui->epoch.epochs[ 0 ].start_time = now;
1400 0 : } else {
1401 0 : gui->epoch.epochs[ idx ].start_time = LONG_MAX;
1402 :
1403 0 : for( ulong i=0UL; i<fd_ulong_min( start_slot-1UL, FD_GUI_SLOTS_CNT ); i++ ) {
1404 0 : fd_gui_slot_t const * slot = fd_gui_get_slot_const( gui, start_slot-i );
1405 0 : if( FD_UNLIKELY( !slot ) ) break;
1406 0 : else if( FD_UNLIKELY( slot->skipped ) ) continue;
1407 :
1408 0 : gui->epoch.epochs[ idx ].start_time = slot->completed_time;
1409 0 : break;
1410 0 : }
1411 0 : }
1412 :
1413 0 : fd_gui_printf_epoch( gui, idx );
1414 0 : fd_http_server_ws_broadcast( gui->http );
1415 0 : }
1416 :
1417 : static void
1418 : fd_gui_handle_slot_start( fd_gui_t * gui,
1419 : ulong * msg,
1420 0 : long now ) {
1421 0 : ulong _slot = msg[ 0 ];
1422 0 : ulong _parent_slot = msg[ 1 ];
1423 : // FD_LOG_WARNING(( "Got start slot %lu parent_slot %lu", _slot, _parent_slot ));
1424 0 : FD_TEST( gui->debug_in_leader_slot==ULONG_MAX );
1425 0 : gui->debug_in_leader_slot = _slot;
1426 :
1427 0 : fd_gui_slot_t * slot = fd_gui_get_slot( gui, _slot );
1428 0 : if( FD_UNLIKELY( !slot ) ) slot = fd_gui_clear_slot( gui, _slot, _parent_slot );
1429 :
1430 0 : fd_gui_tile_timers_snap( gui );
1431 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;
1432 :
1433 0 : fd_gui_txn_waterfall_t waterfall[ 1 ];
1434 0 : fd_gui_txn_waterfall_snap( gui, waterfall );
1435 0 : fd_gui_tile_stats_snap( gui, waterfall, slot->tile_stats_begin, now );
1436 0 : }
1437 :
1438 : static void
1439 : fd_gui_handle_slot_end( fd_gui_t * gui,
1440 : ulong * msg,
1441 0 : long now ) {
1442 0 : ulong _slot = msg[ 0 ];
1443 0 : ulong _cus_used = msg[ 1 ];
1444 0 : if( FD_UNLIKELY( gui->debug_in_leader_slot!=_slot ) ) {
1445 0 : FD_LOG_ERR(( "gui->debug_in_leader_slot %lu _slot %lu", gui->debug_in_leader_slot, _slot ));
1446 0 : }
1447 0 : gui->debug_in_leader_slot = ULONG_MAX;
1448 :
1449 0 : fd_gui_slot_t * slot = fd_gui_get_slot( gui, _slot );
1450 0 : FD_TEST( slot );
1451 :
1452 0 : slot->compute_units = (uint)_cus_used;
1453 :
1454 0 : fd_gui_tile_timers_snap( gui );
1455 :
1456 : /* Downsample tile timers. */
1457 0 : ulong end = gui->summary.tile_timers_snap_idx;
1458 0 : end = fd_ulong_if( end<gui->summary.tile_timers_snap_idx_slot_start, end+FD_GUI_TILE_TIMER_SNAP_CNT, end );
1459 :
1460 0 : fd_gui_leader_slot_t * lslot = fd_gui_get_leader_slot( gui, _slot );
1461 0 : if( FD_LIKELY( lslot ) ) {
1462 0 : lslot->tile_timers_sample_cnt = end-gui->summary.tile_timers_snap_idx_slot_start;
1463 0 : ulong stride = fd_ulong_max( 1UL, (end-gui->summary.tile_timers_snap_idx_slot_start) / FD_GUI_TILE_TIMER_LEADER_DOWNSAMPLE_CNT );
1464 0 : for( ulong sample_snap_idx=gui->summary.tile_timers_snap_idx_slot_start, i=0UL; sample_snap_idx<end; sample_snap_idx+=stride, i++ ) {
1465 0 : memcpy( lslot->tile_timers[ i ], gui->summary.tile_timers_snap[ sample_snap_idx%FD_GUI_TILE_TIMER_SNAP_CNT ], sizeof(lslot->tile_timers[ i ]) );
1466 0 : }
1467 0 : }
1468 :
1469 : /* When a slot ends, snap the state of the waterfall and save it into
1470 : that slot, and also reset the reference counters to the end of the
1471 : slot. */
1472 :
1473 0 : fd_gui_txn_waterfall_snap( gui, slot->waterfall_end );
1474 0 : memcpy( slot->waterfall_begin, gui->summary.txn_waterfall_reference, sizeof(slot->waterfall_begin) );
1475 0 : memcpy( gui->summary.txn_waterfall_reference, slot->waterfall_end, sizeof(gui->summary.txn_waterfall_reference) );
1476 :
1477 0 : fd_gui_tile_stats_snap( gui, slot->waterfall_end, slot->tile_stats_end, now );
1478 0 : }
1479 :
1480 : static inline void
1481 0 : fd_gui_try_insert_ephemeral_slot( fd_gui_ephemeral_slot_t * slots, ulong slots_sz, ulong slot, long now ) {
1482 0 : int already_present = 0;
1483 0 : for( ulong i=0UL; i<slots_sz; i++ ) {
1484 : /* evict any slots older than 4.8 seconds */
1485 0 : if( FD_UNLIKELY( slots[ i ].slot!=ULONG_MAX && now-slots[ i ].timestamp_arrival_nanos>4800000000L ) ) {
1486 0 : slots[ i ].slot = ULONG_MAX;
1487 0 : continue;
1488 0 : }
1489 :
1490 : /* if we've already seen this slot, just update the timestamp */
1491 0 : if( FD_UNLIKELY( slots[ i ].slot==slot ) ) {
1492 0 : slots[ i ].timestamp_arrival_nanos = now;
1493 0 : already_present = 1;
1494 0 : }
1495 0 : }
1496 0 : if( FD_LIKELY( already_present ) ) return;
1497 :
1498 : /* Insert the new slot number, evicting a smaller slot if necessary */
1499 0 : slots[ slots_sz ].timestamp_arrival_nanos = now;
1500 0 : slots[ slots_sz ].slot = slot;
1501 0 : fd_gui_ephemeral_slot_sort_insert( slots, slots_sz+1UL );
1502 0 : }
1503 :
1504 : static inline void
1505 0 : fd_gui_try_insert_catch_up_slot( ulong * slots, ulong * slots_sz, ulong slot ) {
1506 : /* catch up history is run-length encoded */
1507 0 : int inserted = 0;
1508 0 : for( ulong i=0UL; i<*slots_sz; i++ ) {
1509 0 : if( FD_UNLIKELY( i%2UL==1UL && slots[ i ]==slot-1UL ) ) {
1510 0 : slots[ i ]++;
1511 0 : inserted = 1;
1512 0 : break;
1513 0 : } else if( FD_UNLIKELY( i%2UL==0UL && slots[ i ]==slot+1UL ) ) {
1514 0 : slots[ i ]--;
1515 0 : inserted = 1;
1516 0 : break;
1517 0 : }
1518 0 : }
1519 0 : if( FD_LIKELY( !inserted ) ) {
1520 0 : slots[ (*slots_sz)++ ] = slot;
1521 0 : slots[ (*slots_sz)++ ] = slot;
1522 0 : }
1523 :
1524 : /* colesce intervals that touch */
1525 0 : ulong removed = 0UL;
1526 0 : for( ulong i=1UL; i<(*slots_sz)-1UL; i+=2 ) {
1527 0 : if( FD_UNLIKELY( slots[ i ]==slots[ i+1UL ] ) ) {
1528 0 : slots[ i ] = ULONG_MAX;
1529 0 : slots[ i+1UL ] = ULONG_MAX;
1530 0 : removed += 2;
1531 0 : }
1532 0 : }
1533 :
1534 0 : fd_sort_up_ulong_insert( slots, (*slots_sz) );
1535 0 : (*slots_sz) -= removed;
1536 0 : }
1537 :
1538 : static inline int
1539 0 : fd_gui_ephemeral_slots_contains( fd_gui_ephemeral_slot_t * slots, ulong slots_sz, ulong slot ) {
1540 0 : for( ulong i=0UL; i<slots_sz; i++ ) {
1541 0 : if( FD_UNLIKELY( slots[ i ].slot==ULONG_MAX ) ) break;
1542 0 : if( FD_UNLIKELY( slots[ i ].slot==slot ) ) return 1;
1543 0 : }
1544 0 : return 0;
1545 0 : }
1546 :
1547 : void
1548 : fd_gui_handle_shred( fd_gui_t * gui,
1549 : ulong slot,
1550 : ulong shred_idx,
1551 : ulong fec_idx,
1552 : int is_turbine,
1553 0 : long tsorig ) {
1554 0 : int was_sent = fd_gui_ephemeral_slots_contains( gui->summary.slots_max_turbine, FD_GUI_TURBINE_SLOT_HISTORY_SZ, slot );
1555 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 );
1556 :
1557 0 : if( FD_UNLIKELY( !was_sent && is_turbine && slot!=gui->summary.slot_turbine ) ) {
1558 0 : gui->summary.slot_turbine = slot;
1559 :
1560 0 : fd_gui_printf_turbine_slot( gui );
1561 0 : fd_http_server_ws_broadcast( gui->http );
1562 :
1563 0 : if( FD_UNLIKELY( gui->summary.slot_caught_up==ULONG_MAX ) ) fd_gui_try_insert_catch_up_slot( gui->summary.catch_up_turbine, &gui->summary.catch_up_turbine_sz, slot );
1564 0 : }
1565 :
1566 0 : fd_gui_slot_staged_shred_event_t * recv_event = &gui->shreds.staged[ gui->shreds.staged_tail++ ];
1567 0 : recv_event->timestamp = tsorig;
1568 0 : recv_event->shred_idx = (ushort)shred_idx;
1569 0 : recv_event->fec_idx = (ushort)fec_idx;
1570 0 : recv_event->slot = slot;
1571 0 : recv_event->event = fd_uchar_if( is_turbine, FD_GUI_SLOT_SHRED_SHRED_RECEIVED_TURBINE, FD_GUI_SLOT_SHRED_SHRED_RECEIVED_REPAIR );
1572 0 : }
1573 :
1574 : void
1575 0 : fd_gui_handle_repair_slot( fd_gui_t * gui, ulong slot, long now ) {
1576 0 : int was_sent = fd_gui_ephemeral_slots_contains( gui->summary.slots_max_repair, FD_GUI_REPAIR_SLOT_HISTORY_SZ, slot );
1577 0 : fd_gui_try_insert_ephemeral_slot( gui->summary.slots_max_repair, FD_GUI_REPAIR_SLOT_HISTORY_SZ, slot, now );
1578 :
1579 0 : if( FD_UNLIKELY( !was_sent && slot!=gui->summary.slot_repair ) ) {
1580 0 : gui->summary.slot_repair = slot;
1581 :
1582 0 : fd_gui_printf_repair_slot( gui );
1583 0 : fd_http_server_ws_broadcast( gui->http );
1584 :
1585 0 : if( FD_UNLIKELY( gui->summary.slot_caught_up==ULONG_MAX ) ) fd_gui_try_insert_catch_up_slot( gui->summary.catch_up_repair, &gui->summary.catch_up_repair_sz, slot );
1586 0 : }
1587 0 : }
1588 :
1589 : static void
1590 : fd_gui_handle_reset_slot_legacy( fd_gui_t * gui,
1591 : ulong * msg,
1592 0 : long now ) {
1593 0 : ulong last_landed_vote = msg[ 0 ];
1594 :
1595 0 : ulong parent_cnt = msg[ 1 ];
1596 0 : FD_TEST( parent_cnt<4096UL );
1597 :
1598 0 : ulong _slot = msg[ 2 ];
1599 :
1600 0 : for( ulong i=0UL; i<parent_cnt; i++ ) {
1601 0 : ulong parent_slot = msg[2UL+i];
1602 0 : fd_gui_slot_t * slot = fd_gui_get_slot( gui, parent_slot );
1603 0 : if( FD_UNLIKELY( !slot ) ) {
1604 0 : ulong parent_parent_slot = ULONG_MAX;
1605 0 : if( FD_UNLIKELY( i!=parent_cnt-1UL) ) parent_parent_slot = msg[ 3UL+i ];
1606 0 : fd_gui_clear_slot( gui, parent_slot, parent_parent_slot );
1607 0 : }
1608 0 : }
1609 :
1610 0 : if( FD_UNLIKELY( gui->summary.vote_distance!=_slot-last_landed_vote ) ) {
1611 0 : gui->summary.vote_distance = _slot-last_landed_vote;
1612 0 : fd_gui_printf_vote_distance( gui );
1613 0 : fd_http_server_ws_broadcast( gui->http );
1614 0 : }
1615 :
1616 0 : if( FD_LIKELY( gui->summary.vote_state!=FD_GUI_VOTE_STATE_NON_VOTING ) ) {
1617 0 : if( FD_UNLIKELY( last_landed_vote==ULONG_MAX || (last_landed_vote+150UL)<_slot ) ) {
1618 0 : if( FD_UNLIKELY( gui->summary.vote_state!=FD_GUI_VOTE_STATE_DELINQUENT ) ) {
1619 0 : gui->summary.vote_state = FD_GUI_VOTE_STATE_DELINQUENT;
1620 0 : fd_gui_printf_vote_state( gui );
1621 0 : fd_http_server_ws_broadcast( gui->http );
1622 0 : }
1623 0 : } else {
1624 0 : if( FD_UNLIKELY( gui->summary.vote_state!=FD_GUI_VOTE_STATE_VOTING ) ) {
1625 0 : gui->summary.vote_state = FD_GUI_VOTE_STATE_VOTING;
1626 0 : fd_gui_printf_vote_state( gui );
1627 0 : fd_http_server_ws_broadcast( gui->http );
1628 0 : }
1629 0 : }
1630 0 : }
1631 :
1632 0 : ulong parent_slot_idx = 0UL;
1633 :
1634 0 : int republish_skip_rate[ 2 ] = {0};
1635 :
1636 0 : for( ulong i=0UL; i<fd_ulong_min( _slot+1, FD_GUI_SLOTS_CNT ); i++ ) {
1637 0 : ulong parent_slot = _slot - i;
1638 :
1639 0 : fd_gui_slot_t * slot = fd_gui_get_slot( gui, parent_slot );
1640 0 : if( FD_UNLIKELY( !slot ) ) slot = fd_gui_clear_slot( gui, parent_slot, ULONG_MAX );
1641 :
1642 : /* The chain of parents may stretch into already rooted slots if
1643 : they haven't been squashed yet, if we reach one of them we can
1644 : just exit, all the information prior to the root is already
1645 : correct. */
1646 :
1647 0 : if( FD_LIKELY( slot->level>=FD_GUI_SLOT_LEVEL_ROOTED ) ) break;
1648 :
1649 0 : int should_republish = slot->must_republish;
1650 0 : slot->must_republish = 0;
1651 :
1652 0 : if( FD_UNLIKELY( parent_slot!=msg[2UL+parent_slot_idx] ) ) {
1653 : /* We are between two parents in the rooted chain, which means
1654 : we were skipped. */
1655 0 : if( FD_UNLIKELY( !slot->skipped ) ) {
1656 0 : slot->skipped = 1;
1657 0 : should_republish = 1;
1658 0 : if( FD_LIKELY( slot->mine ) ) {
1659 0 : for( ulong i=0UL; i<2UL; i++ ) {
1660 0 : if( FD_LIKELY( parent_slot>=gui->epoch.epochs[ i ].start_slot && parent_slot<=gui->epoch.epochs[ i ].end_slot ) ) {
1661 0 : gui->epoch.epochs[ i ].my_skipped_slots++;
1662 0 : republish_skip_rate[ i ] = 1;
1663 0 : break;
1664 0 : }
1665 0 : }
1666 0 : }
1667 0 : }
1668 0 : } else {
1669 : /* Reached the next parent... */
1670 0 : if( FD_UNLIKELY( slot->skipped ) ) {
1671 0 : slot->skipped = 0;
1672 0 : should_republish = 1;
1673 0 : if( FD_LIKELY( slot->mine ) ) {
1674 0 : for( ulong i=0UL; i<2UL; i++ ) {
1675 0 : if( FD_LIKELY( parent_slot>=gui->epoch.epochs[ i ].start_slot && parent_slot<=gui->epoch.epochs[ i ].end_slot ) ) {
1676 0 : gui->epoch.epochs[ i ].my_skipped_slots--;
1677 0 : republish_skip_rate[ i ] = 1;
1678 0 : break;
1679 0 : }
1680 0 : }
1681 0 : }
1682 0 : }
1683 0 : parent_slot_idx++;
1684 0 : }
1685 :
1686 0 : if( FD_LIKELY( should_republish ) ) {
1687 0 : fd_gui_printf_slot( gui, parent_slot );
1688 0 : fd_http_server_ws_broadcast( gui->http );
1689 0 : }
1690 :
1691 : /* We reached the last parent in the chain, everything above this
1692 : must have already been rooted, so we can exit. */
1693 :
1694 0 : if( FD_UNLIKELY( parent_slot_idx>=parent_cnt ) ) break;
1695 0 : }
1696 :
1697 0 : ulong duration_sum = 0UL;
1698 0 : ulong slot_cnt = 0UL;
1699 :
1700 : /* If we've just caught up we should truncate our slot history to avoid including catch-up slots */
1701 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;
1702 0 : ulong slot_duration_history_sz = fd_ulong_if( just_caught_up, _slot-gui->summary.slot_caught_up, 750UL );
1703 0 : for( ulong i=0UL; i<fd_ulong_min( _slot+1, slot_duration_history_sz ); i++ ) {
1704 0 : ulong parent_slot = _slot - i;
1705 :
1706 0 : fd_gui_slot_t const * slot = fd_gui_get_slot_const( gui, parent_slot );
1707 0 : if( FD_UNLIKELY( !slot) ) break;
1708 0 : if( FD_UNLIKELY( slot->slot!=parent_slot ) ) {
1709 0 : FD_LOG_ERR(( "_slot %lu i %lu we expect _slot-i %lu got slot->slot %lu", _slot, i, _slot-i, slot->slot ));
1710 0 : }
1711 :
1712 0 : ulong slot_duration = fd_gui_slot_duration( gui, slot );
1713 0 : if( FD_LIKELY( slot_duration!=ULONG_MAX ) ) {
1714 0 : duration_sum += slot_duration;
1715 0 : slot_cnt++;
1716 0 : }
1717 0 : }
1718 :
1719 0 : if( FD_LIKELY( slot_cnt>0 )) {
1720 0 : gui->summary.estimated_slot_duration_nanos = (ulong)(duration_sum / slot_cnt);
1721 0 : fd_gui_printf_estimated_slot_duration_nanos( gui );
1722 0 : fd_http_server_ws_broadcast( gui->http );
1723 0 : }
1724 :
1725 0 : if( FD_LIKELY( gui->summary.slot_completed==ULONG_MAX || _slot!=gui->summary.slot_completed ) ) {
1726 0 : gui->summary.slot_completed = _slot;
1727 0 : fd_gui_printf_completed_slot( gui );
1728 0 : fd_http_server_ws_broadcast( gui->http );
1729 :
1730 : /* Also update slot_turbine which could be larger than the max
1731 : turbine slot if we are leader */
1732 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 ) ) {
1733 0 : fd_gui_try_insert_ephemeral_slot( gui->summary.slots_max_turbine, FD_GUI_TURBINE_SLOT_HISTORY_SZ, gui->summary.slot_completed, now );
1734 0 : }
1735 :
1736 0 : int slot_turbine_hist_full = gui->summary.slots_max_turbine[ FD_GUI_TURBINE_SLOT_HISTORY_SZ-1UL ].slot!=ULONG_MAX;
1737 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) ) ) {
1738 0 : gui->summary.slot_caught_up = gui->summary.slot_completed + 4UL;
1739 :
1740 0 : fd_gui_printf_slot_caught_up( gui );
1741 0 : fd_http_server_ws_broadcast( gui->http );
1742 0 : }
1743 0 : }
1744 :
1745 0 : for( ulong i=0UL; i<2UL; i++ ) {
1746 0 : if( FD_LIKELY( republish_skip_rate[ i ] ) ) {
1747 0 : fd_gui_printf_skip_rate( gui, i );
1748 0 : fd_http_server_ws_broadcast( gui->http );
1749 0 : }
1750 0 : }
1751 0 : }
1752 :
1753 : static void
1754 : fd_gui_handle_completed_slot( fd_gui_t * gui,
1755 : ulong * msg,
1756 0 : long now ) {
1757 0 : ulong _slot = msg[ 0 ];
1758 0 : uint total_txn_count = (uint)msg[ 1 ];
1759 0 : uint nonvote_txn_count = (uint)msg[ 2 ];
1760 0 : uint failed_txn_count = (uint)msg[ 3 ];
1761 0 : uint nonvote_failed_txn_count = (uint)msg[ 4 ];
1762 0 : uint compute_units = (uint)msg[ 5 ];
1763 0 : ulong transaction_fee = msg[ 6 ];
1764 0 : ulong priority_fee = msg[ 7 ];
1765 0 : ulong tips = msg[ 8 ];
1766 0 : ulong _parent_slot = msg[ 9 ];
1767 0 : ulong max_compute_units = msg[ 10 ];
1768 :
1769 0 : fd_gui_slot_t * slot = fd_gui_get_slot( gui, _slot );
1770 0 : if( FD_UNLIKELY( !slot ) ) slot = fd_gui_clear_slot( gui, _slot, _parent_slot );
1771 :
1772 0 : slot->completed_time = now;
1773 0 : slot->parent_slot = _parent_slot;
1774 0 : slot->max_compute_units = (uint)max_compute_units;
1775 0 : if( FD_LIKELY( slot->level<FD_GUI_SLOT_LEVEL_COMPLETED ) ) {
1776 : /* Typically a slot goes from INCOMPLETE to COMPLETED but it can
1777 : happen that it starts higher. One such case is when we
1778 : optimistically confirm a higher slot that skips this one, but
1779 : then later we replay this one anyway to track the bank fork. */
1780 :
1781 0 : if( FD_LIKELY( gui->summary.slot_optimistically_confirmed!=ULONG_MAX && _slot<gui->summary.slot_optimistically_confirmed ) ) {
1782 : /* Cluster might have already optimistically confirmed by the time
1783 : we finish replaying it. */
1784 0 : slot->level = FD_GUI_SLOT_LEVEL_OPTIMISTICALLY_CONFIRMED;
1785 0 : } else {
1786 0 : slot->level = FD_GUI_SLOT_LEVEL_COMPLETED;
1787 0 : }
1788 0 : }
1789 0 : slot->total_txn_cnt = total_txn_count;
1790 0 : slot->vote_txn_cnt = total_txn_count - nonvote_txn_count;
1791 0 : slot->failed_txn_cnt = failed_txn_count;
1792 0 : slot->nonvote_failed_txn_cnt = nonvote_failed_txn_count;
1793 0 : slot->transaction_fee = transaction_fee;
1794 0 : slot->priority_fee = priority_fee;
1795 0 : slot->tips = tips;
1796 0 : slot->compute_units = compute_units;
1797 :
1798 0 : if( FD_UNLIKELY( gui->epoch.has_epoch[ 0 ] && _slot==gui->epoch.epochs[ 0 ].end_slot ) ) {
1799 0 : gui->epoch.epochs[ 0 ].end_time = slot->completed_time;
1800 0 : } else if( FD_UNLIKELY( gui->epoch.has_epoch[ 1 ] && _slot==gui->epoch.epochs[ 1 ].end_slot ) ) {
1801 0 : gui->epoch.epochs[ 1 ].end_time = slot->completed_time;
1802 0 : }
1803 :
1804 : /* Broadcast new skip rate if one of our slots got completed. */
1805 0 : if( FD_LIKELY( slot->mine ) ) {
1806 0 : for( ulong i=0UL; i<2UL; i++ ) {
1807 0 : if( FD_LIKELY( _slot>=gui->epoch.epochs[ i ].start_slot && _slot<=gui->epoch.epochs[ i ].end_slot ) ) {
1808 0 : fd_gui_printf_skip_rate( gui, i );
1809 0 : fd_http_server_ws_broadcast( gui->http );
1810 0 : break;
1811 0 : }
1812 0 : }
1813 0 : }
1814 0 : }
1815 :
1816 : static void
1817 : fd_gui_handle_rooted_slot_legacy( fd_gui_t * gui,
1818 0 : ulong * msg ) {
1819 0 : ulong _slot = msg[ 0 ];
1820 :
1821 : // FD_LOG_WARNING(( "Got rooted slot %lu", _slot ));
1822 :
1823 : /* Slot 0 is always rooted. No need to iterate all the way back to
1824 : i==_slot */
1825 0 : for( ulong i=0UL; i<fd_ulong_min( _slot, FD_GUI_SLOTS_CNT ); i++ ) {
1826 0 : ulong parent_slot = _slot - i;
1827 :
1828 0 : fd_gui_slot_t * slot = fd_gui_get_slot( gui, parent_slot );
1829 0 : if( FD_UNLIKELY( !slot ) ) break;
1830 :
1831 0 : if( FD_UNLIKELY( slot->slot!=parent_slot ) ) {
1832 0 : FD_LOG_ERR(( "_slot %lu i %lu we expect parent_slot %lu got slot->slot %lu", _slot, i, parent_slot, slot->slot ));
1833 0 : }
1834 0 : if( FD_UNLIKELY( slot->level>=FD_GUI_SLOT_LEVEL_ROOTED ) ) break;
1835 :
1836 0 : slot->level = FD_GUI_SLOT_LEVEL_ROOTED;
1837 0 : fd_gui_printf_slot( gui, parent_slot );
1838 0 : fd_http_server_ws_broadcast( gui->http );
1839 0 : }
1840 :
1841 0 : gui->summary.slot_rooted = _slot;
1842 0 : fd_gui_printf_root_slot( gui );
1843 0 : fd_http_server_ws_broadcast( gui->http );
1844 0 : }
1845 :
1846 : static void
1847 : fd_gui_handle_optimistically_confirmed_slot( fd_gui_t * gui,
1848 0 : ulong * msg ) {
1849 0 : ulong _slot = msg[ 0 ];
1850 :
1851 : /* Slot 0 is always rooted. No need to iterate all the way back to
1852 : i==_slot */
1853 0 : for( ulong i=0UL; i<fd_ulong_min( _slot, FD_GUI_SLOTS_CNT ); i++ ) {
1854 0 : ulong parent_slot = _slot - i;
1855 :
1856 0 : fd_gui_slot_t * slot = fd_gui_get_slot( gui, parent_slot );
1857 0 : if( FD_UNLIKELY( !slot) ) break;
1858 :
1859 0 : if( FD_UNLIKELY( slot->slot>parent_slot ) ) {
1860 0 : FD_LOG_ERR(( "_slot %lu i %lu we expect parent_slot %lu got slot->slot %lu", _slot, i, parent_slot, slot->slot ));
1861 0 : } else if( FD_UNLIKELY( slot->slot<parent_slot ) ) {
1862 : /* Slot not even replayed yet ... will come out as optimistically confirmed */
1863 0 : continue;
1864 0 : }
1865 0 : if( FD_UNLIKELY( slot->level>=FD_GUI_SLOT_LEVEL_ROOTED ) ) break;
1866 :
1867 0 : if( FD_LIKELY( slot->level<FD_GUI_SLOT_LEVEL_OPTIMISTICALLY_CONFIRMED ) ) {
1868 0 : slot->level = FD_GUI_SLOT_LEVEL_OPTIMISTICALLY_CONFIRMED;
1869 0 : fd_gui_printf_slot( gui, parent_slot );
1870 0 : fd_http_server_ws_broadcast( gui->http );
1871 0 : }
1872 0 : }
1873 :
1874 0 : if( FD_UNLIKELY( gui->summary.slot_optimistically_confirmed!=ULONG_MAX && _slot<gui->summary.slot_optimistically_confirmed ) ) {
1875 : /* Optimistically confirmed slot went backwards ... mark some slots as no
1876 : longer optimistically confirmed. */
1877 0 : for( ulong i=gui->summary.slot_optimistically_confirmed; i>=_slot; i-- ) {
1878 0 : fd_gui_slot_t * slot = fd_gui_get_slot( gui, i );
1879 0 : if( FD_UNLIKELY( !slot ) ) break;
1880 0 : if( FD_LIKELY( slot->slot==i ) ) {
1881 : /* It's possible for the optimistically confirmed slot to skip
1882 : backwards between two slots that we haven't yet replayed. In
1883 : that case we don't need to change anything, since they will
1884 : get marked properly when they get completed. */
1885 0 : slot->level = FD_GUI_SLOT_LEVEL_COMPLETED;
1886 0 : fd_gui_printf_slot( gui, i );
1887 0 : fd_http_server_ws_broadcast( gui->http );
1888 0 : }
1889 0 : }
1890 0 : }
1891 :
1892 0 : gui->summary.slot_optimistically_confirmed = _slot;
1893 0 : fd_gui_printf_optimistically_confirmed_slot( gui );
1894 0 : fd_http_server_ws_broadcast( gui->http );
1895 0 : }
1896 :
1897 : static void
1898 : fd_gui_handle_balance_update( fd_gui_t * gui,
1899 0 : ulong const * msg ) {
1900 0 : switch( msg[ 0 ] ) {
1901 0 : case 0UL:
1902 0 : gui->summary.identity_account_balance = msg[ 1 ];
1903 0 : fd_gui_printf_identity_balance( gui );
1904 0 : fd_http_server_ws_broadcast( gui->http );
1905 0 : break;
1906 0 : case 1UL:
1907 0 : gui->summary.vote_account_balance = msg[ 1 ];
1908 0 : fd_gui_printf_vote_balance( gui );
1909 0 : fd_http_server_ws_broadcast( gui->http );
1910 0 : break;
1911 0 : default:
1912 0 : FD_LOG_ERR(( "balance: unknown account type: %lu", msg[ 0 ] ));
1913 0 : }
1914 0 : }
1915 :
1916 : static void
1917 : fd_gui_handle_start_progress( fd_gui_t * gui,
1918 0 : uchar const * msg ) {
1919 0 : uchar type = msg[ 0 ];
1920 :
1921 0 : switch (type) {
1922 0 : case 0:
1923 0 : gui->summary.startup_progress.phase = FD_GUI_START_PROGRESS_TYPE_INITIALIZING;
1924 0 : FD_LOG_INFO(( "progress: initializing" ));
1925 0 : break;
1926 0 : case 1: {
1927 0 : char const * snapshot_type;
1928 0 : if( FD_UNLIKELY( gui->summary.startup_progress.startup_got_full_snapshot ) ) {
1929 0 : gui->summary.startup_progress.phase = FD_GUI_START_PROGRESS_TYPE_SEARCHING_FOR_INCREMENTAL_SNAPSHOT;
1930 0 : snapshot_type = "incremental";
1931 0 : } else {
1932 0 : gui->summary.startup_progress.phase = FD_GUI_START_PROGRESS_TYPE_SEARCHING_FOR_FULL_SNAPSHOT;
1933 0 : snapshot_type = "full";
1934 0 : }
1935 0 : FD_LOG_INFO(( "progress: searching for %s snapshot", snapshot_type ));
1936 0 : break;
1937 0 : }
1938 0 : case 2: {
1939 0 : uchar is_full_snapshot = msg[ 1 ];
1940 0 : if( FD_LIKELY( is_full_snapshot ) ) {
1941 0 : gui->summary.startup_progress.phase = FD_GUI_START_PROGRESS_TYPE_DOWNLOADING_FULL_SNAPSHOT;
1942 0 : gui->summary.startup_progress.startup_full_snapshot_slot = *((ulong *)(msg + 2));
1943 0 : gui->summary.startup_progress.startup_full_snapshot_peer_ip_addr = *((uint *)(msg + 10));
1944 0 : gui->summary.startup_progress.startup_full_snapshot_peer_port = *((ushort *)(msg + 14));
1945 0 : gui->summary.startup_progress.startup_full_snapshot_total_bytes = *((ulong *)(msg + 16));
1946 0 : gui->summary.startup_progress.startup_full_snapshot_current_bytes = *((ulong *)(msg + 24));
1947 0 : gui->summary.startup_progress.startup_full_snapshot_elapsed_secs = *((double *)(msg + 32));
1948 0 : gui->summary.startup_progress.startup_full_snapshot_remaining_secs = *((double *)(msg + 40));
1949 0 : gui->summary.startup_progress.startup_full_snapshot_throughput = *((double *)(msg + 48));
1950 0 : FD_LOG_INFO(( "progress: downloading full snapshot: slot=%lu", gui->summary.startup_progress.startup_full_snapshot_slot ));
1951 0 : } else {
1952 0 : gui->summary.startup_progress.phase = FD_GUI_START_PROGRESS_TYPE_DOWNLOADING_INCREMENTAL_SNAPSHOT;
1953 0 : gui->summary.startup_progress.startup_incremental_snapshot_slot = *((ulong *)(msg + 2));
1954 0 : gui->summary.startup_progress.startup_incremental_snapshot_peer_ip_addr = *((uint *)(msg + 10));
1955 0 : gui->summary.startup_progress.startup_incremental_snapshot_peer_port = *((ushort *)(msg + 14));
1956 0 : gui->summary.startup_progress.startup_incremental_snapshot_total_bytes = *((ulong *)(msg + 16));
1957 0 : gui->summary.startup_progress.startup_incremental_snapshot_current_bytes = *((ulong *)(msg + 24));
1958 0 : gui->summary.startup_progress.startup_incremental_snapshot_elapsed_secs = *((double *)(msg + 32));
1959 0 : gui->summary.startup_progress.startup_incremental_snapshot_remaining_secs = *((double *)(msg + 40));
1960 0 : gui->summary.startup_progress.startup_incremental_snapshot_throughput = *((double *)(msg + 48));
1961 0 : FD_LOG_INFO(( "progress: downloading incremental snapshot: slot=%lu", gui->summary.startup_progress.startup_incremental_snapshot_slot ));
1962 0 : }
1963 0 : break;
1964 0 : }
1965 0 : case 3: {
1966 0 : gui->summary.startup_progress.startup_got_full_snapshot = 1;
1967 0 : break;
1968 0 : }
1969 0 : case 4:
1970 0 : gui->summary.startup_progress.phase = FD_GUI_START_PROGRESS_TYPE_CLEANING_BLOCK_STORE;
1971 0 : FD_LOG_INFO(( "progress: cleaning block store" ));
1972 0 : break;
1973 0 : case 5:
1974 0 : gui->summary.startup_progress.phase = FD_GUI_START_PROGRESS_TYPE_CLEANING_ACCOUNTS;
1975 0 : FD_LOG_INFO(( "progress: cleaning accounts" ));
1976 0 : break;
1977 0 : case 6:
1978 0 : gui->summary.startup_progress.phase = FD_GUI_START_PROGRESS_TYPE_LOADING_LEDGER;
1979 0 : FD_LOG_INFO(( "progress: loading ledger" ));
1980 0 : break;
1981 0 : case 7: {
1982 0 : gui->summary.startup_progress.phase = FD_GUI_START_PROGRESS_TYPE_PROCESSING_LEDGER;
1983 0 : gui->summary.startup_progress.startup_ledger_slot = fd_ulong_load_8( msg + 1 );
1984 0 : gui->summary.startup_progress.startup_ledger_max_slot = fd_ulong_load_8( msg + 9 );
1985 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 ));
1986 0 : break;
1987 0 : }
1988 0 : case 8:
1989 0 : gui->summary.startup_progress.phase = FD_GUI_START_PROGRESS_TYPE_STARTING_SERVICES;
1990 0 : FD_LOG_INFO(( "progress: starting services" ));
1991 0 : break;
1992 0 : case 9:
1993 0 : gui->summary.startup_progress.phase = FD_GUI_START_PROGRESS_TYPE_HALTED;
1994 0 : FD_LOG_INFO(( "progress: halted" ));
1995 0 : break;
1996 0 : case 10: {
1997 0 : gui->summary.startup_progress.phase = FD_GUI_START_PROGRESS_TYPE_WAITING_FOR_SUPERMAJORITY;
1998 0 : gui->summary.startup_progress.startup_waiting_for_supermajority_slot = fd_ulong_load_8( msg + 1 );
1999 0 : gui->summary.startup_progress.startup_waiting_for_supermajority_stake_pct = fd_ulong_load_8( msg + 9 );
2000 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 ));
2001 0 : break;
2002 0 : }
2003 0 : case 11:
2004 0 : gui->summary.startup_progress.phase = FD_GUI_START_PROGRESS_TYPE_RUNNING;
2005 0 : FD_LOG_INFO(( "progress: running" ));
2006 0 : break;
2007 0 : default:
2008 0 : FD_LOG_ERR(( "progress: unknown type: %u", type ));
2009 0 : }
2010 :
2011 0 : fd_gui_printf_startup_progress( gui );
2012 0 : fd_http_server_ws_broadcast( gui->http );
2013 0 : }
2014 :
2015 : static void
2016 : fd_gui_handle_genesis_hash( fd_gui_t * gui,
2017 0 : uchar const * msg ) {
2018 0 : FD_BASE58_ENCODE_32_BYTES(msg, hash_cstr);
2019 0 : ulong cluster = fd_genesis_cluster_identify(hash_cstr);
2020 0 : char const * cluster_name = fd_genesis_cluster_name(cluster);
2021 :
2022 0 : if( FD_LIKELY( strcmp( gui->summary.cluster, cluster_name ) ) ) {
2023 0 : gui->summary.cluster = fd_genesis_cluster_name(cluster);
2024 0 : fd_gui_printf_cluster( gui );
2025 0 : fd_http_server_ws_broadcast( gui->http );
2026 0 : }
2027 0 : }
2028 :
2029 : static void
2030 : fd_gui_handle_block_engine_update( fd_gui_t * gui,
2031 0 : uchar const * msg ) {
2032 0 : fd_plugin_msg_block_engine_update_t const * update = (fd_plugin_msg_block_engine_update_t const *)msg;
2033 :
2034 0 : gui->block_engine.has_block_engine = 1;
2035 0 : memcpy( gui->block_engine.name, update->name, sizeof(gui->block_engine.name )-1 );
2036 0 : memcpy( gui->block_engine.url, update->url, sizeof(gui->block_engine.url )-1 );
2037 0 : memcpy( gui->block_engine.ip_cstr, update->ip_cstr, sizeof(gui->block_engine.ip_cstr)-1 );
2038 0 : gui->block_engine.status = update->status;
2039 :
2040 0 : fd_gui_printf_block_engine( gui );
2041 0 : fd_http_server_ws_broadcast( gui->http );
2042 0 : }
2043 :
2044 : void
2045 : fd_gui_handle_snapshot_update( fd_gui_t * gui,
2046 0 : fd_snaprd_update_t const * msg ) {
2047 0 : FD_TEST( msg && fd_cstr_nlen( msg->read_path, 1 ) );
2048 :
2049 0 : ulong snapshot_idx = fd_ulong_if( msg->type==FD_SNAPRD_SNAPSHOT_TYPE_FULL, FD_GUI_BOOT_PROGRESS_FULL_SNAPSHOT_IDX, FD_GUI_BOOT_PROGRESS_INCREMENTAL_SNAPSHOT_IDX );
2050 :
2051 0 : char const * filename = strrchr(msg->read_path, '/');
2052 :
2053 : /* Skip the '/' */
2054 0 : if( FD_UNLIKELY( filename ) ) filename++;
2055 :
2056 0 : if (msg->type == FD_SNAPRD_SNAPSHOT_TYPE_INCREMENTAL) {
2057 0 : ulong slot1, slot2;
2058 0 : if ( FD_LIKELY( sscanf( filename, "incremental-snapshot-%lu-%lu-", &slot1, &slot2 ) ) ) gui->summary.boot_progress.loading_snapshot[ snapshot_idx ].slot = slot2;
2059 0 : else FD_LOG_ERR(("failed to scan filename: %s parsed from %s", filename, msg->read_path ));
2060 0 : } else if (msg->type == FD_SNAPRD_SNAPSHOT_TYPE_FULL) {
2061 0 : ulong slot1;
2062 0 : if ( FD_LIKELY( sscanf( filename, "snapshot-%lu-", &slot1 ) ) ) gui->summary.boot_progress.loading_snapshot[ snapshot_idx ].slot = slot1;
2063 0 : else FD_LOG_ERR(("failed to scan filename: %s parsed from %s", filename, msg->read_path ));
2064 0 : }
2065 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 );
2066 0 : }
2067 :
2068 : static void
2069 0 : fd_gui_handle_reset_slot( fd_gui_t * gui, ulong reset_slot, long now ) {
2070 0 : FD_TEST( reset_slot!=ULONG_MAX );
2071 :
2072 0 : ulong prev_slot_completed = gui->summary.slot_completed;
2073 0 : gui->summary.slot_completed = reset_slot;
2074 :
2075 0 : fd_gui_printf_completed_slot( gui );
2076 0 : fd_http_server_ws_broadcast( gui->http );
2077 :
2078 : /* Also update slot_turbine which could be larger than the max
2079 : turbine slot if we are leader */
2080 0 : if( FD_UNLIKELY( gui->summary.slots_max_turbine[ 0 ].slot!=ULONG_MAX && gui->summary.slot_completed > gui->summary.slots_max_turbine[ 0 ].slot ) ) {
2081 0 : fd_gui_try_insert_ephemeral_slot( gui->summary.slots_max_turbine, FD_GUI_TURBINE_SLOT_HISTORY_SZ, gui->summary.slot_completed, now );
2082 0 : }
2083 :
2084 0 : int slot_turbine_hist_full = gui->summary.slots_max_turbine[ FD_GUI_TURBINE_SLOT_HISTORY_SZ-1UL ].slot!=ULONG_MAX;
2085 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) ) ) {
2086 0 : gui->summary.slot_caught_up = gui->summary.slot_completed + 4UL;
2087 :
2088 0 : fd_gui_printf_slot_caught_up( gui );
2089 0 : fd_http_server_ws_broadcast( gui->http );
2090 0 : }
2091 :
2092 : /* fork switch */
2093 0 : int republish_skip_rate[ 2 ] = {0};
2094 0 : if( FD_UNLIKELY( !fd_gui_slot_is_ancestor( gui, prev_slot_completed, reset_slot ) ) ) {
2095 : /* The handling for skipped slot on a fork switch is tricky. We
2096 : want to make sure we correctly count any skipped slots that
2097 : appear on the new fork, and also rebate back any slots that were
2098 : skipped but are no longer. We also need to make sure we count
2099 : skipped slots towards the correct epoch. */
2100 0 : for( ulong i=fd_ulong_max( gui->summary.slot_completed, prev_slot_completed); i>gui->summary.slot_rooted; i-- ) {
2101 0 : fd_gui_slot_t * old_root = fd_gui_get_root_slot( gui, prev_slot_completed );
2102 0 : fd_gui_slot_t * new_root = fd_gui_get_root_slot( gui, gui->summary.slot_completed );
2103 0 : if( FD_UNLIKELY( !old_root || !new_root ) ) break; /* at startup we may not have parent slots */
2104 :
2105 0 : int is_skipped_on_old_fork = i<=prev_slot_completed && fd_gui_is_skipped_on_fork( gui, old_root->slot, prev_slot_completed, i );
2106 0 : int is_skipped_on_new_fork = i<=gui->summary.slot_completed && fd_gui_is_skipped_on_fork( gui, new_root->slot, gui->summary.slot_completed, i );
2107 :
2108 0 : fd_gui_slot_t * skipped = fd_gui_get_slot( gui, i );
2109 0 : if( FD_LIKELY( is_skipped_on_old_fork && !is_skipped_on_new_fork ) ) {
2110 0 : if( FD_LIKELY( !skipped ) ) {
2111 0 : fd_gui_slot_t * p = fd_gui_get_parent_slot_on_fork( gui, prev_slot_completed, i );
2112 0 : skipped = fd_gui_clear_slot( gui, i, p ? p->slot : ULONG_MAX );
2113 0 : }
2114 :
2115 0 : skipped->skipped = 0;
2116 0 : fd_gui_printf_slot( gui, skipped->slot );
2117 0 : fd_http_server_ws_broadcast( gui->http );
2118 0 : skipped->must_republish = 0;
2119 :
2120 0 : if( FD_LIKELY( skipped->mine ) ) {
2121 0 : for( ulong i=0UL; i<2UL; i++ ) {
2122 0 : if( FD_LIKELY( i>=gui->epoch.epochs[ i ].start_slot && i<=gui->epoch.epochs[ i ].end_slot ) ) {
2123 0 : gui->epoch.epochs[ i ].my_skipped_slots--;
2124 0 : republish_skip_rate[ i ] = 1;
2125 0 : break;
2126 0 : }
2127 0 : }
2128 0 : }
2129 0 : }
2130 0 : if( FD_UNLIKELY( !is_skipped_on_old_fork && is_skipped_on_new_fork ) ) {
2131 0 : if( FD_LIKELY( !skipped ) ) {
2132 0 : fd_gui_slot_t * p = fd_gui_get_parent_slot_on_fork( gui, gui->summary.slot_completed, i );
2133 0 : skipped = fd_gui_clear_slot( gui, i, p ? p->slot : ULONG_MAX );
2134 0 : }
2135 :
2136 0 : skipped->skipped = 1;
2137 0 : fd_gui_printf_slot( gui, skipped->slot );
2138 0 : fd_http_server_ws_broadcast( gui->http );
2139 0 : skipped->must_republish = 0;
2140 :
2141 0 : if( FD_LIKELY( skipped->mine ) ) {
2142 0 : for( ulong i=0UL; i<2UL; i++ ) {
2143 0 : if( FD_LIKELY( i>=gui->epoch.epochs[ i ].start_slot && i<=gui->epoch.epochs[ i ].end_slot ) ) {
2144 0 : gui->epoch.epochs[ i ].my_skipped_slots++;
2145 0 : republish_skip_rate[ i ] = 1;
2146 0 : break;
2147 0 : }
2148 0 : }
2149 0 : }
2150 0 : }
2151 0 : }
2152 0 : } else {
2153 : /* not a fork switch, all skipped slots are new */
2154 0 : for( ulong i=prev_slot_completed+1; i<gui->summary.slot_completed; i++ ) {
2155 0 : fd_gui_slot_t * skipped = fd_gui_get_slot( gui, i );
2156 0 : if( FD_LIKELY( !skipped ) ) {
2157 0 : fd_gui_slot_t * p = fd_gui_get_parent_slot_on_fork( gui, gui->summary.slot_completed, i );
2158 0 : skipped = fd_gui_clear_slot( gui, i, p ? p->slot : ULONG_MAX );
2159 0 : }
2160 0 : skipped->skipped = 1;
2161 0 : fd_gui_printf_slot( gui, skipped->slot );
2162 0 : fd_http_server_ws_broadcast( gui->http );
2163 0 : skipped->must_republish = 0;
2164 0 : if( FD_LIKELY( skipped->mine ) ) {
2165 0 : for( ulong i=0UL; i<2UL; i++ ) {
2166 0 : if( FD_LIKELY( i>=gui->epoch.epochs[ i ].start_slot && i<=gui->epoch.epochs[ i ].end_slot ) ) {
2167 0 : gui->epoch.epochs[ i ].my_skipped_slots++;
2168 0 : republish_skip_rate[ i ] = 1;
2169 0 : break;
2170 0 : }
2171 0 : }
2172 0 : }
2173 0 : }
2174 0 : }
2175 :
2176 0 : for( ulong i=0UL; i<2UL; i++ ) {
2177 0 : if( FD_LIKELY( republish_skip_rate[ i ] ) ) {
2178 0 : fd_gui_printf_skip_rate( gui, i );
2179 0 : fd_http_server_ws_broadcast( gui->http );
2180 0 : }
2181 0 : }
2182 0 : }
2183 :
2184 : static void
2185 0 : fd_gui_handle_rooted_slot( fd_gui_t * gui, ulong root_slot ) {
2186 : // ulong unstaged_cnt = 0UL;
2187 0 : for( ulong i=0UL; i<fd_ulong_min( root_slot, FD_GUI_SLOTS_CNT ); i++ ) {
2188 0 : ulong parent_slot = root_slot - i;
2189 :
2190 0 : fd_gui_slot_t * slot = fd_gui_get_slot( gui, parent_slot );
2191 0 : if( FD_UNLIKELY( !slot ) ) break;
2192 :
2193 0 : if( FD_UNLIKELY( slot->slot!=parent_slot ) ) {
2194 0 : FD_LOG_ERR(( "_slot %lu i %lu we expect parent_slot %lu got slot->slot %lu", root_slot, i, parent_slot, slot->slot ));
2195 0 : }
2196 0 : if( FD_UNLIKELY( slot->level>=FD_GUI_SLOT_LEVEL_ROOTED ) ) break;
2197 :
2198 : /* TODO: commented out due to being too slow */
2199 : // /* archive root shred events */
2200 : // slot->shreds.start_offset = gui->shreds.history_tail;
2201 : // for( ulong i=gui->shreds.staged_head; i<gui->shreds.staged_tail; i++ ) {
2202 : // if( FD_UNLIKELY( gui->shreds.staged[ i ].slot==slot->slot ) ) {
2203 : // /* move event to history */
2204 : // gui->shreds.history[ gui->shreds.history_tail ].timestamp = gui->shreds.staged[ i ].timestamp;
2205 : // gui->shreds.history[ gui->shreds.history_tail ].shred_idx = gui->shreds.staged[ i ].shred_idx;
2206 : // gui->shreds.history[ gui->shreds.history_tail ].event = gui->shreds.staged[ i ].event;
2207 : // gui->shreds.history_tail++;
2208 :
2209 : // gui->shreds.staged[ i ].slot = ULONG_MAX;
2210 : // unstaged_cnt++;
2211 : // }
2212 :
2213 : // /* evict older slots staged also */
2214 : // if( FD_UNLIKELY( gui->shreds.staged[ i ].slot<slot->slot ) ) {
2215 : // gui->shreds.staged[ i ].slot = ULONG_MAX;
2216 : // unstaged_cnt++;
2217 : // }
2218 : // }
2219 : // slot->shreds.end_offset = gui->shreds.history_tail;
2220 :
2221 : // /* change notarization levels and rebroadcast */
2222 : // slot->level = FD_GUI_SLOT_LEVEL_ROOTED;
2223 : // fd_gui_printf_slot( gui, parent_slot );
2224 : // fd_http_server_ws_broadcast( gui->http );
2225 0 : }
2226 :
2227 : /* The entries from the staging area are evicted by setting their
2228 : slot field to ULONG MAX, then sorting the staging area.
2229 :
2230 : IMPORTANT: this sort needs to be stable since we always keep
2231 : valid un-broadcast events at the end of the ring buffer */
2232 : // if( FD_LIKELY( unstaged_cnt ) ) {
2233 : // fd_gui_slot_staged_shred_event_sort_insert( &gui->shreds.staged[ gui->shreds.staged_head ], gui->shreds.staged_tail-gui->shreds.staged_head );
2234 : // gui->shreds.staged_head += unstaged_cnt;
2235 : // }
2236 :
2237 : // /* In the rare case that we are archiving any shred events that have
2238 : // not yet been broadcast, we'll increment
2239 : // gui->shreds.staged_next_broadcast to keep it in bounds. */
2240 : // gui->shreds.staged_next_broadcast = fd_ulong_max( gui->shreds.staged_head, gui->shreds.staged_next_broadcast );
2241 :
2242 0 : gui->summary.slot_rooted = root_slot;
2243 0 : fd_gui_printf_root_slot( gui );
2244 0 : fd_http_server_ws_broadcast( gui->http );
2245 0 : }
2246 :
2247 : /* fd_gui_handle_tower_update handles updates from the tower tile, which
2248 : manages consensus related fork switching, rooting, slot confirmation. */
2249 : void
2250 : fd_gui_handle_tower_update( fd_gui_t * gui,
2251 : fd_tower_slot_done_t const * tower,
2252 0 : long now ) {
2253 0 : (void)now;
2254 :
2255 : /* slot completed */
2256 0 : if( FD_UNLIKELY( gui->summary.slot_completed!=tower->reset_slot ) ) {
2257 0 : fd_gui_handle_reset_slot( gui, tower->reset_slot, now );
2258 0 : }
2259 :
2260 : /* handle new root */
2261 0 : if( FD_LIKELY( tower->new_root && gui->summary.slot_rooted!=tower->root_slot ) ) {
2262 0 : fd_gui_handle_rooted_slot( gui, tower->root_slot );
2263 0 : }
2264 :
2265 0 : if( FD_UNLIKELY( gui->summary.vote_distance!=tower->reset_slot-tower->vote_slot ) ) {
2266 0 : gui->summary.vote_distance = tower->reset_slot-tower->vote_slot;
2267 0 : fd_gui_printf_vote_distance( gui );
2268 0 : fd_http_server_ws_broadcast( gui->http );
2269 0 : }
2270 :
2271 0 : if( FD_LIKELY( gui->summary.vote_state!=FD_GUI_VOTE_STATE_NON_VOTING ) ) {
2272 0 : if( FD_UNLIKELY( tower->vote_slot==ULONG_MAX || (tower->vote_slot+150UL)<tower->reset_slot ) ) {
2273 0 : if( FD_UNLIKELY( gui->summary.vote_state!=FD_GUI_VOTE_STATE_DELINQUENT ) ) {
2274 0 : gui->summary.vote_state = FD_GUI_VOTE_STATE_DELINQUENT;
2275 0 : fd_gui_printf_vote_state( gui );
2276 0 : fd_http_server_ws_broadcast( gui->http );
2277 0 : }
2278 0 : } else {
2279 0 : if( FD_UNLIKELY( gui->summary.vote_state!=FD_GUI_VOTE_STATE_VOTING ) ) {
2280 0 : gui->summary.vote_state = FD_GUI_VOTE_STATE_VOTING;
2281 0 : fd_gui_printf_vote_state( gui );
2282 0 : fd_http_server_ws_broadcast( gui->http );
2283 0 : }
2284 0 : }
2285 0 : }
2286 :
2287 : /* todo ... optimistic confirmation, waiting on fd_ghost / fd_notar */
2288 0 : }
2289 :
2290 : void
2291 : fd_gui_handle_replay_update( fd_gui_t * gui,
2292 : fd_replay_slot_completed_t const * replay,
2293 0 : long now ) {
2294 0 : (void)now;
2295 :
2296 0 : fd_gui_slot_t * slot = fd_gui_get_slot( gui, replay->slot );
2297 0 : if( FD_UNLIKELY( slot ) ) {
2298 : /* Its possible that this slot was labeled as skipped by another
2299 : consensus fork at some point in the past. In this case no need to
2300 : clear it. */
2301 0 : } else {
2302 0 : slot = fd_gui_clear_slot( gui, replay->slot, replay->parent_slot );
2303 0 : }
2304 :
2305 0 : slot->slot = replay->slot;
2306 0 : slot->completed_time = replay->completion_time_nanos;
2307 0 : slot->parent_slot = replay->parent_slot;
2308 0 : slot->max_compute_units = (uint)replay->max_compute_units;
2309 0 : if( FD_LIKELY( slot->level<FD_GUI_SLOT_LEVEL_COMPLETED ) ) {
2310 : /* Typically a slot goes from INCOMPLETE to COMPLETED but it can
2311 : happen that it starts higher. One such case is when we
2312 : optimistically confirm a higher slot that skips this one, but
2313 : then later we replay this one anyway to track the bank fork. */
2314 :
2315 0 : if( FD_LIKELY( gui->summary.slot_optimistically_confirmed!=ULONG_MAX && replay->slot<gui->summary.slot_optimistically_confirmed ) ) {
2316 : /* Cluster might have already optimistically confirmed by the time
2317 : we finish replaying it. */
2318 0 : slot->level = FD_GUI_SLOT_LEVEL_OPTIMISTICALLY_CONFIRMED;
2319 0 : } else {
2320 0 : slot->level = FD_GUI_SLOT_LEVEL_COMPLETED;
2321 0 : }
2322 0 : }
2323 0 : slot->total_txn_cnt = (uint)replay->transaction_count;
2324 0 : slot->vote_txn_cnt = (uint)(replay->transaction_count - replay->nonvote_txn_count);
2325 0 : slot->failed_txn_cnt = (uint)replay->failed_txn_count;
2326 0 : slot->nonvote_failed_txn_cnt = (uint)replay->nonvote_failed_txn_count;
2327 0 : slot->transaction_fee = replay->execution_fees;
2328 0 : slot->priority_fee = replay->priority_fees;
2329 0 : slot->tips = replay->tips;
2330 0 : slot->compute_units = (uint)replay->total_compute_units_used;
2331 :
2332 0 : if( FD_UNLIKELY( gui->epoch.has_epoch[ 0 ] && replay->slot==gui->epoch.epochs[ 0 ].end_slot ) ) {
2333 0 : gui->epoch.epochs[ 0 ].end_time = slot->completed_time;
2334 0 : } else if( FD_UNLIKELY( gui->epoch.has_epoch[ 1 ] && replay->slot==gui->epoch.epochs[ 1 ].end_slot ) ) {
2335 0 : gui->epoch.epochs[ 1 ].end_time = slot->completed_time;
2336 0 : }
2337 :
2338 : /* Broadcast new skip rate if one of our slots got completed. */
2339 0 : if( FD_LIKELY( slot->mine ) ) {
2340 0 : for( ulong i=0UL; i<2UL; i++ ) {
2341 0 : if( FD_LIKELY( replay->slot>=gui->epoch.epochs[ i ].start_slot && replay->slot<=gui->epoch.epochs[ i ].end_slot ) ) {
2342 0 : fd_gui_printf_skip_rate( gui, i );
2343 0 : fd_http_server_ws_broadcast( gui->http );
2344 0 : break;
2345 0 : }
2346 0 : }
2347 0 : }
2348 0 : }
2349 :
2350 : void
2351 : fd_gui_plugin_message( fd_gui_t * gui,
2352 : ulong plugin_msg,
2353 : uchar const * msg,
2354 0 : long now ) {
2355 :
2356 0 : switch( plugin_msg ) {
2357 0 : case FD_PLUGIN_MSG_SLOT_ROOTED:
2358 0 : fd_gui_handle_rooted_slot_legacy( gui, (ulong *)msg );
2359 0 : break;
2360 0 : case FD_PLUGIN_MSG_SLOT_OPTIMISTICALLY_CONFIRMED:
2361 0 : fd_gui_handle_optimistically_confirmed_slot( gui, (ulong *)msg );
2362 0 : break;
2363 0 : case FD_PLUGIN_MSG_SLOT_COMPLETED: {
2364 0 : fd_gui_handle_completed_slot( gui, (ulong *)msg, now );
2365 0 : break;
2366 0 : }
2367 0 : case FD_PLUGIN_MSG_LEADER_SCHEDULE: {
2368 0 : fd_gui_handle_leader_schedule( gui, (ulong const *)msg, now );
2369 0 : break;
2370 0 : }
2371 0 : case FD_PLUGIN_MSG_SLOT_START: {
2372 0 : fd_gui_handle_slot_start( gui, (ulong *)msg, now );
2373 0 : break;
2374 0 : }
2375 0 : case FD_PLUGIN_MSG_SLOT_END: {
2376 0 : fd_gui_handle_slot_end( gui, (ulong *)msg, now );
2377 0 : break;
2378 0 : }
2379 0 : case FD_PLUGIN_MSG_GOSSIP_UPDATE: {
2380 0 : fd_gui_handle_gossip_update( gui, msg );
2381 0 : break;
2382 0 : }
2383 0 : case FD_PLUGIN_MSG_VOTE_ACCOUNT_UPDATE: {
2384 0 : fd_gui_handle_vote_account_update( gui, msg );
2385 0 : break;
2386 0 : }
2387 0 : case FD_PLUGIN_MSG_VALIDATOR_INFO: {
2388 0 : fd_gui_handle_validator_info_update( gui, msg );
2389 0 : break;
2390 0 : }
2391 0 : case FD_PLUGIN_MSG_SLOT_RESET: {
2392 0 : fd_gui_handle_reset_slot_legacy( gui, (ulong *)msg, now );
2393 0 : break;
2394 0 : }
2395 0 : case FD_PLUGIN_MSG_BALANCE: {
2396 0 : fd_gui_handle_balance_update( gui, (ulong *)msg );
2397 0 : break;
2398 0 : }
2399 0 : case FD_PLUGIN_MSG_START_PROGRESS: {
2400 0 : fd_gui_handle_start_progress( gui, msg );
2401 0 : break;
2402 0 : }
2403 0 : case FD_PLUGIN_MSG_GENESIS_HASH_KNOWN: {
2404 0 : fd_gui_handle_genesis_hash( gui, msg );
2405 0 : break;
2406 0 : }
2407 0 : case FD_PLUGIN_MSG_BLOCK_ENGINE_UPDATE: {
2408 0 : fd_gui_handle_block_engine_update( gui, msg );
2409 0 : break;
2410 0 : }
2411 0 : default:
2412 0 : FD_LOG_ERR(( "Unhandled plugin msg: 0x%lx", plugin_msg ));
2413 0 : break;
2414 0 : }
2415 0 : }
2416 :
2417 : void
2418 : fd_gui_became_leader( fd_gui_t * gui,
2419 : ulong _slot,
2420 : long start_time_nanos,
2421 : long end_time_nanos,
2422 : ulong max_compute_units,
2423 0 : ulong max_microblocks ) {
2424 0 : fd_gui_slot_t * slot = fd_gui_get_slot( gui, _slot );
2425 0 : if( FD_UNLIKELY( !slot ) ) slot = fd_gui_clear_slot( gui, _slot, ULONG_MAX );
2426 0 : fd_gui_leader_slot_t * lslot = fd_gui_get_leader_slot( gui, _slot );
2427 0 : if( FD_UNLIKELY( !lslot ) ) return;
2428 :
2429 0 : slot->max_compute_units = (uint)max_compute_units;
2430 0 : lslot->leader_start_time = start_time_nanos;
2431 0 : lslot->leader_end_time = end_time_nanos;
2432 0 : if( FD_LIKELY( lslot->txs.microblocks_upper_bound==USHORT_MAX ) ) lslot->txs.microblocks_upper_bound = (ushort)max_microblocks;
2433 0 : }
2434 :
2435 : void
2436 : fd_gui_unbecame_leader( fd_gui_t * gui,
2437 : ulong _slot,
2438 0 : ulong microblocks_in_slot ) {
2439 0 : fd_gui_slot_t * slot = fd_gui_get_slot( gui, _slot );
2440 0 : if( FD_UNLIKELY( !slot ) ) slot = fd_gui_clear_slot( gui, _slot, ULONG_MAX );
2441 0 : fd_gui_leader_slot_t * lslot = fd_gui_get_leader_slot( gui, _slot );
2442 0 : if( FD_LIKELY( !lslot ) ) return;
2443 0 : lslot->txs.microblocks_upper_bound = (ushort)microblocks_in_slot;
2444 0 : }
2445 :
2446 : void
2447 : fd_gui_microblock_execution_begin( fd_gui_t * gui,
2448 : long now,
2449 : ulong _slot,
2450 : fd_txn_p_t * txns,
2451 : ulong txn_cnt,
2452 : uint microblock_idx,
2453 0 : ulong pack_txn_idx ) {
2454 0 : fd_gui_slot_t * slot = fd_gui_get_slot( gui, _slot );
2455 0 : if( FD_UNLIKELY( !slot ) ) slot = fd_gui_clear_slot( gui, _slot, ULONG_MAX );
2456 :
2457 0 : fd_gui_leader_slot_t * lslot = fd_gui_get_leader_slot( gui, _slot );
2458 0 : if( FD_UNLIKELY( !lslot ) ) return;
2459 :
2460 0 : if( FD_UNLIKELY( lslot->txs.start_offset==ULONG_MAX ) ) lslot->txs.start_offset = pack_txn_idx;
2461 0 : else lslot->txs.start_offset = fd_ulong_min( lslot->txs.start_offset, pack_txn_idx );
2462 :
2463 0 : gui->pack_txn_idx = fd_ulong_max( gui->pack_txn_idx, pack_txn_idx+txn_cnt-1UL );
2464 :
2465 0 : for( ulong i=0UL; i<txn_cnt; i++ ) {
2466 0 : fd_txn_p_t * txn_payload = &txns[ i ];
2467 0 : fd_txn_t * txn = TXN( txn_payload );
2468 :
2469 0 : ulong sig_rewards = FD_PACK_FEE_PER_SIGNATURE * txn->signature_cnt;
2470 0 : ulong priority_rewards = ULONG_MAX;
2471 0 : ulong requested_execution_cus = ULONG_MAX;
2472 0 : ulong precompile_sigs = ULONG_MAX;
2473 0 : ulong requested_loaded_accounts_data_cost = ULONG_MAX;
2474 0 : uint _flags;
2475 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 );
2476 0 : sig_rewards += FD_PACK_FEE_PER_SIGNATURE * precompile_sigs;
2477 0 : sig_rewards = sig_rewards * FD_PACK_TXN_FEE_BURN_PCT / 100UL;
2478 :
2479 0 : fd_gui_txn_t * txn_entry = gui->txs[ (pack_txn_idx + i)%FD_GUI_TXN_HISTORY_SZ ];
2480 0 : fd_memcpy(txn_entry->signature, txn_payload->payload + txn->signature_off, FD_SHA512_HASH_SZ);
2481 0 : txn_entry->timestamp_arrival_nanos = txn_payload->scheduler_arrival_time_nanos;
2482 0 : txn_entry->compute_units_requested = cost_estimate & 0x1FFFFFU;
2483 0 : txn_entry->priority_fee = priority_rewards;
2484 0 : txn_entry->transaction_fee = sig_rewards;
2485 0 : txn_entry->timestamp_delta_start_nanos = (int)(now - lslot->leader_start_time);
2486 0 : txn_entry->source_ipv4 = txn_payload->source_ipv4;
2487 0 : txn_entry->source_tpu = txn_payload->source_tpu;
2488 0 : txn_entry->microblock_idx = microblock_idx;
2489 0 : txn_entry->flags |= (uchar)FD_GUI_TXN_FLAGS_STARTED;
2490 0 : txn_entry->flags &= (uchar)(~(uchar)(FD_GUI_TXN_FLAGS_IS_SIMPLE_VOTE | FD_GUI_TXN_FLAGS_FROM_BUNDLE));
2491 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);
2492 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);
2493 0 : }
2494 :
2495 : /* At the moment, bank publishes at most 1 transaction per microblock,
2496 : even if it received microblocks with multiple transactions
2497 : (i.e. a bundle). This means that we need to calculate microblock
2498 : count here based on the transaction count. */
2499 0 : lslot->txs.begin_microblocks = (ushort)(lslot->txs.begin_microblocks + txn_cnt);
2500 0 : }
2501 :
2502 : void
2503 : fd_gui_microblock_execution_end( fd_gui_t * gui,
2504 : long now,
2505 : ulong bank_idx,
2506 : ulong _slot,
2507 : ulong txn_cnt,
2508 : fd_txn_p_t * txns,
2509 : ulong pack_txn_idx,
2510 : uchar txn_start_pct,
2511 : uchar txn_load_end_pct,
2512 : uchar txn_end_pct,
2513 : uchar txn_preload_end_pct,
2514 0 : ulong tips ) {
2515 0 : if( FD_UNLIKELY( 1UL!=txn_cnt ) ) FD_LOG_ERR(( "gui expects 1 txn per microblock from bank, found %lu", txn_cnt ));
2516 :
2517 0 : fd_gui_slot_t * slot = fd_gui_get_slot( gui, _slot );
2518 0 : if( FD_UNLIKELY( !slot ) ) slot = fd_gui_clear_slot( gui, _slot, ULONG_MAX );
2519 :
2520 0 : fd_gui_leader_slot_t * lslot = fd_gui_get_leader_slot( gui, _slot );
2521 0 : if( FD_UNLIKELY( !lslot ) ) return;
2522 :
2523 0 : if( FD_UNLIKELY( lslot->txs.end_offset==ULONG_MAX ) ) lslot->txs.end_offset = pack_txn_idx + txn_cnt;
2524 0 : else lslot->txs.end_offset = fd_ulong_max( lslot->txs.end_offset, pack_txn_idx+txn_cnt );
2525 :
2526 0 : gui->pack_txn_idx = fd_ulong_max( gui->pack_txn_idx, pack_txn_idx+txn_cnt-1UL );
2527 :
2528 0 : for( ulong i=0UL; i<txn_cnt; i++ ) {
2529 0 : fd_txn_p_t * txn_p = &txns[ i ];
2530 :
2531 0 : fd_gui_txn_t * txn_entry = gui->txs[ (pack_txn_idx + i)%FD_GUI_TXN_HISTORY_SZ ];
2532 0 : txn_entry->bank_idx = bank_idx & 0x3FU;
2533 0 : txn_entry->compute_units_consumed = txn_p->bank_cu.actual_consumed_cus & 0x1FFFFFU;
2534 0 : txn_entry->error_code = (txn_p->flags >> 24) & 0x3FU;
2535 0 : txn_entry->timestamp_delta_end_nanos = (int)(now - lslot->leader_start_time);
2536 0 : txn_entry->txn_start_pct = txn_start_pct;
2537 0 : txn_entry->txn_load_end_pct = txn_load_end_pct;
2538 0 : txn_entry->txn_end_pct = txn_end_pct;
2539 0 : txn_entry->txn_preload_end_pct = txn_preload_end_pct;
2540 0 : txn_entry->tips = tips;
2541 0 : txn_entry->flags |= (uchar)FD_GUI_TXN_FLAGS_ENDED;
2542 0 : txn_entry->flags &= (uchar)(~(uchar)FD_GUI_TXN_FLAGS_LANDED_IN_BLOCK);
2543 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);
2544 0 : }
2545 :
2546 0 : lslot->txs.end_microblocks = lslot->txs.end_microblocks + (uint)txn_cnt;
2547 0 : }
|