Skip to content

Commit 0b00ac2

Browse files
committed
gui, replay: fix gui startup, tps, validators card
1 parent 2536b3e commit 0b00ac2

File tree

1 file changed

+83
-45
lines changed

1 file changed

+83
-45
lines changed

src/discof/replay/fd_replay_tile.c

+83-45
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ struct fd_replay_tile_ctx {
291291
ulong * poh; /* proof-of-history slot */
292292
uint poh_init_done;
293293
int snapshot_init_done;
294+
int startup_init_done;
294295

295296
int tower_checkpt_fileno;
296297

@@ -1285,6 +1286,7 @@ publish_slot_notifications( fd_replay_tile_ctx_t * ctx,
12851286
FD_LOG_DEBUG(("TIMING: notify_slot_time - slot: %lu, elapsed: %6.6f ms", curr_slot, (double)notify_time_ns * 1e-6));
12861287

12871288
if( ctx->replay_plugin_out_mem ) {
1289+
/*
12881290
fd_replay_complete_msg_t msg2 = {
12891291
.slot = curr_slot,
12901292
.total_txn_count = fork->slot_ctx->txn_count,
@@ -1296,7 +1298,19 @@ publish_slot_notifications( fd_replay_tile_ctx_t * ctx,
12961298
.priority_fee = fork->slot_ctx->slot_bank.collected_priority_fees,
12971299
.parent_slot = ctx->parent_slot,
12981300
};
1299-
replay_plugin_publish( ctx, stem, FD_PLUGIN_MSG_SLOT_COMPLETED, (uchar const *)&msg2, sizeof(msg2) );
1301+
*/
1302+
ulong msg[10];
1303+
msg[ 0 ] = ctx->curr_slot;
1304+
msg[ 1 ] = fork->slot_ctx->txn_count;
1305+
msg[ 2 ] = fork->slot_ctx->nonvote_txn_count;
1306+
msg[ 3 ] = fork->slot_ctx->failed_txn_count;
1307+
msg[ 4 ] = fork->slot_ctx->nonvote_failed_txn_count;
1308+
msg[ 5 ] = fork->slot_ctx->total_compute_units_used;
1309+
msg[ 6 ] = fork->slot_ctx->slot_bank.collected_execution_fees;
1310+
msg[ 7 ] = fork->slot_ctx->slot_bank.collected_priority_fees;
1311+
msg[ 8 ] = 0UL; /* todo ... track tips */
1312+
msg[ 9 ] = ctx->parent_slot;
1313+
replay_plugin_publish( ctx, stem, FD_PLUGIN_MSG_SLOT_COMPLETED, (uchar const *)msg, sizeof(msg) );
13001314
}
13011315
}
13021316

@@ -1761,6 +1775,7 @@ exec_slice( fd_replay_tile_ctx_t * ctx,
17611775

17621776
ctx->slice_exec_ctx.txns_rem--;
17631777
num_free_exec_tiles--;
1778+
fork->slot_ctx->txn_count++;
17641779
continue;
17651780
}
17661781

@@ -2033,15 +2048,6 @@ read_snapshot( void * _ctx,
20332048
.para_arg_2 = stem,
20342049
};
20352050

2036-
if( ctx->replay_plugin_out_mem ) {
2037-
// ValidatorStartProgress::DownloadingSnapshot
2038-
uchar msg[56];
2039-
fd_memset( msg, 0, sizeof(msg) );
2040-
msg[0] = 2;
2041-
msg[1] = 1;
2042-
replay_plugin_publish( ctx, stem, FD_PLUGIN_MSG_START_PROGRESS, msg, sizeof(msg) );
2043-
}
2044-
20452051
/* Pass the slot_ctx to snapshot_load or recover_banks */
20462052
/* Base slot is the slot we will compare against the base slot of the incremental snapshot, to ensure that the
20472053
base slot of the incremental snapshot is the slot of the full snapshot.
@@ -2130,17 +2136,6 @@ read_snapshot( void * _ctx,
21302136
fd_snapshot_load_fini( snap_ctx );
21312137
}
21322138

2133-
/* Load incremental */
2134-
2135-
if( ctx->replay_plugin_out_mem ) {
2136-
// ValidatorStartProgress::DownloadingSnapshot
2137-
uchar msg[56];
2138-
fd_memset( msg, 0, sizeof(msg) );
2139-
msg[0] = 2;
2140-
msg[1] = 0;
2141-
replay_plugin_publish( ctx, stem, FD_PLUGIN_MSG_START_PROGRESS, msg, sizeof(msg) );
2142-
}
2143-
21442139
if( strlen( incremental ) > 0 && strcmp( snapshot, "funk" ) != 0 ) {
21452140

21462141
/* The slot of the full snapshot should be used as the base slot to verify the incremental snapshot,
@@ -2158,14 +2153,6 @@ read_snapshot( void * _ctx,
21582153
ctx->runtime_spad );
21592154
}
21602155

2161-
if( ctx->replay_plugin_out_mem ) {
2162-
// ValidatorStartProgress::DownloadedFullSnapshot
2163-
uchar msg[56];
2164-
fd_memset( msg, 0, sizeof(msg) );
2165-
msg[0] = 3;
2166-
replay_plugin_publish( ctx, stem, FD_PLUGIN_MSG_START_PROGRESS, msg, sizeof(msg) );
2167-
}
2168-
21692156
fd_runtime_update_leaders( ctx->slot_ctx,
21702157
ctx->slot_ctx->slot_bank.slot,
21712158
ctx->runtime_spad );
@@ -2325,6 +2312,13 @@ init_snapshot( fd_replay_tile_ctx_t * ctx,
23252312
read_snapshot( ctx, stem, ctx->snapshot, ctx->incremental );
23262313
}
23272314

2315+
if( ctx->replay_plugin_out_mem ) {
2316+
uchar msg[56];
2317+
fd_memset( msg, 0, sizeof(msg) );
2318+
msg[ 0 ] = 6;
2319+
replay_plugin_publish( ctx, stem, FD_PLUGIN_MSG_START_PROGRESS, msg, sizeof(msg) );
2320+
}
2321+
23282322
fd_runtime_read_genesis( ctx->slot_ctx,
23292323
ctx->genesis,
23302324
is_snapshot,
@@ -2335,6 +2329,10 @@ init_snapshot( fd_replay_tile_ctx_t * ctx,
23352329
ctx->epoch_ctx->runtime_public = ctx->runtime_public;
23362330
init_after_snapshot( ctx, stem );
23372331

2332+
if( ctx->replay_plugin_out_mem && strlen( ctx->genesis ) > 0 ) {
2333+
replay_plugin_publish( ctx, stem, FD_PLUGIN_MSG_GENESIS_HASH_KNOWN, ctx->epoch_ctx->epoch_bank.genesis_hash.uc, sizeof(fd_hash_t) );
2334+
}
2335+
23382336
/* Redirect ctx->slot_ctx to point to the memory inside forks. */
23392337

23402338
fd_fork_t * fork = fd_forks_query( ctx->forks, ctx->curr_slot );
@@ -2387,31 +2385,51 @@ publish_votes_to_plugin( fd_replay_tile_ctx_t * ctx,
23872385
fd_vote_state_versioned_t * vsv = fd_vote_state_versioned_decode( mem, &dec_ctx );
23882386

23892387
fd_pubkey_t node_pubkey;
2390-
ulong last_ts_slot;
2388+
ulong commission;
2389+
ulong epoch_credits;
2390+
fd_vote_epoch_credits_t const * _epoch_credits;
2391+
ulong root_slot;
2392+
23912393
switch( vsv->discriminant ) {
23922394
case fd_vote_state_versioned_enum_v0_23_5:
2393-
node_pubkey = vsv->inner.v0_23_5.node_pubkey;
2394-
last_ts_slot = vsv->inner.v0_23_5.last_timestamp.slot;
2395+
node_pubkey = vsv->inner.v0_23_5.node_pubkey;
2396+
commission = vsv->inner.v0_23_5.commission;
2397+
_epoch_credits = deq_fd_vote_epoch_credits_t_peek_tail_const( vsv->inner.v0_23_5.epoch_credits );
2398+
epoch_credits = _epoch_credits->credits - _epoch_credits->prev_credits;
2399+
root_slot = vsv->inner.v0_23_5.root_slot;
23952400
break;
23962401
case fd_vote_state_versioned_enum_v1_14_11:
2397-
node_pubkey = vsv->inner.v1_14_11.node_pubkey;
2398-
last_ts_slot = vsv->inner.v1_14_11.last_timestamp.slot;
2402+
node_pubkey = vsv->inner.v1_14_11.node_pubkey;
2403+
commission = vsv->inner.v1_14_11.commission;
2404+
_epoch_credits = deq_fd_vote_epoch_credits_t_peek_tail_const( vsv->inner.v1_14_11.epoch_credits );
2405+
epoch_credits = _epoch_credits->credits - _epoch_credits->prev_credits;
2406+
root_slot = vsv->inner.v1_14_11.root_slot;
23992407
break;
24002408
case fd_vote_state_versioned_enum_current:
2401-
node_pubkey = vsv->inner.current.node_pubkey;
2402-
last_ts_slot = vsv->inner.current.last_timestamp.slot;
2409+
node_pubkey = vsv->inner.current.node_pubkey;
2410+
commission = vsv->inner.current.commission;
2411+
_epoch_credits = deq_fd_vote_epoch_credits_t_peek_tail_const( vsv->inner.current.epoch_credits );
2412+
epoch_credits = _epoch_credits->credits - _epoch_credits->prev_credits;
2413+
root_slot = vsv->inner.v0_23_5.root_slot;
24032414
break;
24042415
default:
24052416
__builtin_unreachable();
24062417
}
24072418

2419+
fd_clock_timestamp_vote_t_mapnode_t query;
2420+
memcpy( query.elem.pubkey.uc, n->elem.key.uc, 32UL );
2421+
fd_clock_timestamp_vote_t_mapnode_t * res = fd_clock_timestamp_vote_t_map_find( fork->slot_ctx->slot_bank.timestamp_votes.votes_pool, fork->slot_ctx->slot_bank.timestamp_votes.votes_root, &query );
2422+
24082423
fd_vote_update_msg_t * msg = (fd_vote_update_msg_t *)(dst + sizeof(ulong) + i*112U);
24092424
memset( msg, 0, 112U );
24102425
memcpy( msg->vote_pubkey, n->elem.key.uc, sizeof(fd_pubkey_t) );
24112426
memcpy( msg->node_pubkey, node_pubkey.uc, sizeof(fd_pubkey_t) );
24122427
msg->activated_stake = n->elem.stake;
2413-
msg->last_vote = last_ts_slot;
2414-
msg->is_delinquent = (uchar)(msg->last_vote == 0);
2428+
msg->last_vote = res == NULL ? 0UL : res->elem.slot;
2429+
msg->root_slot = root_slot;
2430+
msg->epoch_credits = epoch_credits;
2431+
msg->commission = (uchar)commission;
2432+
msg->is_delinquent = (uchar)fd_int_if(ctx->curr_slot >= 128UL, msg->last_vote <= ctx->curr_slot - 128UL, msg->last_vote == 0);
24152433
++i;
24162434
}
24172435
} FD_SPAD_FRAME_END;
@@ -2547,7 +2565,6 @@ after_credit( fd_replay_tile_ctx_t * ctx,
25472565
if( FD_UNLIKELY( flags & EXEC_FLAG_FINISHED_SLOT ) ){
25482566
fd_fork_t * fork = fd_fork_frontier_ele_query( ctx->forks->frontier, &ctx->curr_slot, NULL, ctx->forks->pool );
25492567

2550-
fork->slot_ctx->txn_count = fork->slot_ctx->slot_bank.transaction_count-fork->slot_ctx->parent_transaction_count;
25512568
FD_LOG_NOTICE(( "finished block - slot: %lu, parent_slot: %lu, txn_cnt: %lu, blockhash: %s",
25522569
curr_slot,
25532570
ctx->parent_slot,
@@ -2619,8 +2636,21 @@ after_credit( fd_replay_tile_ctx_t * ctx,
26192636
FD_LOG_ERR(( "failed to insert ghost node %lu", curr_slot ));
26202637
}
26212638
#endif
2639+
2640+
ulong prev_confirmed = ctx->forks->confirmed;
2641+
ulong prev_finalized = ctx->forks->finalized;
26222642
fd_forks_update( ctx->forks, ctx->epoch, ctx->funk, ctx->ghost, curr_slot );
26232643

2644+
if (FD_UNLIKELY( prev_confirmed!=ctx->forks->confirmed ) ) {
2645+
ulong msg[ 1 ] = { ctx->forks->confirmed };
2646+
replay_plugin_publish( ctx, stem, FD_PLUGIN_MSG_SLOT_OPTIMISTICALLY_CONFIRMED, (uchar const *)msg, sizeof(msg) );
2647+
}
2648+
2649+
if (FD_UNLIKELY( prev_finalized!=ctx->forks->finalized ) ) {
2650+
ulong msg[ 1 ] = { ctx->forks->finalized };
2651+
replay_plugin_publish( ctx, stem, FD_PLUGIN_MSG_SLOT_ROOTED, (uchar const *)msg, sizeof(msg) );
2652+
}
2653+
26242654
/**********************************************************************/
26252655
/* Consensus: decide (1) the fork for pack; (2) the fork to vote on */
26262656
/**********************************************************************/
@@ -2638,6 +2668,14 @@ after_credit( fd_replay_tile_ctx_t * ctx,
26382668
reset_fork = new_reset_fork;
26392669
}
26402670

2671+
if( FD_UNLIKELY( !ctx->startup_init_done && ctx->replay_plugin_out_mem ) ) {
2672+
ctx->startup_init_done = 1;
2673+
uchar msg[ 56 ];
2674+
fd_memset( msg, 0, sizeof(msg) );
2675+
msg[ 0 ] = 11; // ValidatorStartProgress::Running
2676+
replay_plugin_publish( ctx, stem, FD_PLUGIN_MSG_START_PROGRESS, msg, sizeof(msg) );
2677+
}
2678+
26412679
/* Update the gui */
26422680
if( ctx->replay_plugin_out_mem ) {
26432681
/* FIXME. We need a more efficient way to compute the ancestor chain. */
@@ -2793,16 +2831,15 @@ after_credit( fd_replay_tile_ctx_t * ctx,
27932831
} // end of if( FD_UNLIKELY( ( flags & REPLAY_FLAG_FINISHED_BLOCK ) ) )
27942832

27952833
if( FD_UNLIKELY( ctx->snapshot_init_done==0 ) ) {
2796-
init_snapshot( ctx, stem );
2797-
ctx->snapshot_init_done = 1;
2798-
//*charge_busy = 0;
27992834
if( ctx->replay_plugin_out_mem ) {
2800-
// ValidatorStartProgress::Running
28012835
uchar msg[56];
28022836
fd_memset( msg, 0, sizeof(msg) );
2803-
msg[0] = 11;
2837+
msg[ 0 ] = 0; // ValidatorStartProgress::Initializing
28042838
replay_plugin_publish( ctx, stem, FD_PLUGIN_MSG_START_PROGRESS, msg, sizeof(msg) );
28052839
}
2840+
init_snapshot( ctx, stem );
2841+
ctx->snapshot_init_done = 1;
2842+
//*charge_busy = 0;
28062843
}
28072844

28082845
long now = fd_log_wallclock();
@@ -3200,8 +3237,9 @@ unprivileged_init( fd_topo_t * topo,
32003237
poh_out->chunk = poh_out->chunk0;
32013238
}
32023239

3203-
ctx->poh_init_done = 0U;
3240+
ctx->poh_init_done = 0U;
32043241
ctx->snapshot_init_done = 0;
3242+
ctx->startup_init_done = 0;
32053243

32063244
/**********************************************************************/
32073245
/* exec */

0 commit comments

Comments
 (0)