core: partial versioned transaction support for voting service
This commit is contained in:
committed by
Trent Nelson
parent
016d3c450a
commit
eb3df4c20e
@ -2001,7 +2001,7 @@ impl ReplayStage {
|
|||||||
);
|
);
|
||||||
voting_sender
|
voting_sender
|
||||||
.send(VoteOp::RefreshVote {
|
.send(VoteOp::RefreshVote {
|
||||||
tx: vote_tx,
|
tx: vote_tx.into(),
|
||||||
last_voted_slot,
|
last_voted_slot,
|
||||||
})
|
})
|
||||||
.unwrap_or_else(|err| warn!("Error: {:?}", err));
|
.unwrap_or_else(|err| warn!("Error: {:?}", err));
|
||||||
@ -2044,7 +2044,7 @@ impl ReplayStage {
|
|||||||
let tower_slots = tower.tower_slots();
|
let tower_slots = tower.tower_slots();
|
||||||
voting_sender
|
voting_sender
|
||||||
.send(VoteOp::PushVote {
|
.send(VoteOp::PushVote {
|
||||||
tx: vote_tx,
|
tx: vote_tx.into(),
|
||||||
tower_slots,
|
tower_slots,
|
||||||
saved_tower: SavedTowerVersions::from(saved_tower),
|
saved_tower: SavedTowerVersions::from(saved_tower),
|
||||||
})
|
})
|
||||||
|
@ -6,7 +6,7 @@ use {
|
|||||||
solana_measure::measure::Measure,
|
solana_measure::measure::Measure,
|
||||||
solana_poh::poh_recorder::PohRecorder,
|
solana_poh::poh_recorder::PohRecorder,
|
||||||
solana_runtime::bank_forks::BankForks,
|
solana_runtime::bank_forks::BankForks,
|
||||||
solana_sdk::{clock::Slot, transaction::Transaction},
|
solana_sdk::{clock::Slot, transaction::VersionedTransaction},
|
||||||
std::{
|
std::{
|
||||||
sync::{Arc, Mutex, RwLock},
|
sync::{Arc, Mutex, RwLock},
|
||||||
thread::{self, Builder, JoinHandle},
|
thread::{self, Builder, JoinHandle},
|
||||||
@ -15,18 +15,18 @@ use {
|
|||||||
|
|
||||||
pub enum VoteOp {
|
pub enum VoteOp {
|
||||||
PushVote {
|
PushVote {
|
||||||
tx: Transaction,
|
tx: VersionedTransaction,
|
||||||
tower_slots: Vec<Slot>,
|
tower_slots: Vec<Slot>,
|
||||||
saved_tower: SavedTowerVersions,
|
saved_tower: SavedTowerVersions,
|
||||||
},
|
},
|
||||||
RefreshVote {
|
RefreshVote {
|
||||||
tx: Transaction,
|
tx: VersionedTransaction,
|
||||||
last_voted_slot: Slot,
|
last_voted_slot: Slot,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
impl VoteOp {
|
impl VoteOp {
|
||||||
fn tx(&self) -> &Transaction {
|
fn tx(&self) -> &VersionedTransaction {
|
||||||
match self {
|
match self {
|
||||||
VoteOp::PushVote { tx, .. } => tx,
|
VoteOp::PushVote { tx, .. } => tx,
|
||||||
VoteOp::RefreshVote { tx, .. } => tx,
|
VoteOp::RefreshVote { tx, .. } => tx,
|
||||||
@ -90,7 +90,7 @@ impl VotingService {
|
|||||||
|
|
||||||
let mut measure = Measure::start("vote_tx_send-ms");
|
let mut measure = Measure::start("vote_tx_send-ms");
|
||||||
let target_address = target_address.unwrap_or_else(|| cluster_info.my_contact_info().tpu);
|
let target_address = target_address.unwrap_or_else(|| cluster_info.my_contact_info().tpu);
|
||||||
let _ = get_connection(&target_address).send_transaction(vote_op.tx());
|
let _ = get_connection(&target_address).serialize_and_send_transaction(vote_op.tx());
|
||||||
measure.stop();
|
measure.stop();
|
||||||
inc_new_counter_info!("vote_tx_send-ms", measure.as_ms() as usize);
|
inc_new_counter_info!("vote_tx_send-ms", measure.as_ms() as usize);
|
||||||
|
|
||||||
@ -98,12 +98,18 @@ impl VotingService {
|
|||||||
VoteOp::PushVote {
|
VoteOp::PushVote {
|
||||||
tx, tower_slots, ..
|
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);
|
cluster_info.push_vote(&tower_slots, tx);
|
||||||
}
|
}
|
||||||
VoteOp::RefreshVote {
|
VoteOp::RefreshVote {
|
||||||
tx,
|
tx,
|
||||||
last_voted_slot,
|
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);
|
cluster_info.refresh_vote(tx, last_voted_slot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user