Line data Source code
1 : #ifndef HEADER_fd_src_flamenco_runtime_fd_slot_params_h
2 : #define HEADER_fd_src_flamenco_runtime_fd_slot_params_h
3 :
4 : #include "../fd_flamenco_base.h"
5 :
6 : /* fd_slot_params groups the runtime parameters that move together when
7 : the slot time changes due to the reduce_slot_time feature gates as
8 : described in SIMD-525.
9 :
10 : Slot time reductions happen in 50ms increments, each with a separate
11 : feature gate:
12 : reduce_slot_time_to_350ms
13 : reduce_slot_time_to_300ms
14 : reduce_slot_time_to_250ms
15 : reduce_slot_time_to_200ms
16 :
17 : Note that these feature gates take effect an epoch after they
18 : have been activated, because they affect the turbine shred filtering
19 : rules. */
20 :
21 : /* https://github.com/anza-xyz/agave/blob/v4.2/runtime/src/slot_params.rs#L13 */
22 3771 : #define FD_DEFAULT_MAX_ENTRY_BYTES_PER_SLOT (20UL*1024UL*1024UL) /* 20 MiB */
23 :
24 : /* https://github.com/anza-xyz/agave/blob/v4.2/runtime/src/slot_params.rs#L122 */
25 3771 : #define FD_LEGACY_HASHES_PER_TICK (62500UL)
26 :
27 : /* In order to hit the target slot time, when producing blocks we
28 : subtract a fixed overhead amount to compensate for time spent
29 : outside of block production itself, such as network propagation.
30 :
31 : 50ms is used to match Agave's behaviour:
32 : https://github.com/anza-xyz/agave/blob/v4.2/poh/src/poh_service.rs#L47 */
33 3846 : #define FD_TARGET_SLOT_ADJUSTMENT_NS (50000000UL)
34 :
35 : /* Runtime parameters that need to change when the slot time changes
36 : due to one of the reduce_slot_time feature gates.
37 :
38 : https://github.com/anza-xyz/agave/blob/v4.2/runtime/src/slot_params.rs#L20-L30 */
39 :
40 : struct fd_slot_params {
41 : ulong ns_per_slot;
42 : ulong ns_per_slot_adjusted;
43 : double slots_per_year;
44 : ulong hashes_per_tick;
45 : ulong max_block_units;
46 : ulong max_writable_account_units;
47 : ulong max_block_accounts_data_size_delta;
48 : ulong max_shred_idx;
49 : ulong max_entry_bytes_per_slot;
50 : ulong stake_account_stores_per_block;
51 : };
52 : typedef struct fd_slot_params fd_slot_params_t;
53 :
54 : /* https://github.com/anza-xyz/agave/blob/v4.2/runtime/src/slot_params.rs#L123-L133 */
55 3771 : #define FD_SLOT_PARAMS_400MS ((fd_slot_params_t){ \
56 3771 : .ns_per_slot = 400000000UL, \
57 3771 : .ns_per_slot_adjusted = 400000000UL-FD_TARGET_SLOT_ADJUSTMENT_NS, \
58 3771 : .slots_per_year = 78892314.984, \
59 3771 : .hashes_per_tick = FD_LEGACY_HASHES_PER_TICK, \
60 3771 : .max_block_units = 60000000UL, \
61 3771 : .max_writable_account_units = 24000000UL, \
62 3771 : .max_block_accounts_data_size_delta = 100000000UL, \
63 3771 : .max_shred_idx = 32768UL, \
64 3771 : .max_entry_bytes_per_slot = FD_DEFAULT_MAX_ENTRY_BYTES_PER_SLOT, \
65 3771 : .stake_account_stores_per_block = 4096UL, \
66 3771 : })
67 :
68 : /* https://github.com/anza-xyz/agave/blob/v4.2/runtime/src/slot_params.rs#L135-L145 */
69 15 : #define FD_SLOT_PARAMS_350MS ((fd_slot_params_t){ \
70 15 : .ns_per_slot = 350000000UL, \
71 15 : .ns_per_slot_adjusted = 350000000UL-FD_TARGET_SLOT_ADJUSTMENT_NS, \
72 15 : .slots_per_year = 90162645.696, \
73 15 : .hashes_per_tick = 54687UL, \
74 15 : .max_block_units = 52500000UL, \
75 15 : .max_writable_account_units = 21000000UL, \
76 15 : .max_block_accounts_data_size_delta = 87500000UL, \
77 15 : .max_shred_idx = 28672UL, \
78 15 : .max_entry_bytes_per_slot = 18350080UL, \
79 15 : .stake_account_stores_per_block = 3584UL, \
80 15 : })
81 :
82 : /* https://github.com/anza-xyz/agave/blob/v4.2/runtime/src/slot_params.rs#L147-L157 */
83 18 : #define FD_SLOT_PARAMS_300MS ((fd_slot_params_t){ \
84 18 : .ns_per_slot = 300000000UL, \
85 18 : .ns_per_slot_adjusted = 300000000UL-FD_TARGET_SLOT_ADJUSTMENT_NS, \
86 18 : .slots_per_year = 105189753.312, \
87 18 : .hashes_per_tick = 46875UL, \
88 18 : .max_block_units = 45000000UL, \
89 18 : .max_writable_account_units = 18000000UL, \
90 18 : .max_block_accounts_data_size_delta = 75000000UL, \
91 18 : .max_shred_idx = 24576UL, \
92 18 : .max_entry_bytes_per_slot = 15728640UL, \
93 18 : .stake_account_stores_per_block = 3072UL, \
94 18 : })
95 :
96 : /* https://github.com/anza-xyz/agave/blob/v4.2/runtime/src/slot_params.rs#L159-L169 */
97 9 : #define FD_SLOT_PARAMS_250MS ((fd_slot_params_t){ \
98 9 : .ns_per_slot = 250000000UL, \
99 9 : .ns_per_slot_adjusted = 250000000UL-FD_TARGET_SLOT_ADJUSTMENT_NS, \
100 9 : .slots_per_year = 126227703.974, \
101 9 : .hashes_per_tick = 39062UL, \
102 9 : .max_block_units = 37500000UL, \
103 9 : .max_writable_account_units = 15000000UL, \
104 9 : .max_block_accounts_data_size_delta = 62500000UL, \
105 9 : .max_shred_idx = 20480UL, \
106 9 : .max_entry_bytes_per_slot = 13107200UL, \
107 9 : .stake_account_stores_per_block = 2560UL, \
108 9 : })
109 :
110 : /* https://github.com/anza-xyz/agave/blob/v4.2/runtime/src/slot_params.rs#L171-L181 */
111 27 : #define FD_SLOT_PARAMS_200MS ((fd_slot_params_t){ \
112 27 : .ns_per_slot = 200000000UL, \
113 27 : .ns_per_slot_adjusted = 200000000UL-FD_TARGET_SLOT_ADJUSTMENT_NS, \
114 27 : .slots_per_year = 157784629.968, \
115 27 : .hashes_per_tick = 31250UL, \
116 27 : .max_block_units = 30000000UL, \
117 27 : .max_writable_account_units = 12000000UL, \
118 27 : .max_block_accounts_data_size_delta = 50000000UL, \
119 27 : .max_shred_idx = 16384UL, \
120 27 : .max_entry_bytes_per_slot = 10485760UL, \
121 27 : .stake_account_stores_per_block = 2048UL, \
122 27 : })
123 :
124 : FD_PROTOTYPES_BEGIN
125 :
126 : /* fd_slot_params_at_slot returns the effective slot params at the given
127 : slot, using the bank's default params, features, and epoch schedule.
128 :
129 : This takes into account the fact that the reduce_slot_time feature
130 : gates take effect an epoch after they have been activated.
131 :
132 : https://github.com/anza-xyz/agave/blob/v4.2/runtime/src/slot_params.rs#L241-L286 */
133 :
134 : fd_slot_params_t
135 : fd_slot_params_at_slot( fd_bank_t const * bank,
136 : ulong slot );
137 :
138 : /* fd_slot_params_lookup returns the effective slot params at the given
139 : slot, using the given default params, features, and epoch schedule.
140 :
141 : This takes into account the fact that the reduce_slot_time feature
142 : gates take effect an epoch after they have been activated. */
143 :
144 : fd_slot_params_t
145 : fd_slot_params_lookup( fd_slot_params_t const * default_params,
146 : fd_features_t const * features,
147 : fd_epoch_schedule_t const * epoch_schedule,
148 : ulong slot );
149 :
150 : /* fd_slot_params_effective_slot returns the slot at which the given
151 : slot params regime takes effect. */
152 :
153 : ulong
154 : fd_slot_params_effective_slot( fd_slot_params_t const * params,
155 : fd_features_t const * features,
156 : fd_epoch_schedule_t const * epoch_schedule );
157 :
158 : /* fd_slot_params_next_effective_slot returns the slot at which the next
159 : slot params regime after the given one takes effect. */
160 :
161 : ulong
162 : fd_slot_params_next_effective_slot( fd_slot_params_t const * params,
163 : fd_features_t const * features,
164 : fd_epoch_schedule_t const * epoch_schedule );
165 :
166 : /* fd_slot_params_slot_range_duration_ns returns the duration in
167 : nanoseconds for the slot range [start_slot, end_slot),
168 : taking into account any reduce_slot_time feature gate activations
169 : between the two slots.
170 :
171 : This is equivalent to Agave's slot_range_duration_nanos
172 : https://github.com/anza-xyz/agave/blob/v4.2/runtime/src/slot_params.rs#L295-L320 */
173 :
174 : FD_FN_PURE ulong
175 : fd_slot_params_slot_range_duration_ns( fd_bank_t const * bank,
176 : ulong start_slot,
177 : ulong end_slot );
178 :
179 : /* fd_slot_params_slot_range_duration_years returns the duration in
180 : years for the slot range [start_slot, end_slot), taking into
181 : account any reduce_slot_time feature gate activations between the
182 : two slots.
183 :
184 : This is equivalent to Agave's slot_range_duration_in_years:
185 : https://github.com/anza-xyz/agave/blob/v4.2/runtime/src/bank.rs#L2850-L2874 */
186 :
187 : FD_FN_PURE double
188 : fd_slot_params_slot_range_duration_years( fd_bank_t const * bank,
189 : ulong start_slot,
190 : ulong end_slot );
191 :
192 : FD_PROTOTYPES_END
193 :
194 : #endif /* HEADER_fd_src_flamenco_runtime_fd_slot_params_h */
|