1
1
#[ cfg( feature = "agave-unstable-api" ) ]
2
+ use crate :: {
3
+ cluster_info:: REFRESH_PUSH_ACTIVE_SET_INTERVAL_MS , stake_weighting_config:: TimeConstant ,
4
+ } ;
5
+ #[ cfg( feature = "agave-unstable-api" ) ]
2
6
use solana_low_pass_filter:: api as lpf;
3
7
use {
4
- crate :: {
5
- cluster_info:: REFRESH_PUSH_ACTIVE_SET_INTERVAL_MS ,
6
- stake_weighting_config:: { TimeConstant , WeightingConfig } ,
7
- weighted_shuffle:: WeightedShuffle ,
8
- } ,
8
+ crate :: { stake_weighting_config:: WeightingConfig , weighted_shuffle:: WeightedShuffle } ,
9
9
indexmap:: IndexMap ,
10
10
rand:: Rng ,
11
11
solana_bloom:: bloom:: { Bloom , ConcurrentBloom } ,
15
15
} ;
16
16
17
17
const NUM_PUSH_ACTIVE_SET_ENTRIES : usize = 25 ;
18
+
19
+ #[ cfg( feature = "agave-unstable-api" ) ]
18
20
const ALPHA_MIN : u64 = lpf:: SCALE . get ( ) ;
21
+ #[ cfg( feature = "agave-unstable-api" ) ]
19
22
const ALPHA_MAX : u64 = 2 * lpf:: SCALE . get ( ) ;
23
+ #[ cfg( feature = "agave-unstable-api" ) ]
20
24
const DEFAULT_ALPHA : u64 = ALPHA_MAX ;
25
+ #[ cfg( feature = "agave-unstable-api" ) ]
21
26
// Low pass filter convergence time (ms)
22
27
const DEFAULT_TC_MS : u64 = 30_000 ;
23
28
@@ -26,6 +31,7 @@ pub enum WeightingMode {
26
31
// alpha = 2.0 -> Quadratic
27
32
Static ,
28
33
// alpha in [1.0, 2.0], smoothed over time, scaled up by 1,000,000 to avoid floating-point math
34
+ #[ cfg( feature = "agave-unstable-api" ) ]
29
35
Dynamic {
30
36
alpha : u64 , // current alpha (fixed-point, 1,000,000–2,000,000)
31
37
filter_k : u64 , // default: 611,000
@@ -37,6 +43,7 @@ impl From<&WeightingConfig> for WeightingMode {
37
43
fn from ( cfg : & WeightingConfig ) -> Self {
38
44
match cfg {
39
45
WeightingConfig :: Static => WeightingMode :: Static ,
46
+ #[ cfg( feature = "agave-unstable-api" ) ]
40
47
WeightingConfig :: Dynamic { tc } => {
41
48
let tc_ms = match tc {
42
49
TimeConstant :: Value ( tc_ms) => * tc_ms,
@@ -49,10 +56,16 @@ impl From<&WeightingConfig> for WeightingMode {
49
56
tc_ms,
50
57
}
51
58
}
59
+ #[ cfg( not( feature = "agave-unstable-api" ) ) ]
60
+ WeightingConfig :: Dynamic { .. } => {
61
+ // When the feature is not enabled, fall back to Static mode
62
+ WeightingMode :: Static
63
+ }
52
64
}
53
65
}
54
66
}
55
67
68
+ #[ cfg( feature = "agave-unstable-api" ) ]
56
69
#[ inline]
57
70
fn get_weight ( bucket : u64 , alpha : u64 ) -> u64 {
58
71
debug_assert ! ( ( ALPHA_MIN ..=ALPHA_MIN + lpf:: SCALE . get( ) ) . contains( & alpha) ) ;
@@ -99,6 +112,7 @@ impl PushActiveSet {
99
112
self . mode = WeightingMode :: Static ;
100
113
}
101
114
}
115
+ #[ cfg( feature = "agave-unstable-api" ) ]
102
116
WeightingConfig :: Dynamic { tc } => {
103
117
let new_tc_ms = match tc {
104
118
TimeConstant :: Value ( tc_ms) => * tc_ms,
@@ -138,6 +152,12 @@ impl PushActiveSet {
138
152
}
139
153
}
140
154
}
155
+ #[ cfg( not( feature = "agave-unstable-api" ) ) ]
156
+ WeightingConfig :: Dynamic { .. } => {
157
+ // When the feature is not enabled, Dynamic config is treated as Static
158
+ // This ensures the code compiles but users don't get the dynamic behavior
159
+ info ! ( "Dynamic weighting config ignored - requires 'agave-unstable-api' feature" ) ;
160
+ }
141
161
}
142
162
}
143
163
}
@@ -193,6 +213,7 @@ impl PushActiveSet {
193
213
// Gossip nodes to be sampled for each push active set.
194
214
nodes : & [ Pubkey ] ,
195
215
stakes : & HashMap < Pubkey , u64 > ,
216
+ #[ cfg_attr( not( feature = "agave-unstable-api" ) , allow( unused_variables) ) ]
196
217
self_pubkey : & Pubkey ,
197
218
) {
198
219
if nodes. is_empty ( ) {
@@ -234,6 +255,7 @@ impl PushActiveSet {
234
255
entry. rotate ( rng, size, num_bloom_filter_items, nodes, & weights) ;
235
256
}
236
257
}
258
+ #[ cfg( feature = "agave-unstable-api" ) ]
237
259
WeightingMode :: Dynamic {
238
260
ref mut alpha,
239
261
filter_k,
@@ -281,28 +303,6 @@ impl PushActiveSet {
281
303
}
282
304
}
283
305
284
- #[ cfg( not( feature = "agave-unstable-api" ) ) ]
285
- mod lpf {
286
- pub const SCALE : std:: num:: NonZeroU64 = std:: num:: NonZeroU64 :: new ( 1000000 ) . unwrap ( ) ;
287
- pub struct FilterConfig {
288
- pub output_range : std:: ops:: Range < u64 > ,
289
- #[ allow( dead_code) ]
290
- pub k : u64 ,
291
- }
292
- pub fn compute_k ( _: u64 , _: u64 ) -> u64 {
293
- 0
294
- }
295
- pub fn filter_alpha ( alpha : u64 , _: u64 , filter_config : FilterConfig ) -> u64 {
296
- alpha. clamp (
297
- filter_config. output_range . start ,
298
- filter_config. output_range . end ,
299
- )
300
- }
301
- pub fn interpolate ( _: u64 , _: u64 ) -> u64 {
302
- 0
303
- }
304
- }
305
-
306
306
impl PushActiveSetEntry {
307
307
const BLOOM_FALSE_RATE : f64 = 0.1 ;
308
308
const BLOOM_MAX_BITS : usize = 1024 * 8 * 4 ;
0 commit comments