Skip to content

Commit

Permalink
Merge branch 'master' into lb/remove_unexecuted_txs_cost_model
Browse files Browse the repository at this point in the history
  • Loading branch information
buffalu authored Jun 27, 2023
2 parents a9239f1 + 9fb105c commit f5e9c83
Show file tree
Hide file tree
Showing 16 changed files with 1,091 additions and 587 deletions.
20 changes: 19 additions & 1 deletion account-decoder/src/parse_sysvar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ use {
slot_hashes::SlotHashes,
slot_history::{self, SlotHistory},
stake_history::{StakeHistory, StakeHistoryEntry},
sysvar::{self, last_restart_slot::LastRestartSlot, rewards::Rewards},
sysvar::{
self, epoch_rewards::EpochRewards, last_restart_slot::LastRestartSlot, rewards::Rewards,
},
},
};

Expand Down Expand Up @@ -89,6 +91,10 @@ pub fn parse_sysvar(data: &[u8], pubkey: &Pubkey) -> Result<SysvarAccountType, P
let last_restart_slot = last_restart_slot.last_restart_slot;
SysvarAccountType::LastRestartSlot(UiLastRestartSlot { last_restart_slot })
})
} else if pubkey == &sysvar::epoch_rewards::id() {
deserialize::<EpochRewards>(data)
.ok()
.map(SysvarAccountType::EpochRewards)
} else {
None
}
Expand All @@ -113,6 +119,7 @@ pub enum SysvarAccountType {
SlotHistory(UiSlotHistory),
StakeHistory(Vec<UiStakeHistoryEntry>),
LastRestartSlot(UiLastRestartSlot),
EpochRewards(EpochRewards),
}

#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Default)]
Expand Down Expand Up @@ -363,5 +370,16 @@ mod test {
last_restart_slot: 1282
})
);

let epoch_rewards = EpochRewards {
total_rewards: 100,
distributed_rewards: 20,
distribution_complete_block_height: 42,
};
let epoch_rewards_sysvar = create_account_for_test(&epoch_rewards);
assert_eq!(
parse_sysvar(&epoch_rewards_sysvar.data, &sysvar::epoch_rewards::id()).unwrap(),
SysvarAccountType::EpochRewards(epoch_rewards),
);
}
}
35 changes: 22 additions & 13 deletions core/src/cluster_info_vote_listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,15 +422,12 @@ impl ClusterInfoVoteListener {
// Always set this to avoid taking the poh lock too often
time_since_lock = Instant::now();
// We will take this lock at most once every `BANK_SEND_VOTES_LOOP_SLEEP_MS`
let current_working_bank = poh_recorder.read().unwrap().bank();
if let Some(current_working_bank) = current_working_bank {
Self::check_for_leader_bank_and_send_votes(
&mut bank_vote_sender_state_option,
current_working_bank,
verified_packets_sender,
&verified_vote_packets,
)?;
}
Self::check_for_leader_bank_and_send_votes(
&mut bank_vote_sender_state_option,
poh_recorder.read().unwrap().bank(),
verified_packets_sender,
&verified_vote_packets,
)?;
// Check if we've crossed the feature boundary
if !is_tower_full_vote_enabled {
is_tower_full_vote_enabled = bank_forks
Expand All @@ -446,10 +443,22 @@ impl ClusterInfoVoteListener {

fn check_for_leader_bank_and_send_votes(
bank_vote_sender_state_option: &mut Option<BankVoteSenderState>,
current_working_bank: Arc<Bank>,
current_working_bank: Option<Arc<Bank>>,
verified_packets_sender: &BankingPacketSender,
verified_vote_packets: &VerifiedVotePackets,
) -> Result<()> {
let current_working_bank = match current_working_bank {
Some(current_working_bank) => current_working_bank,
None => {
// We are not the leader!
if let Some(bank_vote_sender_state) = bank_vote_sender_state_option {
// This ensures we report the last slot's metrics
bank_vote_sender_state.report_metrics();
*bank_vote_sender_state_option = None;
}
return Ok(());
}
};
// We will take this lock at most once every `BANK_SEND_VOTES_LOOP_SLEEP_MS`
if let Some(bank_vote_sender_state) = bank_vote_sender_state_option {
if bank_vote_sender_state.bank.slot() != current_working_bank.slot() {
Expand Down Expand Up @@ -1713,7 +1722,7 @@ mod tests {
// 1) If we hand over a `current_leader_bank`, vote sender state should be updated
ClusterInfoVoteListener::check_for_leader_bank_and_send_votes(
&mut bank_vote_sender_state_option,
current_leader_bank.clone(),
Some(current_leader_bank.clone()),
&verified_packets_sender,
&verified_vote_packets,
)
Expand All @@ -1732,7 +1741,7 @@ mod tests {
// 2) Handing over the same leader bank again should not update the state
ClusterInfoVoteListener::check_for_leader_bank_and_send_votes(
&mut bank_vote_sender_state_option,
current_leader_bank.clone(),
Some(current_leader_bank.clone()),
&verified_packets_sender,
&verified_vote_packets,
)
Expand All @@ -1758,7 +1767,7 @@ mod tests {
));
ClusterInfoVoteListener::check_for_leader_bank_and_send_votes(
&mut bank_vote_sender_state_option,
current_leader_bank.clone(),
Some(current_leader_bank.clone()),
&verified_packets_sender,
&verified_vote_packets,
)
Expand Down
Loading

0 comments on commit f5e9c83

Please sign in to comment.