From d62018a99fba6833ae2fb5c69e7cc2d999b4769c Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Tue, 29 Aug 2023 01:38:48 +0000 Subject: [PATCH] v1.14: revises turbine epoch stakes for shreds propagation (backport of #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 d5c2dacd07f13a39ff9c79d873b96d816c40743d) # Conflicts: # sdk/src/feature_set.rs * resolves mergify merge conflicts --------- Co-authored-by: behzad nouri --- core/src/cluster_nodes.rs | 16 ++++++++++++++-- sdk/src/feature_set.rs | 5 +++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/core/src/cluster_nodes.rs b/core/src/cluster_nodes.rs index 3e13c821c30bdb..f87cfe585b42d8 100644 --- a/core/src/cluster_nodes.rs +++ b/core/src/cluster_nodes.rs @@ -419,7 +419,7 @@ impl ClusterNodesCache { working_bank: &Bank, cluster_info: &ClusterInfo, ) -> Arc> { - 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. @@ -434,7 +434,7 @@ impl ClusterNodesCache { .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); @@ -448,6 +448,18 @@ impl ClusterNodesCache { } } +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 for NodeId { fn from(node: ContactInfo) -> Self { NodeId::ContactInfo(node) diff --git a/sdk/src/feature_set.rs b/sdk/src/feature_set.rs index e2a9835ab92862..efd353ba1640a2 100644 --- a/sdk/src/feature_set.rs +++ b/sdk/src/feature_set.rs @@ -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 = [ @@ -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()