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