@@ -585,6 +585,19 @@ 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_DEBUG (( "vote account %s has no lamports" , FD_BASE58_ENC_32_ALLOCA ( pubkey -> uc ) ));
592+ return -1 ;
593+ }
594+ /* Sanity check that the vote account data has been initialized, and the
595+ discriminator is none-zero. */
596+ if ( FD_UNLIKELY ( data_sz == 0UL || memcmp ( vote_tower_out -> acc , "\0\0" , 2 ) == 0 ) ) {
597+ FD_LOG_DEBUG (( "vote account %s has invalid data" , FD_BASE58_ENC_32_ALLOCA ( pubkey -> uc ) ));
598+ return -1 ;
599+ }
600+
588601 fd_memcpy ( vote_tower_out -> acc , fd_accdb_ref_data_const ( peek -> acc ), data_sz );
589602 vote_tower_out -> acc_sz = data_sz ;
590603
@@ -617,12 +630,12 @@ buffer_vote_towers( fd_replay_tile_t * ctx,
617630 if ( FD_UNLIKELY ( vote_state -> stake == 0 ) ) continue ; /* skip unstaked vote accounts */
618631 fd_pubkey_t const * vote_account_pubkey = & vote_state -> vote_account ;
619632 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 ++ ] ) ) ) {
633+ fd_replay_tower_t * vote_tower_out = & ctx -> vote_tower_out [ ctx -> vote_tower_out_len ];
634+ int err = fd_replay_out_vote_tower_from_funk ( ctx -> accdb , xid , vote_account_pubkey , vote_state -> stake , vote_tower_out );
635+ if ( FD_UNLIKELY ( err ) ) {
625636 FD_LOG_DEBUG (( "failed to get vote state for vote account %s" , FD_BASE58_ENC_32_ALLOCA ( vote_account_pubkey -> uc ) ));
637+ } else {
638+ ctx -> vote_tower_out_len ++ ;
626639 }
627640 }
628641 fd_bank_vote_states_prev_end_locking_query ( bank );
0 commit comments