@@ -585,6 +585,17 @@ fd_replay_out_vote_tower_from_funk(
585585 return -1 ;
586586 }
587587
588+ /* If the vote account has no lamports, no data, or the first 2 bytes are zeros,
589+ then it is not a valid vote account and should be skipped */
590+ if ( FD_UNLIKELY ( fd_accdb_ref_lamports ( peek -> acc ) == 0 ) ) {
591+ FD_LOG_WARNING (( "vote account %s has no lamports" , FD_BASE58_ENC_32_ALLOCA ( pubkey -> uc ) ));
592+ return -1 ;
593+ }
594+ if ( FD_UNLIKELY ( data_sz == 0UL || memcmp ( vote_tower_out -> acc , "\0\0" , 2 ) == 0 ) ) {
595+ FD_LOG_WARNING (( "vote account %s has invalid data" , FD_BASE58_ENC_32_ALLOCA ( pubkey -> uc ) ));
596+ return -1 ;
597+ }
598+
588599 fd_memcpy ( vote_tower_out -> acc , fd_accdb_ref_data_const ( peek -> acc ), data_sz );
589600 vote_tower_out -> acc_sz = data_sz ;
590601
@@ -617,12 +628,12 @@ buffer_vote_towers( fd_replay_tile_t * ctx,
617628 if ( FD_UNLIKELY ( vote_state -> stake == 0 ) ) continue ; /* skip unstaked vote accounts */
618629 fd_pubkey_t const * vote_account_pubkey = & vote_state -> vote_account ;
619630 if ( FD_UNLIKELY ( ctx -> vote_tower_out_len >= (FD_REPLAY_TOWER_VOTE_ACC_MAX - 1UL ) ) ) FD_LOG_ERR (( "vote_tower_out_len too large" ));
620- if ( FD_UNLIKELY ( fd_replay_out_vote_tower_from_funk ( ctx -> accdb ,
621- xid ,
622- vote_account_pubkey ,
623- vote_state -> stake ,
624- & ctx -> vote_tower_out [ctx -> vote_tower_out_len ++ ] ) ) ) {
631+ fd_replay_tower_t * vote_tower_out = & ctx -> vote_tower_out [ ctx -> vote_tower_out_len ];
632+ int err = fd_replay_out_vote_tower_from_funk ( ctx -> accdb , xid , vote_account_pubkey , vote_state -> stake , vote_tower_out );
633+ if ( FD_UNLIKELY ( err ) ) {
625634 FD_LOG_DEBUG (( "failed to get vote state for vote account %s" , FD_BASE58_ENC_32_ALLOCA ( vote_account_pubkey -> uc ) ));
635+ } else {
636+ ctx -> vote_tower_out_len ++ ;
626637 }
627638 }
628639 fd_bank_vote_states_prev_end_locking_query ( bank );
0 commit comments