Manually serialize and use `send_wire_transaction` for votes (#23826)

* Revert "core: partial versioned transaction support for voting service"

This reverts commit eb3df4c20e.

* Manually serialize vote tx before sending to TPU
This commit is contained in:
Justin Starry 2022-03-23 09:47:55 +08:00 committed by GitHub
parent 9f0ca6d88a
commit 92462ae031
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 13 deletions

View File

@ -2001,7 +2001,7 @@ impl ReplayStage {
);
voting_sender
.send(VoteOp::RefreshVote {
tx: vote_tx.into(),
tx: vote_tx,
last_voted_slot,
})
.unwrap_or_else(|err| warn!("Error: {:?}", err));
@ -2044,7 +2044,7 @@ impl ReplayStage {
let tower_slots = tower.tower_slots();
voting_sender
.send(VoteOp::PushVote {
tx: vote_tx.into(),
tx: vote_tx,
tower_slots,
saved_tower: SavedTowerVersions::from(saved_tower),
})

View File

@ -6,7 +6,7 @@ use {
solana_measure::measure::Measure,
solana_poh::poh_recorder::PohRecorder,
solana_runtime::bank_forks::BankForks,
solana_sdk::{clock::Slot, transaction::VersionedTransaction},
solana_sdk::{clock::Slot, transaction::Transaction},
std::{
sync::{Arc, Mutex, RwLock},
thread::{self, Builder, JoinHandle},
@ -15,18 +15,18 @@ use {
pub enum VoteOp {
PushVote {
tx: VersionedTransaction,
tx: Transaction,
tower_slots: Vec<Slot>,
saved_tower: SavedTowerVersions,
},
RefreshVote {
tx: VersionedTransaction,
tx: Transaction,
last_voted_slot: Slot,
},
}
impl VoteOp {
fn tx(&self) -> &VersionedTransaction {
fn tx(&self) -> &Transaction {
match self {
VoteOp::PushVote { tx, .. } => tx,
VoteOp::RefreshVote { tx, .. } => tx,
@ -90,7 +90,8 @@ impl VotingService {
let mut measure = Measure::start("vote_tx_send-ms");
let target_address = target_address.unwrap_or_else(|| cluster_info.my_contact_info().tpu);
let _ = get_connection(&target_address).serialize_and_send_transaction(vote_op.tx());
let wire_vote_tx = bincode::serialize(vote_op.tx()).expect("vote serialization failure");
let _ = get_connection(&target_address).send_wire_transaction(&wire_vote_tx);
measure.stop();
inc_new_counter_info!("vote_tx_send-ms", measure.as_ms() as usize);
@ -98,18 +99,12 @@ impl VotingService {
VoteOp::PushVote {
tx, tower_slots, ..
} => {
// we can safely unwrap here because the vote tx is constructed
// from a legacy transaction in replay stage
let tx = tx.into_legacy_transaction().unwrap();
cluster_info.push_vote(&tower_slots, tx);
}
VoteOp::RefreshVote {
tx,
last_voted_slot,
} => {
// we can safely unwrap here because the vote tx is constructed
// from a legacy transaction in replay stage
let tx = tx.into_legacy_transaction().unwrap();
cluster_info.refresh_vote(tx, last_voted_slot);
}
}