Send votes to next leader's TPU instead of our TPU
This commit is contained in:
parent
a19c3ba5b0
commit
c8b474cd0b
|
@ -566,15 +566,8 @@ impl BankingStage {
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let next_leader = match poh_recorder
|
|
||||||
.lock()
|
let addr = match next_leader_tpu_forwards(cluster_info, poh_recorder) {
|
||||||
.unwrap()
|
|
||||||
.leader_after_n_slots(FORWARD_TRANSACTIONS_TO_LEADER_AT_SLOT_OFFSET)
|
|
||||||
{
|
|
||||||
Some(pubkey) => pubkey,
|
|
||||||
None => return,
|
|
||||||
};
|
|
||||||
let addr = match cluster_info.lookup_contact_info(&next_leader, |ci| ci.tpu_forwards) {
|
|
||||||
Some(addr) => addr,
|
Some(addr) => addr,
|
||||||
None => return,
|
None => return,
|
||||||
};
|
};
|
||||||
|
@ -1368,6 +1361,36 @@ impl BankingStage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn next_leader_tpu(
|
||||||
|
cluster_info: &ClusterInfo,
|
||||||
|
poh_recorder: &Arc<Mutex<PohRecorder>>,
|
||||||
|
) -> Option<std::net::SocketAddr> {
|
||||||
|
if let Some(leader_pubkey) = poh_recorder
|
||||||
|
.lock()
|
||||||
|
.unwrap()
|
||||||
|
.leader_after_n_slots(FORWARD_TRANSACTIONS_TO_LEADER_AT_SLOT_OFFSET)
|
||||||
|
{
|
||||||
|
cluster_info.lookup_contact_info(&leader_pubkey, |leader| leader.tpu)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn next_leader_tpu_forwards(
|
||||||
|
cluster_info: &ClusterInfo,
|
||||||
|
poh_recorder: &Arc<Mutex<PohRecorder>>,
|
||||||
|
) -> Option<std::net::SocketAddr> {
|
||||||
|
if let Some(leader_pubkey) = poh_recorder
|
||||||
|
.lock()
|
||||||
|
.unwrap()
|
||||||
|
.leader_after_n_slots(FORWARD_TRANSACTIONS_TO_LEADER_AT_SLOT_OFFSET)
|
||||||
|
{
|
||||||
|
cluster_info.lookup_contact_info(&leader_pubkey, |leader| leader.tpu_forwards)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn create_test_recorder(
|
pub fn create_test_recorder(
|
||||||
bank: &Arc<Bank>,
|
bank: &Arc<Bank>,
|
||||||
blockstore: &Arc<Blockstore>,
|
blockstore: &Arc<Blockstore>,
|
||||||
|
|
|
@ -1182,8 +1182,8 @@ impl ClusterInfo {
|
||||||
.process_push_message(&self_pubkey, vec![vote], now);
|
.process_push_message(&self_pubkey, vec![vote], now);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn send_vote(&self, vote: &Transaction) -> Result<()> {
|
pub fn send_vote(&self, vote: &Transaction, tpu: Option<SocketAddr>) -> Result<()> {
|
||||||
let tpu = self.my_contact_info().tpu;
|
let tpu = tpu.unwrap_or_else(|| self.my_contact_info().tpu);
|
||||||
let buf = serialize(vote)?;
|
let buf = serialize(vote)?;
|
||||||
self.socket.send_to(&buf, &tpu)?;
|
self.socket.send_to(&buf, &tpu)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -526,6 +526,7 @@ impl ReplayStage {
|
||||||
|
|
||||||
Self::handle_votable_bank(
|
Self::handle_votable_bank(
|
||||||
&vote_bank,
|
&vote_bank,
|
||||||
|
&poh_recorder,
|
||||||
switch_fork_decision,
|
switch_fork_decision,
|
||||||
&bank_forks,
|
&bank_forks,
|
||||||
&mut tower,
|
&mut tower,
|
||||||
|
@ -1250,6 +1251,7 @@ impl ReplayStage {
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
fn handle_votable_bank(
|
fn handle_votable_bank(
|
||||||
bank: &Arc<Bank>,
|
bank: &Arc<Bank>,
|
||||||
|
poh_recorder: &Arc<Mutex<PohRecorder>>,
|
||||||
switch_fork_decision: &SwitchForkDecision,
|
switch_fork_decision: &SwitchForkDecision,
|
||||||
bank_forks: &Arc<RwLock<BankForks>>,
|
bank_forks: &Arc<RwLock<BankForks>>,
|
||||||
tower: &mut Tower,
|
tower: &mut Tower,
|
||||||
|
@ -1350,6 +1352,7 @@ impl ReplayStage {
|
||||||
Self::push_vote(
|
Self::push_vote(
|
||||||
cluster_info,
|
cluster_info,
|
||||||
bank,
|
bank,
|
||||||
|
poh_recorder,
|
||||||
vote_account_pubkey,
|
vote_account_pubkey,
|
||||||
authorized_voter_keypairs,
|
authorized_voter_keypairs,
|
||||||
last_vote,
|
last_vote,
|
||||||
|
@ -1360,9 +1363,11 @@ impl ReplayStage {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
fn push_vote(
|
fn push_vote(
|
||||||
cluster_info: &ClusterInfo,
|
cluster_info: &ClusterInfo,
|
||||||
bank: &Arc<Bank>,
|
bank: &Arc<Bank>,
|
||||||
|
poh_recorder: &Arc<Mutex<PohRecorder>>,
|
||||||
vote_account_pubkey: &Pubkey,
|
vote_account_pubkey: &Pubkey,
|
||||||
authorized_voter_keypairs: &[Arc<Keypair>],
|
authorized_voter_keypairs: &[Arc<Keypair>],
|
||||||
vote: Vote,
|
vote: Vote,
|
||||||
|
@ -1452,7 +1457,10 @@ impl ReplayStage {
|
||||||
vote_signatures.clear();
|
vote_signatures.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
let _ = cluster_info.send_vote(&vote_tx);
|
let _ = cluster_info.send_vote(
|
||||||
|
&vote_tx,
|
||||||
|
crate::banking_stage::next_leader_tpu(cluster_info, poh_recorder),
|
||||||
|
);
|
||||||
cluster_info.push_vote(tower, vote_tx);
|
cluster_info.push_vote(tower, vote_tx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue