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

@@ -52,7 +52,7 @@ use {
},
},
solana_rayon_threadlimit::get_thread_count,
solana_runtime::bank_forks::BankForks,
solana_runtime::{bank_forks::BankForks, vote_parser},
solana_sdk::{
clock::{Slot, DEFAULT_MS_PER_SLOT, DEFAULT_SLOTS_PER_EPOCH},
feature_set::FeatureSet,
@@ -69,9 +69,7 @@ use {
socket::SocketAddrSpace,
streamer::{PacketBatchReceiver, PacketBatchSender},
},
solana_vote_program::{
vote_state::MAX_LOCKOUT_HISTORY, vote_transaction::parse_vote_transaction,
},
solana_vote_program::vote_state::MAX_LOCKOUT_HISTORY,
std::{
borrow::Cow,
collections::{hash_map::Entry, HashMap, HashSet, VecDeque},
@@ -1037,7 +1035,7 @@ impl ClusterInfo {
};
let vote_index = vote_index.unwrap_or(num_crds_votes);
if (vote_index as usize) >= MAX_LOCKOUT_HISTORY {
let (_, vote, hash) = parse_vote_transaction(&vote).unwrap();
let (_, vote, hash) = vote_parser::parse_vote_transaction(&vote).unwrap();
panic!(
"invalid vote index: {}, switch: {}, vote slots: {:?}, tower: {:?}",
vote_index,

View File

@@ -9,6 +9,7 @@ use {
bincode::{serialize, serialized_size},
rand::{CryptoRng, Rng},
serde::de::{Deserialize, Deserializer},
solana_runtime::vote_parser,
solana_sdk::{
clock::Slot,
hash::Hash,
@@ -18,7 +19,6 @@ use {
timing::timestamp,
transaction::Transaction,
},
solana_vote_program::vote_transaction::parse_vote_transaction,
std::{
borrow::{Borrow, Cow},
cmp::Ordering,
@@ -307,7 +307,7 @@ impl Sanitize for Vote {
impl Vote {
// Returns None if cannot parse transaction into a vote.
pub fn new(from: Pubkey, transaction: Transaction, wallclock: u64) -> Option<Self> {
parse_vote_transaction(&transaction).map(|(_, vote, _)| Self {
vote_parser::parse_vote_transaction(&transaction).map(|(_, vote, _)| Self {
from,
transaction,
wallclock,