Skip to content

Commit 566cd34

Browse files
emwang-jumplidatong
authored andcommitted
tower: prevent publish on old roots popped from tower
1 parent da6b5cc commit 566cd34

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/choreo/ghost/fd_ghost.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -345,17 +345,19 @@ FD_FN_PURE static inline fd_ghost_ele_t const * fd_ghost_root_const ( fd
345345
NULL if not found. */
346346

347347
FD_FN_PURE static inline fd_ghost_ele_t *
348-
fd_ghost_query( fd_ghost_t * ghost, fd_hash_t const * hash_id ) {
348+
fd_ghost_query( fd_ghost_t * ghost, fd_hash_t const * hash ) {
349+
if( FD_UNLIKELY( !hash ) ) { return NULL; }
349350
fd_ghost_hash_map_t * map = fd_ghost_hash_map( ghost );
350351
fd_ghost_ele_t * pool = fd_ghost_pool( ghost );
351-
return fd_ghost_hash_map_ele_query( map, hash_id, NULL, pool );
352+
return fd_ghost_hash_map_ele_query( map, hash, NULL, pool );
352353
}
353354

354355
FD_FN_PURE static inline fd_ghost_ele_t const *
355-
fd_ghost_query_const( fd_ghost_t const * ghost, fd_hash_t const * hash_id ) {
356+
fd_ghost_query_const( fd_ghost_t const * ghost, fd_hash_t const * hash ) {
357+
if( FD_UNLIKELY( !hash ) ) { return NULL; }
356358
fd_ghost_hash_map_t const * map = fd_ghost_hash_map_const ( ghost );
357359
fd_ghost_ele_t const * pool = fd_ghost_pool_const( ghost );
358-
return fd_ghost_hash_map_ele_query_const( map, hash_id, NULL, pool );
360+
return fd_ghost_hash_map_ele_query_const( map, hash, NULL, pool );
359361
}
360362

361363
/* fd_ghost_hash returns the hash_id of the ele keyed by `slot`.

src/discof/tower/fd_tower_tile.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,12 @@ after_frag( ctx_t * ctx,
307307
ulong root = fd_tower_vote( ctx->tower, vote_slot );
308308
if( FD_LIKELY( root != FD_SLOT_NULL ) ) {
309309
fd_hash_t const * root_bid = fd_ghost_hash( ctx->ghost, root );
310-
fd_ghost_publish( ctx->ghost, root_bid );
311-
fd_stem_publish( stem, ctx->replay_out_idx, root, 0UL, 0UL, 0UL, tsorig, fd_frag_meta_ts_comp( fd_tickcount() ) );
310+
if( FD_UNLIKELY( !root_bid ) ) {
311+
FD_LOG_WARNING(( "Lowest vote slot %lu is not in ghost, skipping publish", root ));
312+
} else {
313+
fd_ghost_publish( ctx->ghost, root_bid );
314+
fd_stem_publish( stem, ctx->replay_out_idx, root, 0UL, 0UL, 0UL, tsorig, fd_frag_meta_ts_comp( fd_tickcount() ) );
315+
}
312316
ctx->root = root;
313317
}
314318

0 commit comments

Comments
 (0)