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_acc_pool.h"
7 : #include "../../flamenco/runtime/fd_txncache_shmem.h"
8 : #include "../../flamenco/progcache/fd_progcache.h"
9 : #include "../../funk/fd_funk.h"
10 : #include "../../disco/shred/fd_rnonce_ss.h"
11 :
12 0 : #define VAL(name) (__extension__({ \
13 0 : ulong __x = fd_pod_queryf_ulong( topo->props, ULONG_MAX, "obj.%lu.%s", obj->id, name ); \
14 0 : if( FD_UNLIKELY( __x==ULONG_MAX ) ) FD_LOG_ERR(( "obj.%lu.%s was not set", obj->id, name )); \
15 0 : __x; }))
16 :
17 : static ulong
18 : banks_locks_footprint( fd_topo_t const * topo FD_PARAM_UNUSED,
19 0 : fd_topo_obj_t const * obj FD_PARAM_UNUSED ) {
20 0 : return sizeof(fd_banks_locks_t);
21 0 : }
22 :
23 : static ulong
24 : banks_locks_align( fd_topo_t const * topo FD_PARAM_UNUSED,
25 0 : fd_topo_obj_t const * obj FD_PARAM_UNUSED ) {
26 0 : return alignof(fd_banks_locks_t);
27 0 : }
28 :
29 : static void
30 : banks_locks_new( fd_topo_t const * topo,
31 0 : fd_topo_obj_t const * obj ) {
32 0 : fd_banks_locks_init( fd_topo_obj_laddr( topo, obj->id ) );
33 0 : }
34 :
35 : fd_topo_obj_callbacks_t fd_obj_cb_banks_locks = {
36 : .name = "banks_locks",
37 : .footprint = banks_locks_footprint,
38 : .align = banks_locks_align,
39 : .new = banks_locks_new,
40 : };
41 :
42 : static ulong
43 : banks_footprint( fd_topo_t const * topo,
44 0 : fd_topo_obj_t const * obj ) {
45 0 : return fd_banks_footprint( VAL("max_live_slots"), VAL("max_fork_width"), FD_RUNTIME_MAX_STAKE_ACCOUNTS, FD_RUNTIME_MAX_VOTE_ACCOUNTS );
46 0 : }
47 :
48 : static ulong
49 : banks_align( fd_topo_t const * topo FD_FN_UNUSED,
50 0 : fd_topo_obj_t const * obj FD_FN_UNUSED ) {
51 0 : return fd_banks_align();
52 0 : }
53 :
54 : static void
55 : banks_new( fd_topo_t const * topo,
56 0 : fd_topo_obj_t const * obj ) {
57 0 : int larger_max_cost_per_block = fd_pod_queryf_int( topo->props, 0, "obj.%lu.larger_max_cost_per_block", obj->id );
58 0 : ulong seed = fd_pod_queryf_ulong( topo->props, 0UL, "obj.%lu.seed", obj->id );
59 0 : FD_TEST( fd_banks_new( fd_topo_obj_laddr( topo, obj->id ), VAL("max_live_slots"), VAL("max_fork_width"), FD_RUNTIME_MAX_STAKE_ACCOUNTS, FD_RUNTIME_MAX_VOTE_ACCOUNTS, larger_max_cost_per_block, seed ) );
60 0 : }
61 :
62 : fd_topo_obj_callbacks_t fd_obj_cb_banks = {
63 : .name = "banks",
64 : .footprint = banks_footprint,
65 : .align = banks_align,
66 : .new = banks_new,
67 : };
68 :
69 : static ulong
70 : funk_align( fd_topo_t const * topo,
71 0 : fd_topo_obj_t const * obj ) {
72 0 : (void)topo; (void)obj;
73 0 : return fd_funk_align();
74 0 : }
75 :
76 : static ulong
77 : funk_footprint( fd_topo_t const * topo,
78 0 : fd_topo_obj_t const * obj ) {
79 0 : return fd_funk_shmem_footprint( VAL("txn_max"), VAL("rec_max") );
80 0 : }
81 :
82 : static ulong
83 : funk_loose( fd_topo_t const * topo,
84 0 : fd_topo_obj_t const * obj ) {
85 0 : return VAL("heap_max");
86 0 : }
87 :
88 : static void
89 : funk_new( fd_topo_t const * topo,
90 0 : fd_topo_obj_t const * obj ) {
91 0 : ulong funk_seed = fd_pod_queryf_ulong( topo->props, 0UL, "obj.%lu.seed", obj->id );
92 0 : if( !funk_seed ) FD_TEST( fd_rng_secure( &funk_seed, sizeof(ulong) ) );
93 0 : FD_TEST( fd_funk_shmem_new( fd_topo_obj_laddr( topo, obj->id ), 2UL, funk_seed, VAL("txn_max"), VAL("rec_max") ) );
94 0 : }
95 :
96 : fd_topo_obj_callbacks_t fd_obj_cb_funk = {
97 : .name = "funk",
98 : .footprint = funk_footprint,
99 : .loose = funk_loose,
100 : .align = funk_align,
101 : .new = funk_new,
102 : };
103 :
104 : static ulong
105 : funk_locks_footprint( fd_topo_t const * topo,
106 0 : fd_topo_obj_t const * obj ) {
107 0 : return fd_funk_locks_footprint( VAL("txn_max"), VAL("rec_max") );
108 0 : }
109 :
110 : static void
111 : funk_locks_new( fd_topo_t const * topo,
112 0 : fd_topo_obj_t const * obj ) {
113 0 : FD_TEST( fd_funk_locks_new( fd_topo_obj_laddr( topo, obj->id ), VAL("txn_max"), VAL("rec_max") ) );
114 0 : }
115 :
116 : fd_topo_obj_callbacks_t fd_obj_cb_funk_locks = {
117 : .name = "funk_locks",
118 : .footprint = funk_locks_footprint,
119 : .align = funk_align,
120 : .new = funk_locks_new,
121 : };
122 :
123 : static ulong
124 : progcache_align( fd_topo_t const * topo,
125 0 : fd_topo_obj_t const * obj ) {
126 0 : (void)topo; (void)obj;
127 0 : return fd_progcache_shmem_align();
128 0 : }
129 :
130 : static ulong
131 : progcache_footprint( fd_topo_t const * topo,
132 0 : fd_topo_obj_t const * obj ) {
133 0 : return fd_progcache_shmem_footprint( VAL("txn_max"), VAL("rec_max") );
134 0 : }
135 :
136 : static ulong
137 : progcache_loose( fd_topo_t const * topo,
138 0 : fd_topo_obj_t const * obj ) {
139 0 : return VAL("heap_max");
140 0 : }
141 :
142 : static void
143 : progcache_new( fd_topo_t const * topo,
144 0 : fd_topo_obj_t const * obj ) {
145 0 : ulong seed = fd_pod_queryf_ulong( topo->props, 0UL, "obj.%lu.seed", obj->id );
146 0 : if( !seed ) FD_TEST( fd_rng_secure( &seed, sizeof(ulong) ) );
147 0 : FD_TEST( fd_progcache_shmem_new( fd_topo_obj_laddr( topo, obj->id ), 2UL, seed, VAL("txn_max"), VAL("rec_max") ) );
148 0 : }
149 :
150 : fd_topo_obj_callbacks_t fd_obj_cb_progcache = {
151 : .name = "progcache",
152 : .footprint = progcache_footprint,
153 : .loose = progcache_loose,
154 : .align = progcache_align,
155 : .new = progcache_new,
156 : };
157 :
158 : /* cnc: a tile admin message queue */
159 :
160 : static ulong
161 : cnc_align( fd_topo_t const * topo,
162 0 : fd_topo_obj_t const * obj ) {
163 0 : (void)topo; (void)obj;
164 0 : return fd_cnc_align();
165 0 : }
166 :
167 : static ulong
168 : cnc_footprint( fd_topo_t const * topo,
169 0 : fd_topo_obj_t const * obj ) {
170 0 : return fd_cnc_footprint( VAL("app_sz") );
171 0 : }
172 :
173 : static void
174 : cnc_new( fd_topo_t const * topo,
175 0 : fd_topo_obj_t const * obj ) {
176 0 : FD_TEST( fd_cnc_new( fd_topo_obj_laddr( topo, obj->id ), VAL("app_sz"), VAL("type"), fd_log_wallclock() ) );
177 0 : }
178 :
179 : fd_topo_obj_callbacks_t fd_obj_cb_cnc = {
180 : .name = "cnc",
181 : .footprint = cnc_footprint,
182 : .align = cnc_align,
183 : .new = cnc_new,
184 : };
185 :
186 : static ulong
187 : fec_sets_footprint( fd_topo_t const * topo,
188 0 : fd_topo_obj_t const * obj ) {
189 0 : return VAL("sz");
190 0 : }
191 :
192 : static ulong
193 : fec_sets_align( fd_topo_t const * topo FD_FN_UNUSED,
194 0 : fd_topo_obj_t const * obj FD_FN_UNUSED ) {
195 0 : return fd_dcache_align();
196 0 : }
197 :
198 : static void
199 : fec_sets_new( FD_PARAM_UNUSED fd_topo_t const * topo,
200 0 : FD_PARAM_UNUSED fd_topo_obj_t const * obj ) {
201 0 : FD_TEST( fd_topo_obj_laddr( topo, obj->id ) );
202 0 : }
203 :
204 : fd_topo_obj_callbacks_t fd_obj_cb_fec_sets = {
205 : .name = "fec_sets",
206 : .footprint = fec_sets_footprint,
207 : .align = fec_sets_align,
208 : .new = fec_sets_new,
209 : };
210 :
211 : static ulong
212 : store_footprint( fd_topo_t const * topo,
213 0 : fd_topo_obj_t const * obj ) {
214 0 : return fd_store_footprint( VAL("fec_max") );
215 0 : }
216 :
217 : static ulong
218 : store_align( fd_topo_t const * topo FD_FN_UNUSED,
219 0 : fd_topo_obj_t const * obj FD_FN_UNUSED ) {
220 0 : return fd_store_align();
221 0 : }
222 :
223 : static void
224 : store_new( fd_topo_t const * topo,
225 0 : fd_topo_obj_t const * obj ) {
226 0 : FD_TEST( fd_store_new( fd_topo_obj_laddr( topo, obj->id ), VAL("fec_max"), VAL("part_cnt") ) );
227 0 : }
228 :
229 : fd_topo_obj_callbacks_t fd_obj_cb_store = {
230 : .name = "store",
231 : .footprint = store_footprint,
232 : .align = store_align,
233 : .new = store_new,
234 : };
235 :
236 : static ulong
237 : txncache_footprint( fd_topo_t const * topo,
238 0 : fd_topo_obj_t const * obj ) {
239 0 : return fd_txncache_shmem_footprint( VAL("max_live_slots"), VAL("max_txn_per_slot") );
240 0 : }
241 :
242 : static ulong
243 : txncache_align( fd_topo_t const * topo FD_FN_UNUSED,
244 0 : fd_topo_obj_t const * obj FD_FN_UNUSED ) {
245 0 : return fd_txncache_shmem_align();
246 0 : }
247 :
248 : static void
249 : txncache_new( fd_topo_t const * topo,
250 0 : fd_topo_obj_t const * obj ) {
251 0 : FD_TEST( fd_txncache_shmem_new( fd_topo_obj_laddr( topo, obj->id ), VAL("max_live_slots"), VAL("max_txn_per_slot") ) );
252 0 : }
253 :
254 : fd_topo_obj_callbacks_t fd_obj_cb_txncache = {
255 : .name = "txncache",
256 : .footprint = txncache_footprint,
257 : .align = txncache_align,
258 : .new = txncache_new,
259 : };
260 :
261 : static ulong
262 : acc_pool_footprint( fd_topo_t const * topo,
263 0 : fd_topo_obj_t const * obj ) {
264 0 : return fd_acc_pool_footprint( VAL("max_account_cnt") );
265 0 : }
266 :
267 : static ulong
268 : acc_pool_align( fd_topo_t const * topo FD_FN_UNUSED,
269 0 : fd_topo_obj_t const * obj FD_FN_UNUSED ) {
270 0 : return fd_acc_pool_align();
271 0 : }
272 :
273 : static void
274 : acc_pool_new( fd_topo_t const * topo,
275 0 : fd_topo_obj_t const * obj ) {
276 0 : FD_TEST( fd_acc_pool_new( fd_topo_obj_laddr( topo, obj->id ), VAL("max_account_cnt") ) );
277 0 : }
278 :
279 : fd_topo_obj_callbacks_t fd_obj_cb_acc_pool = {
280 : .name = "acc_pool",
281 : .footprint = acc_pool_footprint,
282 : .align = acc_pool_align,
283 : .new = acc_pool_new,
284 : };
285 :
286 :
287 : static ulong
288 : rnonce_ss_footprint( fd_topo_t const * topo FD_FN_UNUSED,
289 0 : fd_topo_obj_t const * obj FD_FN_UNUSED ) {
290 0 : return sizeof(fd_rnonce_ss_t) + sizeof(ulong);
291 0 : }
292 :
293 : static ulong
294 : rnonce_ss_align( fd_topo_t const * topo FD_FN_UNUSED,
295 0 : fd_topo_obj_t const * obj FD_FN_UNUSED ) {
296 0 : return alignof(fd_rnonce_ss_t);
297 0 : }
298 :
299 : static void
300 : rnonce_ss_new( fd_topo_t const * topo,
301 0 : fd_topo_obj_t const * obj ) {
302 0 : memset( fd_topo_obj_laddr( topo, obj->id ), '\0', sizeof(fd_rnonce_ss_t)+sizeof(ulong) );
303 0 : }
304 :
305 : fd_topo_obj_callbacks_t fd_obj_cb_rnonce_ss = {
306 : .name = "rnonce_ss",
307 : .footprint = rnonce_ss_footprint,
308 : .align = rnonce_ss_align,
309 : .new = rnonce_ss_new,
310 : };
311 :
312 : #undef VAL
|