Skip to content

Commit

Permalink
v1.14: revises turbine epoch stakes for shreds propagation (backport of
Browse files Browse the repository at this point in the history
#32743) (#33040)

* revises turbine epoch stakes for shreds propagation (#32743)

Bank::get_leader_schedule_epoch returns: 1 + EpochSchedule::get_epoch.
As a result, at the epoch boundaries when the propagated shred is from
the next epoch, we are looking for epoch stakes for 2 epochs ahead of
the root or working bank's epoch.
However, the bank structure only contains epoch stakes for one epoch
ahead. This results in shreds propagated at epoch boundary having
unknown epoch stakes.

(cherry picked from commit d5c2dac)

# Conflicts:
#	sdk/src/feature_set.rs

* resolves mergify merge conflicts

---------

Co-authored-by: behzad nouri <[email protected]>
  • Loading branch information
mergify[bot] and behzadnouri authored Aug 29, 2023
1 parent a869a17 commit d62018a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
16 changes: 14 additions & 2 deletions core/src/cluster_nodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ impl<T: 'static> ClusterNodesCache<T> {
working_bank: &Bank,
cluster_info: &ClusterInfo,
) -> Arc<ClusterNodes<T>> {
let epoch = root_bank.get_leader_schedule_epoch(shred_slot);
let epoch = get_epoch(shred_slot, root_bank);
let entry = self.get_cache_entry(epoch);
// Hold the lock on the entry here so that, if needed, only
// one thread recomputes cluster-nodes for this epoch.
Expand All @@ -434,7 +434,7 @@ impl<T: 'static> ClusterNodesCache<T> {
.find_map(|bank| bank.epoch_staked_nodes(epoch));
if epoch_staked_nodes.is_none() {
inc_new_counter_debug!("cluster_nodes-unknown_epoch_staked_nodes", 1);
if epoch != root_bank.get_leader_schedule_epoch(root_bank.slot()) {
if epoch != get_epoch(root_bank.slot(), root_bank) {
return self.get(root_bank.slot(), root_bank, working_bank, cluster_info);
}
inc_new_counter_info!("cluster_nodes-unknown_epoch_staked_nodes_root", 1);
Expand All @@ -448,6 +448,18 @@ impl<T: 'static> ClusterNodesCache<T> {
}
}

fn get_epoch(shred_slot: Slot, root_bank: &Bank) -> Epoch {
if check_feature_activation(
&feature_set::revise_turbine_epoch_stakes::id(),
shred_slot,
root_bank,
) {
root_bank.epoch_schedule().get_epoch(shred_slot)
} else {
root_bank.get_leader_schedule_epoch(shred_slot)
}
}

impl From<ContactInfo> for NodeId {
fn from(node: ContactInfo) -> Self {
NodeId::ContactInfo(node)
Expand Down
5 changes: 5 additions & 0 deletions sdk/src/feature_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,10 @@ pub mod clean_up_delegation_errors {
solana_sdk::declare_id!("Bj2jmUsM2iRhfdLLDSTkhM5UQRQvQHm57HSmPibPtEyu");
}

pub mod revise_turbine_epoch_stakes {
solana_sdk::declare_id!("BTWmtJC8U5ZLMbBUUA1k6As62sYjPEjAiNAT55xYGdJU");
}

lazy_static! {
/// Map of feature identifiers to user-visible description
pub static ref FEATURE_NAMES: HashMap<Pubkey, &'static str> = [
Expand Down Expand Up @@ -684,6 +688,7 @@ lazy_static! {
(disable_builtin_loader_ownership_chains::id(), "disable builtin loader ownership chains #29956"),
(enable_request_heap_frame_ix::id(), "Enable transaction to request heap frame using compute budget instruction #30076"),
(clean_up_delegation_errors::id(), "Return InsufficientDelegation instead of InsufficientFunds or InsufficientStake where applicable #31206"),
(revise_turbine_epoch_stakes::id(), "revise turbine epoch stakes"),
/*************** ADD NEW FEATURES HERE ***************/
]
.iter()
Expand Down

0 comments on commit d62018a

Please sign in to comment.