Line data Source code
1 : #include "../../util/pod/fd_pod_format.h"
2 :
3 : #include "../../disco/topo/fd_topo.h"
4 : #include "../../disco/store/fd_store.h"
5 : #include "../../flamenco/runtime/fd_bank.h"
6 : #include "../../flamenco/runtime/fd_txncache_shmem.h"
7 : #include "../../flamenco/progcache/fd_progcache.h"
8 : #include "../../flamenco/runtime/fd_bpf_frames.h"
9 : #include "../../flamenco/alpenglow/fd_footer_cache.h"
10 : #include "../../disco/shred/fd_rnonce_ss.h"
11 : #include "../../discof/backup/fd_backup_shmem.h"
12 :
13 : #include "../../discof/admin/fd_adminctl.h"
14 :
15 0 : #define VAL(name) (__extension__({ \
16 0 : ulong __x = fd_pod_queryf_ulong( topo->props, ULONG_MAX, "obj.%lu.%s", obj->id, name ); \
17 0 : if( FD_UNLIKELY( __x==ULONG_MAX ) ) FD_LOG_ERR(( "obj.%lu.%s was not set", obj->id, name )); \
18 0 : __x; }))
19 :
20 : static ulong
21 : banks_footprint( fd_topo_t const * topo,
22 0 : fd_topo_obj_t const * obj ) {
23 0 : return fd_banks_footprint( VAL("max_live_slots"), VAL("cache_cnt"), VAL("stake_delegation_cache_cnt"), FD_RUNTIME_MAX_VAT_VOTE_ACCOUNTS );
24 0 : }
25 :
26 : static ulong
27 : banks_align( fd_topo_t const * topo FD_FN_UNUSED,
28 0 : fd_topo_obj_t const * obj FD_FN_UNUSED ) {
29 0 : return fd_banks_align();
30 0 : }
31 :
32 : static void
33 : banks_new( fd_topo_t const * topo,
34 0 : fd_topo_obj_t const * obj ) {
35 0 : ulong seed = fd_pod_queryf_ulong( topo->props, 0UL, "obj.%lu.seed", obj->id );
36 0 : FD_TEST( fd_banks_new( fd_topo_obj_laddr( topo, obj->id ), FD_STAKE_DELEGATIONS_FD, VAL("max_live_slots"), VAL("cache_cnt"), VAL("stake_delegation_cache_cnt"), FD_RUNTIME_MAX_STAKE_DELEGATION_DISK_RECORDS, FD_RUNTIME_MAX_VAT_VOTE_ACCOUNTS, VAL("bench_max_cost_per_block"), seed ) );
37 0 : }
38 :
39 : fd_topo_obj_callbacks_t fd_obj_cb_banks = {
40 : .name = "banks",
41 : .footprint = banks_footprint,
42 : .align = banks_align,
43 : .new = banks_new,
44 : };
45 :
46 : static ulong
47 : progcache_align( fd_topo_t const * topo,
48 0 : fd_topo_obj_t const * obj ) {
49 0 : (void)topo; (void)obj;
50 0 : return fd_progcache_shmem_align();
51 0 : }
52 :
53 : static ulong
54 : progcache_footprint( fd_topo_t const * topo,
55 0 : fd_topo_obj_t const * obj ) {
56 0 : return fd_progcache_shmem_footprint( VAL("txn_max"), VAL("progcache_sz") );
57 0 : }
58 :
59 : static void
60 : progcache_new( fd_topo_t const * topo,
61 0 : fd_topo_obj_t const * obj ) {
62 0 : ulong seed = fd_pod_queryf_ulong( topo->props, 0UL, "obj.%lu.seed", obj->id );
63 0 : if( !seed ) FD_TEST( fd_rng_secure( &seed, sizeof(ulong) ) );
64 0 : FD_TEST( fd_progcache_shmem_new( fd_topo_obj_laddr( topo, obj->id ), 2UL, seed, VAL("txn_max"), VAL("progcache_sz") ) );
65 0 : }
66 :
67 : fd_topo_obj_callbacks_t fd_obj_cb_progcache = {
68 : .name = "progcache",
69 : .footprint = progcache_footprint,
70 : .align = progcache_align,
71 : .new = progcache_new,
72 : };
73 :
74 : static ulong
75 : bpf_frames_align( fd_topo_t const * topo,
76 0 : fd_topo_obj_t const * obj ) {
77 0 : (void)topo; (void)obj;
78 0 : return fd_bpf_frames_shmem_align();
79 0 : }
80 :
81 : static ulong
82 : bpf_frames_footprint( fd_topo_t const * topo,
83 0 : fd_topo_obj_t const * obj ) {
84 0 : return fd_bpf_frames_shmem_footprint( VAL("frame_cnt"), VAL("joiner_cnt_max"), VAL("local_cnt") );
85 0 : }
86 :
87 : static void
88 : bpf_frames_new( fd_topo_t const * topo,
89 0 : fd_topo_obj_t const * obj ) {
90 0 : FD_TEST( fd_bpf_frames_shmem_new( fd_topo_obj_laddr( topo, obj->id ), VAL("frame_cnt"), VAL("joiner_cnt_max"), VAL("local_cnt") ) );
91 0 : }
92 :
93 : fd_topo_obj_callbacks_t fd_obj_cb_bpf_frames = {
94 : .name = "bpf_frames",
95 : .footprint = bpf_frames_footprint,
96 : .align = bpf_frames_align,
97 : .new = bpf_frames_new,
98 : };
99 :
100 : /* adminctl: admin tile command channel */
101 :
102 : static ulong
103 : adminctl_align( fd_topo_t const * topo,
104 0 : fd_topo_obj_t const * obj ) {
105 0 : (void)topo; (void)obj;
106 0 : return fd_adminctl_align();
107 0 : }
108 :
109 : static ulong
110 : adminctl_footprint( fd_topo_t const * topo,
111 0 : fd_topo_obj_t const * obj ) {
112 0 : (void)topo; (void)obj;
113 0 : return fd_adminctl_footprint();
114 0 : }
115 :
116 : static void
117 : adminctl_new( fd_topo_t const * topo,
118 0 : fd_topo_obj_t const * obj ) {
119 0 : FD_TEST( fd_adminctl_new( fd_topo_obj_laddr( topo, obj->id ) ) );
120 0 : }
121 :
122 : fd_topo_obj_callbacks_t fd_obj_cb_adminctl = {
123 : .name = "adminctl",
124 : .footprint = adminctl_footprint,
125 : .align = adminctl_align,
126 : .new = adminctl_new,
127 : };
128 :
129 : static ulong
130 : fec_sets_footprint( fd_topo_t const * topo,
131 0 : fd_topo_obj_t const * obj ) {
132 0 : return VAL("sz");
133 0 : }
134 :
135 : static ulong
136 : fec_sets_align( fd_topo_t const * topo FD_FN_UNUSED,
137 0 : fd_topo_obj_t const * obj FD_FN_UNUSED ) {
138 0 : return fd_dcache_align();
139 0 : }
140 :
141 : static void
142 : fec_sets_new( FD_PARAM_UNUSED fd_topo_t const * topo,
143 0 : FD_PARAM_UNUSED fd_topo_obj_t const * obj ) {
144 0 : FD_TEST( fd_topo_obj_laddr( topo, obj->id ) );
145 0 : }
146 :
147 : fd_topo_obj_callbacks_t fd_obj_cb_fec_sets = {
148 : .name = "fec_sets",
149 : .footprint = fec_sets_footprint,
150 : .align = fec_sets_align,
151 : .new = fec_sets_new,
152 : };
153 :
154 : static ulong
155 : store_footprint( fd_topo_t const * topo,
156 0 : fd_topo_obj_t const * obj ) {
157 0 : return fd_store_footprint( VAL("fec_max"), VAL("fec_data_max"), VAL("shred_storage_gib"), VAL("shred_cache_bytes"), VAL("fec_set_cnt"), VAL("shred_tile_cnt") );
158 0 : }
159 :
160 : static ulong
161 : store_align( fd_topo_t const * topo FD_FN_UNUSED,
162 0 : fd_topo_obj_t const * obj FD_FN_UNUSED ) {
163 0 : return fd_store_align();
164 0 : }
165 :
166 : static void
167 : store_new( fd_topo_t const * topo,
168 0 : fd_topo_obj_t const * obj ) {
169 0 : ulong disk_seed = fd_pod_queryf_ulong( topo->props, 0UL, "obj.%lu.seed", obj->id );
170 0 : FD_TEST( fd_store_new( fd_topo_obj_laddr( topo, obj->id ),
171 0 : VAL("fec_max"), VAL("fec_data_max"),
172 0 : VAL("shred_storage_gib"), VAL("shred_cache_bytes"),
173 0 : VAL("fec_set_cnt"), VAL("max_shreds_per_block"),
174 0 : disk_seed, VAL("shred_tile_cnt") ) );
175 0 : }
176 :
177 : fd_topo_obj_callbacks_t fd_obj_cb_store = {
178 : .name = "store",
179 : .footprint = store_footprint,
180 : .align = store_align,
181 : .new = store_new,
182 : };
183 :
184 : static ulong
185 : accdb_footprint( fd_topo_t const * topo,
186 0 : fd_topo_obj_t const * obj ) {
187 0 : return fd_accdb_shmem_footprint( VAL("max_accounts"), VAL("max_live_slots"), VAL("max_account_writes_per_slot"), VAL("partition_cnt"), VAL("cache_footprint"), VAL("cache_min_reserved"), VAL("joiner_cnt"), VAL("max_incremental_accounts") );
188 0 : }
189 :
190 : static ulong
191 : accdb_align( fd_topo_t const * topo FD_FN_UNUSED,
192 0 : fd_topo_obj_t const * obj FD_FN_UNUSED ) {
193 0 : return fd_accdb_shmem_align();
194 0 : }
195 :
196 : static void
197 : accdb_new( fd_topo_t const * topo,
198 0 : fd_topo_obj_t const * obj ) {
199 0 : FD_TEST( fd_accdb_shmem_new( fd_topo_obj_laddr( topo, obj->id ), VAL("max_accounts"), VAL("max_live_slots"), VAL("max_account_writes_per_slot"), VAL("partition_cnt"), VAL("partition_sz"), VAL("cache_footprint"), VAL("cache_min_reserved"), (int)VAL("bundle_enabled"), VAL("seed"), VAL("joiner_cnt"), VAL("max_incremental_accounts") ) );
200 0 : }
201 :
202 : fd_topo_obj_callbacks_t fd_obj_cb_accdb = {
203 : .name = "accdb",
204 : .footprint = accdb_footprint,
205 : .align = accdb_align,
206 : .new = accdb_new,
207 : };
208 :
209 : static ulong
210 : txncache_footprint( fd_topo_t const * topo,
211 0 : fd_topo_obj_t const * obj ) {
212 0 : return fd_txncache_shmem_footprint( VAL("max_live_slots"), VAL("max_txn_per_slot"), VAL("cache_footprint") );
213 0 : }
214 :
215 : static ulong
216 : txncache_align( fd_topo_t const * topo FD_FN_UNUSED,
217 0 : fd_topo_obj_t const * obj FD_FN_UNUSED ) {
218 0 : return fd_txncache_shmem_align();
219 0 : }
220 :
221 : static void
222 : txncache_new( fd_topo_t const * topo,
223 0 : fd_topo_obj_t const * obj ) {
224 0 : FD_TEST( fd_txncache_shmem_new( fd_topo_obj_laddr( topo, obj->id ), VAL("max_live_slots"), VAL("max_txn_per_slot"), VAL("cache_footprint"), VAL("seed") ) );
225 0 : }
226 :
227 : fd_topo_obj_callbacks_t fd_obj_cb_txncache = {
228 : .name = "txncache",
229 : .footprint = txncache_footprint,
230 : .align = txncache_align,
231 : .new = txncache_new,
232 : };
233 :
234 : static ulong
235 : footer_cache_footprint( fd_topo_t const * topo FD_FN_UNUSED,
236 0 : fd_topo_obj_t const * obj FD_FN_UNUSED ) {
237 0 : return fd_footer_cache_footprint();
238 0 : }
239 :
240 : static ulong
241 : footer_cache_align( fd_topo_t const * topo FD_FN_UNUSED,
242 0 : fd_topo_obj_t const * obj FD_FN_UNUSED ) {
243 0 : return fd_footer_cache_align();
244 0 : }
245 :
246 : static void
247 : footer_cache_new( fd_topo_t const * topo,
248 0 : fd_topo_obj_t const * obj ) {
249 0 : FD_TEST( fd_footer_cache_new( fd_topo_obj_laddr( topo, obj->id ) ) );
250 0 : }
251 :
252 : fd_topo_obj_callbacks_t fd_obj_cb_footer_cache = {
253 : .name = "footer_cache",
254 : .footprint = footer_cache_footprint,
255 : .align = footer_cache_align,
256 : .new = footer_cache_new,
257 : };
258 :
259 : static ulong
260 : rnonce_ss_footprint( fd_topo_t const * topo FD_FN_UNUSED,
261 0 : fd_topo_obj_t const * obj FD_FN_UNUSED ) {
262 0 : return sizeof(fd_rnonce_ss_t);
263 0 : }
264 :
265 : static ulong
266 : rnonce_ss_align( fd_topo_t const * topo FD_FN_UNUSED,
267 0 : fd_topo_obj_t const * obj FD_FN_UNUSED ) {
268 0 : return alignof(fd_rnonce_ss_t);
269 0 : }
270 :
271 : static void
272 : rnonce_ss_new( fd_topo_t const * topo,
273 0 : fd_topo_obj_t const * obj ) {
274 0 : FD_TEST( fd_rng_secure( fd_topo_obj_laddr( topo, obj->id ), sizeof(fd_rnonce_ss_t) ) );
275 0 : }
276 :
277 : fd_topo_obj_callbacks_t fd_obj_cb_rnonce_ss = {
278 : .name = "rnonce_ss",
279 : .footprint = rnonce_ss_footprint,
280 : .align = rnonce_ss_align,
281 : .new = rnonce_ss_new,
282 : };
283 :
284 : static ulong
285 : backup_footprint_cb( fd_topo_t const * topo,
286 0 : fd_topo_obj_t const * obj ) {
287 0 : return fd_backup_footprint( VAL("max_accounts") );
288 0 : }
289 :
290 : static ulong
291 : backup_align_cb( fd_topo_t const * topo FD_FN_UNUSED,
292 0 : fd_topo_obj_t const * obj FD_FN_UNUSED ) {
293 0 : return fd_backup_align();
294 0 : }
295 :
296 : static void
297 : backup_new_cb( fd_topo_t const * topo,
298 0 : fd_topo_obj_t const * obj ) {
299 0 : FD_TEST( fd_backup_new( fd_topo_obj_laddr( topo, obj->id ), VAL("max_accounts") ) );
300 0 : }
301 :
302 : fd_topo_obj_callbacks_t fd_obj_cb_backup = {
303 : .name = "backup",
304 : .footprint = backup_footprint_cb,
305 : .align = backup_align_cb,
306 : .new = backup_new_cb,
307 : };
308 :
309 : #undef VAL
|