|
19 | 19 | contact_info::{self, ContactInfo, ContactInfoQuery, Error as ContactInfoError}, |
20 | 20 | crds::{Crds, Cursor, GossipRoute}, |
21 | 21 | crds_data::{self, CrdsData, EpochSlotsIndex, LowestSlot, SnapshotHashes, Vote, MAX_VOTES}, |
| 22 | + crds_filter::{should_retain_crds_value, GossipFilterDirection, MIN_STAKE_FOR_GOSSIP}, |
22 | 23 | crds_gossip::CrdsGossip, |
23 | 24 | crds_gossip_error::CrdsGossipError, |
24 | 25 | crds_gossip_pull::{ |
@@ -133,11 +134,6 @@ pub const DEFAULT_CONTACT_DEBUG_INTERVAL_MILLIS: u64 = 10_000; |
133 | 134 | pub const DEFAULT_CONTACT_SAVE_INTERVAL_MILLIS: u64 = 60_000; |
134 | 135 | // Limit number of unique pubkeys in the crds table. |
135 | 136 | pub(crate) const CRDS_UNIQUE_PUBKEY_CAPACITY: usize = 8192; |
136 | | -/// Minimum stake that a node should have so that its CRDS values are |
137 | | -/// propagated through gossip (few types are exempted). |
138 | | -const MIN_STAKE_FOR_GOSSIP: u64 = solana_native_token::LAMPORTS_PER_SOL; |
139 | | -/// Minimum number of staked nodes for enforcing stakes in gossip. |
140 | | -const MIN_NUM_STAKED_NODES: usize = 500; |
141 | 137 |
|
142 | 138 | // Must have at least one socket to monitor the TVU port |
143 | 139 | pub const MINIMUM_NUM_TVU_RECEIVE_SOCKETS: NonZeroUsize = NonZeroUsize::new(1).unwrap(); |
@@ -177,42 +173,6 @@ pub struct ClusterInfo { |
177 | 173 | socket_addr_space: SocketAddrSpace, |
178 | 174 | } |
179 | 175 |
|
180 | | -// Returns false if the CRDS value should be discarded. |
181 | | -#[inline] |
182 | | -#[must_use] |
183 | | -fn should_retain_crds_value( |
184 | | - value: &CrdsValue, |
185 | | - stakes: &HashMap<Pubkey, u64>, |
186 | | - drop_unstaked_node_instance: bool, |
187 | | -) -> bool { |
188 | | - match value.data() { |
189 | | - CrdsData::ContactInfo(_) => true, |
190 | | - CrdsData::LegacyContactInfo(_) => true, |
191 | | - // May Impact new validators starting up without any stake yet. |
192 | | - CrdsData::Vote(_, _) => true, |
193 | | - // Unstaked nodes can still help repair. |
194 | | - CrdsData::EpochSlots(_, _) => true, |
195 | | - // Unstaked nodes can still serve snapshots. |
196 | | - CrdsData::LegacySnapshotHashes(_) | CrdsData::SnapshotHashes(_) => true, |
197 | | - // Otherwise unstaked voting nodes will show up with no version in |
198 | | - // the various dashboards. |
199 | | - CrdsData::Version(_) => true, |
200 | | - CrdsData::AccountsHashes(_) => true, |
201 | | - CrdsData::NodeInstance(_) if !drop_unstaked_node_instance => true, |
202 | | - CrdsData::LowestSlot(_, _) |
203 | | - | CrdsData::LegacyVersion(_) |
204 | | - | CrdsData::DuplicateShred(_, _) |
205 | | - | CrdsData::RestartHeaviestFork(_) |
206 | | - | CrdsData::RestartLastVotedForkSlots(_) |
207 | | - | CrdsData::NodeInstance(_) => { |
208 | | - stakes.len() < MIN_NUM_STAKED_NODES || { |
209 | | - let stake = stakes.get(&value.pubkey()).copied(); |
210 | | - stake.unwrap_or_default() >= MIN_STAKE_FOR_GOSSIP |
211 | | - } |
212 | | - } |
213 | | - } |
214 | | -} |
215 | | - |
216 | 176 | impl ClusterInfo { |
217 | 177 | pub fn new( |
218 | 178 | contact_info: ContactInfo, |
@@ -1282,9 +1242,7 @@ impl ClusterInfo { |
1282 | 1242 | self.flush_push_queue(); |
1283 | 1243 | self.gossip |
1284 | 1244 | .new_push_messages(&self_id, timestamp(), stakes, |value| { |
1285 | | - should_retain_crds_value( |
1286 | | - value, stakes, /*drop_unstaked_node_instance:*/ false, |
1287 | | - ) |
| 1245 | + should_retain_crds_value(value, stakes, GossipFilterDirection::EgressPush) |
1288 | 1246 | }) |
1289 | 1247 | }; |
1290 | 1248 | self.stats |
@@ -1692,7 +1650,9 @@ impl ClusterInfo { |
1692 | 1650 | now, |
1693 | 1651 | |value| { |
1694 | 1652 | should_retain_crds_value( |
1695 | | - value, stakes, /*drop_unstaked_node_instance:*/ true, |
| 1653 | + value, |
| 1654 | + stakes, |
| 1655 | + GossipFilterDirection::EgressPullResponse, |
1696 | 1656 | ) |
1697 | 1657 | }, |
1698 | 1658 | self.my_shred_version(), |
@@ -2132,9 +2092,7 @@ impl ClusterInfo { |
2132 | 2092 | &mut protocol |
2133 | 2093 | { |
2134 | 2094 | values.retain(|value| { |
2135 | | - should_retain_crds_value( |
2136 | | - value, stakes, /*drop_unstaked_node_instance:*/ false, |
2137 | | - ) |
| 2095 | + should_retain_crds_value(value, stakes, GossipFilterDirection::Ingress) |
2138 | 2096 | }); |
2139 | 2097 | if values.is_empty() { |
2140 | 2098 | return None; |
@@ -3003,7 +2961,7 @@ fn verify_gossip_addr<R: Rng + CryptoRng>( |
3003 | 2961 | _ => return true, // If not a contact-info, nothing to verify. |
3004 | 2962 | }; |
3005 | 2963 | // For (sufficiently) staked nodes, don't bother with ping/pong. |
3006 | | - if stakes.get(pubkey) >= Some(&MIN_STAKE_FOR_GOSSIP) { |
| 2964 | + if stakes.get(pubkey).copied() >= Some(MIN_STAKE_FOR_GOSSIP) { |
3007 | 2965 | return true; |
3008 | 2966 | } |
3009 | 2967 | // Invalid addresses are not verifiable. |
|
0 commit comments