@@ -146,6 +146,7 @@ struct fd_replay_tile {
146146 fd_txncache_t * txncache ;
147147 fd_store_t * store ;
148148 fd_banks_t * banks ;
149+ ulong reset_bank_idx ; /* most recent reset bank idx, used for determining root distance */
149150
150151 /* This flag is 1 If we have seen a vote signature that our node has
151152 sent out get rooted at least one time. The value is 0 otherwise.
@@ -2123,9 +2124,9 @@ process_exec_task_done( fd_replay_tile_t * ctx,
21232124}
21242125
21252126static void
2126- process_tower_update ( fd_replay_tile_t * ctx ,
2127- fd_stem_context_t * stem ,
2128- fd_tower_slot_done_t const * msg ) {
2127+ process_tower_slot_done ( fd_replay_tile_t * ctx ,
2128+ fd_stem_context_t * stem ,
2129+ fd_tower_slot_done_t const * msg ) {
21292130 ctx -> reset_block_id = msg -> reset_block_id ;
21302131 ctx -> reset_slot = msg -> reset_slot ;
21312132 ctx -> reset_timestamp_nanos = fd_log_wallclock ();
@@ -2148,7 +2149,6 @@ process_tower_update( fd_replay_tile_t * ctx,
21482149 FD_LOG_CRIT (( "invariant violation: bank not found for bank index %lu" , reset_bank_idx ));
21492150 }
21502151
2151- if ( FD_LIKELY ( msg -> root_slot != ULONG_MAX ) ) FD_TEST ( msg -> root_slot <=msg -> reset_slot );
21522152 ctx -> reset_bank = bank ;
21532153
21542154 if ( FD_LIKELY ( ctx -> replay_out -> idx != ULONG_MAX ) ) {
@@ -2184,22 +2184,36 @@ process_tower_update( fd_replay_tile_t * ctx,
21842184 ctx -> replay_out -> chunk = fd_dcache_compact_next ( ctx -> replay_out -> chunk , sizeof (fd_poh_reset_t ), ctx -> replay_out -> chunk0 , ctx -> replay_out -> wmark );
21852185 }
21862186
2187- FD_LOG_INFO (( "tower_update (reset_slot=%lu, next_leader_slot=%lu, vote_slot=%lu, root_slot=%lu, root_block_id=%s )" , msg -> reset_slot , ctx -> next_leader_slot , msg -> vote_slot , msg -> root_slot , FD_BASE58_ENC_32_ALLOCA ( & msg -> root_block_id ) ));
2187+ FD_LOG_INFO (( "tower_slot_done (reset_slot=%lu, next_leader_slot=%lu, vote_slot=%lu)" , msg -> reset_slot , ctx -> next_leader_slot , msg -> vote_slot ));
21882188 maybe_become_leader ( ctx , stem );
2189+ }
21892190
2190- if ( FD_LIKELY ( msg -> root_slot != ULONG_MAX ) ) {
2191+ static void
2192+ process_tower_slot_confirmed ( fd_replay_tile_t * ctx ,
2193+ fd_stem_context_t * stem ,
2194+ fd_tower_slot_confirmed_t const * msg ) {
2195+ if ( FD_LIKELY ( msg -> kind == FD_TOWER_SLOT_CONFIRMED_ROOTED ) ) {
21912196
2192- FD_TEST ( msg -> root_slot >=ctx -> consensus_root_slot );
2193- fd_block_id_ele_t * block_id_ele = fd_block_id_map_ele_query ( ctx -> block_id_map , & msg -> root_block_id , NULL , ctx -> block_id_arr );
2197+ FD_TEST ( msg -> slot >=ctx -> consensus_root_slot );
2198+ fd_block_id_ele_t * block_id_ele = fd_block_id_map_ele_query ( ctx -> block_id_map , & msg -> block_id , NULL , ctx -> block_id_arr );
21942199 FD_TEST ( block_id_ele );
21952200
2196- ctx -> consensus_root_slot = msg -> root_slot ;
2197- ctx -> consensus_root = msg -> root_block_id ;
2201+ ctx -> consensus_root_slot = msg -> slot ;
2202+ ctx -> consensus_root = msg -> block_id ;
21982203 ctx -> consensus_root_bank_idx = fd_block_id_ele_get_idx ( ctx -> block_id_arr , block_id_ele );
21992204
22002205 publish_root_advanced ( ctx , stem );
22012206 }
22022207
2208+ /* If tower roots a slot, it always publishes the frag immediately
2209+ after the slot_done message, so ctx->reset_bank_idx should still be
2210+ valid at this point (it could not have been published away). */
2211+
2212+ fd_bank_t * bank = fd_banks_bank_query ( ctx -> banks , ctx -> reset_bank_idx );
2213+ if ( FD_UNLIKELY ( !bank ) ) {
2214+ FD_LOG_CRIT (( "invariant violation: bank not found for bank index %lu" , ctx -> reset_bank_idx ));
2215+ }
2216+
22032217 ulong distance = 0UL ;
22042218 fd_bank_t * parent = bank ;
22052219 while ( parent ) {
@@ -2369,7 +2383,8 @@ returnable_frag( fd_replay_tile_t * ctx,
23692383 break ;
23702384 }
23712385 case IN_KIND_TOWER : {
2372- if ( FD_LIKELY ( sig == FD_TOWER_SIG_SLOT_DONE ) ) process_tower_update ( ctx , stem , fd_chunk_to_laddr ( ctx -> in [ in_idx ].mem , chunk ) );
2386+ if ( FD_LIKELY ( sig == FD_TOWER_SIG_SLOT_DONE ) ) process_tower_slot_done ( ctx , stem , fd_chunk_to_laddr ( ctx -> in [ in_idx ].mem , chunk ) );
2387+ else if ( FD_LIKELY ( sig == FD_TOWER_SIG_SLOT_CONFIRMED ) ) process_tower_slot_confirmed ( ctx , stem , fd_chunk_to_laddr ( ctx -> in [ in_idx ].mem , chunk ) );
23732388 break ;
23742389 }
23752390 case IN_KIND_SHRED : {
0 commit comments