Skip to content

Commit e4827eb

Browse files
committed
gui: leader schedule + peer vote info
1 parent 054f398 commit e4827eb

File tree

13 files changed

+463
-99
lines changed

13 files changed

+463
-99
lines changed

book/api/websocket.md

Lines changed: 36 additions & 34 deletions
Large diffs are not rendered by default.

src/app/firedancer/topology.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ fd_topo_initialize( config_t * config ) {
256256

257257
fd_topob_wksp( topo, "shred_out" );
258258
fd_topob_wksp( topo, "replay_stake" );
259+
fd_topob_wksp( topo, "replay_votes" );
259260
fd_topob_wksp( topo, "replay_exec" );
260261
fd_topob_wksp( topo, "replay_out" );
261262
fd_topob_wksp( topo, "tower_out" );
@@ -343,6 +344,9 @@ fd_topo_initialize( config_t * config ) {
343344
/**/ fd_topob_link( topo, "dedup_resolv", "dedup_resolv", 65536UL, FD_TPU_PARSED_MTU, 1UL );
344345
FOR(resolv_tile_cnt) fd_topob_link( topo, "resolv_pack", "resolv_pack", 65536UL, FD_TPU_RESOLVED_MTU, 1UL );
345346
/**/ fd_topob_link( topo, "replay_stake", "replay_stake", 128UL, FD_STAKE_OUT_MTU, 1UL ); /* TODO: This should be 2 but requires fixing STEM_BURST */
347+
if( FD_LIKELY( config->tiles.gui.enabled ) ) { /* the gui, which is optional, is the only consumer of replay_votes */
348+
fd_topob_link( topo, "replay_votes", "replay_votes", 128UL, sizeof(fd_replay_votes_t), 1UL );
349+
}
346350
/**/ fd_topob_link( topo, "replay_out", "replay_out", 8192UL, sizeof(fd_replay_message_t), 1UL );
347351
/**/ fd_topob_link( topo, "pack_poh", "pack_poh", 128UL, sizeof(fd_done_packing_t), 1UL );
348352
/* pack_bank is shared across all banks, so if one bank stalls due to complex transactions, the buffer neeeds to be large so that
@@ -500,6 +504,9 @@ fd_topo_initialize( config_t * config ) {
500504
/**/ fd_topob_tile_in ( topo, "replay", 0UL, "metric_in", "genesi_out", 0UL, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
501505
/**/ fd_topob_tile_out( topo, "replay", 0UL, "replay_out", 0UL );
502506
/**/ fd_topob_tile_out( topo, "replay", 0UL, "replay_stake", 0UL );
507+
if( FD_LIKELY( config->tiles.gui.enabled ) ) { /* the gui, which is optional, is the only consumer of replay_votes */
508+
fd_topob_tile_out( topo, "replay", 0UL, "replay_votes", 0UL );
509+
}
503510
/**/ fd_topob_tile_out( topo, "replay", 0UL, "executed_txn", 0UL );
504511
/**/ fd_topob_tile_out( topo, "replay", 0UL, "replay_exec", 0UL );
505512
/**/ fd_topob_tile_in ( topo, "replay", 0UL, "metric_in", "tower_out", 0UL, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
@@ -652,6 +659,8 @@ fd_topo_initialize( config_t * config ) {
652659
/**/ fd_topob_tile_in( topo, "gui", 0UL, "metric_in", "gossip_out", 0UL, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
653660
/**/ fd_topob_tile_in( topo, "gui", 0UL, "metric_in", "tower_out", 0UL, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
654661
/**/ fd_topob_tile_in( topo, "gui", 0UL, "metric_in", "replay_out", 0UL, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
662+
/**/ fd_topob_tile_in ( topo, "gui", 0UL, "metric_in", "replay_stake", 0UL, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
663+
/**/ fd_topob_tile_in ( topo, "gui", 0UL, "metric_in", "replay_votes", 0UL, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
655664

656665
if( FD_LIKELY( snapshots_enabled ) ) {
657666
fd_topob_tile_in ( topo, "gui", 0UL, "metric_in", "snaprd_out", 0UL, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );

src/disco/gui/fd_gui.c

Lines changed: 45 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,20 @@ fd_gui_ws_open( fd_gui_t * gui,
229229
FD_TEST( !fd_http_server_ws_send( gui->http, ws_conn_id ) );
230230
}
231231

232+
/* todo .. temporary workaround to skip the blur until frontend boot
233+
screen lands */
234+
if( FD_UNLIKELY( gui->summary.is_full_client ) ) {
235+
ulong real_mls = fd_ulong_if( gui->summary.catch_up_repair_sz>0UL, gui->summary.catch_up_repair[ 0 ], 0UL );
236+
uchar prev_phase = gui->summary.startup_progress.phase;
237+
ulong prev_mls = gui->summary.startup_progress.startup_ledger_max_slot;
238+
gui->summary.startup_progress.phase = FD_GUI_START_PROGRESS_TYPE_RUNNING;
239+
gui->summary.startup_progress.startup_ledger_max_slot = real_mls;
240+
fd_gui_printf_startup_progress( gui );
241+
FD_TEST( !fd_http_server_ws_send( gui->http, ws_conn_id ) );
242+
gui->summary.startup_progress.phase = prev_phase;
243+
gui->summary.startup_progress.startup_ledger_max_slot = prev_mls;
244+
}
245+
232246
if( FD_LIKELY( gui->block_engine.has_block_engine ) ) {
233247
fd_gui_printf_block_engine( gui );
234248
FD_TEST( !fd_http_server_ws_send( gui->http, ws_conn_id ) );
@@ -1353,55 +1367,48 @@ fd_gui_clear_slot( fd_gui_t * gui,
13531367
return slot;
13541368
}
13551369

1356-
static void
1357-
fd_gui_handle_leader_schedule( fd_gui_t * gui,
1358-
ulong const * msg,
1359-
long now ) {
1360-
ulong epoch = msg[ 0 ];
1361-
ulong staked_cnt = msg[ 1 ];
1362-
ulong start_slot = msg[ 2 ];
1363-
ulong slot_cnt = msg[ 3 ];
1364-
ulong excluded_stake = msg[ 4 ];
1365-
ulong vote_keyed_lsched = msg[ 5 ];
1366-
1367-
FD_TEST( staked_cnt<=MAX_STAKED_LEADERS );
1368-
FD_TEST( slot_cnt<=MAX_SLOTS_PER_EPOCH );
1369-
1370-
ulong idx = epoch % 2UL;
1370+
void
1371+
fd_gui_handle_leader_schedule( fd_gui_t * gui,
1372+
fd_stake_weight_msg_t const * leader_schedule,
1373+
long now ) {
1374+
FD_TEST( leader_schedule->staked_cnt<=MAX_STAKED_LEADERS );
1375+
FD_TEST( leader_schedule->slot_cnt<=MAX_SLOTS_PER_EPOCH );
1376+
1377+
ulong idx = leader_schedule->epoch % 2UL;
13711378
gui->epoch.has_epoch[ idx ] = 1;
13721379

1373-
gui->epoch.epochs[ idx ].epoch = epoch;
1374-
gui->epoch.epochs[ idx ].start_slot = start_slot;
1375-
gui->epoch.epochs[ idx ].end_slot = start_slot + slot_cnt - 1; // end_slot is inclusive.
1376-
gui->epoch.epochs[ idx ].excluded_stake = excluded_stake;
1380+
gui->epoch.epochs[ idx ].epoch = leader_schedule->epoch;
1381+
gui->epoch.epochs[ idx ].start_slot = leader_schedule->start_slot;
1382+
gui->epoch.epochs[ idx ].end_slot = leader_schedule->start_slot + leader_schedule->slot_cnt - 1; // end_slot is inclusive.
1383+
gui->epoch.epochs[ idx ].excluded_stake = leader_schedule->excluded_stake;
13771384
gui->epoch.epochs[ idx ].my_total_slots = 0UL;
13781385
gui->epoch.epochs[ idx ].my_skipped_slots = 0UL;
13791386

13801387
memset( gui->epoch.epochs[ idx ].rankings, (int)(UINT_MAX), sizeof(gui->epoch.epochs[ idx ].rankings) );
13811388
memset( gui->epoch.epochs[ idx ].my_rankings, (int)(UINT_MAX), sizeof(gui->epoch.epochs[ idx ].my_rankings) );
13821389

1383-
gui->epoch.epochs[ idx ].rankings_slot = start_slot;
1390+
gui->epoch.epochs[ idx ].rankings_slot = leader_schedule->start_slot;
13841391

1385-
fd_vote_stake_weight_t const * stake_weights = fd_type_pun_const( msg+6UL );
1386-
memcpy( gui->epoch.epochs[ idx ].stakes, stake_weights, staked_cnt*sizeof(fd_vote_stake_weight_t) );
1392+
fd_vote_stake_weight_t const * stake_weights = leader_schedule->weights;
1393+
fd_memcpy( gui->epoch.epochs[ idx ].stakes, stake_weights, leader_schedule->staked_cnt*sizeof(fd_vote_stake_weight_t) );
13871394

13881395
fd_epoch_leaders_delete( fd_epoch_leaders_leave( gui->epoch.epochs[ idx ].lsched ) );
13891396
gui->epoch.epochs[idx].lsched = fd_epoch_leaders_join( fd_epoch_leaders_new( gui->epoch.epochs[ idx ]._lsched,
1390-
epoch,
1397+
leader_schedule->epoch,
13911398
gui->epoch.epochs[ idx ].start_slot,
1392-
slot_cnt,
1393-
staked_cnt,
1399+
leader_schedule->slot_cnt,
1400+
leader_schedule->staked_cnt,
13941401
gui->epoch.epochs[ idx ].stakes,
1395-
excluded_stake,
1396-
vote_keyed_lsched ) );
1402+
leader_schedule->excluded_stake,
1403+
leader_schedule->vote_keyed_lsched ) );
13971404

1398-
if( FD_UNLIKELY( start_slot==0UL ) ) {
1405+
if( FD_UNLIKELY( leader_schedule->start_slot==0UL ) ) {
13991406
gui->epoch.epochs[ 0 ].start_time = now;
14001407
} else {
14011408
gui->epoch.epochs[ idx ].start_time = LONG_MAX;
14021409

1403-
for( ulong i=0UL; i<fd_ulong_min( start_slot-1UL, FD_GUI_SLOTS_CNT ); i++ ) {
1404-
fd_gui_slot_t const * slot = fd_gui_get_slot_const( gui, start_slot-i );
1410+
for( ulong i=0UL; i<fd_ulong_min( leader_schedule->start_slot-1UL, FD_GUI_SLOTS_CNT ); i++ ) {
1411+
fd_gui_slot_t const * slot = fd_gui_get_slot_const( gui, leader_schedule->start_slot-i );
14051412
if( FD_UNLIKELY( !slot ) ) break;
14061413
else if( FD_UNLIKELY( slot->skipped ) ) continue;
14071414

@@ -1829,8 +1836,7 @@ fd_gui_handle_rooted_slot_legacy( fd_gui_t * gui,
18291836
if( FD_UNLIKELY( !slot ) ) break;
18301837

18311838
if( FD_UNLIKELY( slot->slot!=parent_slot ) ) {
1832-
FD_LOG_ERR(( "_slot %lu i %lu we expect parent_slot %lu got slot->slot %lu", _slot, i, parent_slot, slot->slot ));
1833-
}
1839+
FD_LOG_ERR(( "_slot %lu i %lu we expect parent_slot %lu got slot->slot %lu", _slot, i, parent_slot, slot->slot )); }
18341840
if( FD_UNLIKELY( slot->level>=FD_GUI_SLOT_LEVEL_ROOTED ) ) break;
18351841

18361842
slot->level = FD_GUI_SLOT_LEVEL_ROOTED;
@@ -2072,6 +2078,11 @@ fd_gui_handle_reset_slot( fd_gui_t * gui, ulong reset_slot, long now ) {
20722078
ulong prev_slot_completed = gui->summary.slot_completed;
20732079
gui->summary.slot_completed = reset_slot;
20742080

2081+
if( FD_LIKELY( fd_gui_get_slot( gui, gui->summary.slot_completed ) ) ) {
2082+
fd_gui_printf_slot( gui, gui->summary.slot_completed );
2083+
fd_http_server_ws_broadcast( gui->http );
2084+
}
2085+
20752086
fd_gui_printf_completed_slot( gui );
20762087
fd_http_server_ws_broadcast( gui->http );
20772088

@@ -2364,7 +2375,8 @@ fd_gui_plugin_message( fd_gui_t * gui,
23642375
break;
23652376
}
23662377
case FD_PLUGIN_MSG_LEADER_SCHEDULE: {
2367-
fd_gui_handle_leader_schedule( gui, (ulong const *)msg, now );
2378+
FD_STATIC_ASSERT( sizeof(fd_stake_weight_msg_t)==6*sizeof(ulong), "sanity check" );
2379+
fd_gui_handle_leader_schedule( gui, (fd_stake_weight_msg_t *)msg, now );
23682380
break;
23692381
}
23702382
case FD_PLUGIN_MSG_SLOT_START: {

src/disco/gui/fd_gui.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,11 @@ void
840840
fd_gui_handle_snapshot_update( fd_gui_t * gui,
841841
fd_snaprd_update_t const * msg );
842842

843+
void
844+
fd_gui_handle_leader_schedule( fd_gui_t * gui,
845+
fd_stake_weight_msg_t const * leader_schedule,
846+
long now );
847+
843848
void
844849
fd_gui_handle_tower_update( fd_gui_t * gui,
845850
fd_tower_slot_done_t const * msg,

0 commit comments

Comments
 (0)