Refactor: move simple vote parsing to runtime (backport #22537) (#22587)

* Refactor: move simple vote parsing to runtime (#22537)

(cherry picked from commit 7f20c6149e)

# Conflicts:
#	core/src/cluster_info_vote_listener.rs
#	core/src/verified_vote_packets.rs
#	programs/vote/src/vote_transaction.rs
#	rpc/src/rpc_subscriptions.rs
#	runtime/src/bank.rs
#	runtime/src/bank_utils.rs
#	runtime/src/vote_sender_types.rs

* resolve conflicts

Co-authored-by: Justin Starry <justin@solana.com>
This commit is contained in:
mergify[bot]
2022-01-20 04:51:50 +00:00
committed by GitHub
parent dbf9a32883
commit 59f406d78a
10 changed files with 137 additions and 148 deletions

View File

@ -32,6 +32,7 @@ use {
bank_forks::BankForks,
commitment::VOTE_THRESHOLD_SIZE,
epoch_stakes::EpochStakes,
vote_parser,
vote_sender_types::{ReplayVoteReceiver, ReplayedVote},
},
solana_sdk::{
@ -42,7 +43,7 @@ use {
slot_hashes,
transaction::Transaction,
},
solana_vote_program::{self, vote_state::Vote, vote_transaction},
solana_vote_program::vote_state::Vote,
std::{
collections::{HashMap, HashSet},
iter::repeat,
@ -311,7 +312,7 @@ impl ClusterInfoVoteListener {
!packet_batch.packets[0].meta.discard()
})
.filter_map(|(tx, packet_batch)| {
let (vote_account_key, vote, _) = vote_transaction::parse_vote_transaction(&tx)?;
let (vote_account_key, vote, _) = vote_parser::parse_vote_transaction(&tx)?;
let slot = vote.last_voted_slot()?;
let epoch = epoch_schedule.get_epoch(slot);
let authorized_voter = root_bank
@ -705,7 +706,7 @@ impl ClusterInfoVoteListener {
// Process votes from gossip and ReplayStage
let votes = gossip_vote_txs
.iter()
.filter_map(vote_transaction::parse_vote_transaction)
.filter_map(vote_parser::parse_vote_transaction)
.zip(repeat(/*is_gossip:*/ true))
.chain(replayed_votes.into_iter().zip(repeat(/*is_gossip:*/ false)));
for ((vote_pubkey, vote, _), is_gossip) in votes {
@ -823,7 +824,7 @@ mod tests {
pubkey::Pubkey,
signature::{Keypair, Signature, Signer},
},
solana_vote_program::vote_state::Vote,
solana_vote_program::{vote_state::Vote, vote_transaction},
std::{
collections::BTreeSet,
iter::repeat_with,