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 "../../disco/shred/fd_rnonce_ss.h"
9 : #include "../../discof/backup/fd_backup_shmem.h"
10 :
11 : #include "../../discof/admin/fd_adminctl.h"
12 :
13 0 : #define VAL(name) (__extension__({ \
14 0 : ulong __x = fd_pod_queryf_ulong( topo->props, ULONG_MAX, "obj.%lu.%s", obj->id, name ); \
15 0 : if( FD_UNLIKELY( __x==ULONG_MAX ) ) FD_LOG_ERR(( "obj.%lu.%s was not set", obj->id, name )); \
16 0 : __x; }))
17 :
18 : static ulong
19 : banks_footprint( fd_topo_t const * topo,
20 0 : fd_topo_obj_t const * obj ) {
21 0 : return fd_banks_footprint( VAL("max_live_slots"), VAL("max_fork_width"), FD_RUNTIME_MAX_STAKE_ACCOUNTS, FD_RUNTIME_MAX_STAKE_ACCOUNTS_FALLBACK, FD_RUNTIME_MAX_VAT_VOTE_ACCOUNTS );
22 0 : }
23 :
24 : static ulong
25 : banks_align( fd_topo_t const * topo FD_FN_UNUSED,
26 0 : fd_topo_obj_t const * obj FD_FN_UNUSED ) {
27 0 : return fd_banks_align();
28 0 : }
29 :
30 : static void
31 : banks_new( fd_topo_t const * topo,
32 0 : fd_topo_obj_t const * obj ) {
33 0 : int larger_max_cost_per_block = fd_pod_queryf_int( topo->props, 0, "obj.%lu.larger_max_cost_per_block", obj->id );
34 0 : ulong seed = fd_pod_queryf_ulong( topo->props, 0UL, "obj.%lu.seed", obj->id );
35 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_STAKE_ACCOUNTS_FALLBACK, FD_RUNTIME_MAX_VAT_VOTE_ACCOUNTS, larger_max_cost_per_block, seed ) );
36 0 : }
37 :
38 : fd_topo_obj_callbacks_t fd_obj_cb_banks = {
39 : .name = "banks",
40 : .footprint = banks_footprint,
41 : .align = banks_align,
42 : .new = banks_new,
43 : };
44 :
45 : static ulong
46 : progcache_align( fd_topo_t const * topo,
47 0 : fd_topo_obj_t const * obj ) {
48 0 : (void)topo; (void)obj;
49 0 : return fd_progcache_shmem_align();
50 0 : }
51 :
52 : static ulong
53 : progcache_footprint( fd_topo_t const * topo,
54 0 : fd_topo_obj_t const * obj ) {
55 0 : return fd_progcache_shmem_footprint( VAL("txn_max"), VAL("rec_max") );
56 0 : }
57 :
58 : static ulong
59 : progcache_loose( fd_topo_t const * topo,
60 0 : fd_topo_obj_t const * obj ) {
61 0 : return VAL("heap_max");
62 0 : }
63 :
64 : static void
65 : progcache_new( fd_topo_t const * topo,
66 0 : fd_topo_obj_t const * obj ) {
67 0 : ulong seed = fd_pod_queryf_ulong( topo->props, 0UL, "obj.%lu.seed", obj->id );
68 0 : if( !seed ) FD_TEST( fd_rng_secure( &seed, sizeof(ulong) ) );
69 0 : FD_TEST( fd_progcache_shmem_new( fd_topo_obj_laddr( topo, obj->id ), 2UL, seed, VAL("txn_max"), VAL("rec_max") ) );
70 0 : }
71 :
72 : fd_topo_obj_callbacks_t fd_obj_cb_progcache = {
73 : .name = "progcache",
74 : .footprint = progcache_footprint,
75 : .loose = progcache_loose,
76 : .align = progcache_align,
77 : .new = progcache_new,
78 : };
79 :
80 : /* adminctl: admin tile command channel */
81 :
82 : static ulong
83 : adminctl_align( fd_topo_t const * topo,
84 0 : fd_topo_obj_t const * obj ) {
85 0 : (void)topo; (void)obj;
86 0 : return fd_adminctl_align();
87 0 : }
88 :
89 : static ulong
90 : adminctl_footprint( fd_topo_t const * topo,
91 0 : fd_topo_obj_t const * obj ) {
92 0 : (void)topo; (void)obj;
93 0 : return fd_adminctl_footprint();
94 0 : }
95 :
96 : static void
97 : adminctl_new( fd_topo_t const * topo,
98 0 : fd_topo_obj_t const * obj ) {
99 0 : FD_TEST( fd_adminctl_new( fd_topo_obj_laddr( topo, obj->id ) ) );
100 0 : }
101 :
102 : fd_topo_obj_callbacks_t fd_obj_cb_adminctl = {
103 : .name = "adminctl",
104 : .footprint = adminctl_footprint,
105 : .align = adminctl_align,
106 : .new = adminctl_new,
107 : };
108 :
109 : static ulong
110 : fec_sets_footprint( fd_topo_t const * topo,
111 0 : fd_topo_obj_t const * obj ) {
112 0 : return VAL("sz");
113 0 : }
114 :
115 : static ulong
116 : fec_sets_align( fd_topo_t const * topo FD_FN_UNUSED,
117 0 : fd_topo_obj_t const * obj FD_FN_UNUSED ) {
118 0 : return fd_dcache_align();
119 0 : }
120 :
121 : static void
122 : fec_sets_new( FD_PARAM_UNUSED fd_topo_t const * topo,
123 0 : FD_PARAM_UNUSED fd_topo_obj_t const * obj ) {
124 0 : FD_TEST( fd_topo_obj_laddr( topo, obj->id ) );
125 0 : }
126 :
127 : fd_topo_obj_callbacks_t fd_obj_cb_fec_sets = {
128 : .name = "fec_sets",
129 : .footprint = fec_sets_footprint,
130 : .align = fec_sets_align,
131 : .new = fec_sets_new,
132 : };
133 :
134 : static ulong
135 : store_footprint( fd_topo_t const * topo,
136 0 : fd_topo_obj_t const * obj ) {
137 0 : return fd_store_footprint( VAL("fec_max"), VAL("fec_data_max") );
138 0 : }
139 :
140 : static ulong
141 : store_align( fd_topo_t const * topo FD_FN_UNUSED,
142 0 : fd_topo_obj_t const * obj FD_FN_UNUSED ) {
143 0 : return fd_store_align();
144 0 : }
145 :
146 : static void
147 : store_new( fd_topo_t const * topo,
148 0 : fd_topo_obj_t const * obj ) {
149 0 : FD_TEST( fd_store_new( fd_topo_obj_laddr( topo, obj->id ), VAL("part_cnt"), VAL("fec_max"), VAL("fec_data_max") ) );
150 0 : }
151 :
152 : fd_topo_obj_callbacks_t fd_obj_cb_store = {
153 : .name = "store",
154 : .footprint = store_footprint,
155 : .align = store_align,
156 : .new = store_new,
157 : };
158 :
159 : static ulong
160 : accdb_footprint( fd_topo_t const * topo,
161 0 : fd_topo_obj_t const * obj ) {
162 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") );
163 0 : }
164 :
165 : static ulong
166 : accdb_align( fd_topo_t const * topo FD_FN_UNUSED,
167 0 : fd_topo_obj_t const * obj FD_FN_UNUSED ) {
168 0 : return fd_accdb_shmem_align();
169 0 : }
170 :
171 : static void
172 : accdb_new( fd_topo_t const * topo,
173 0 : fd_topo_obj_t const * obj ) {
174 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") ) );
175 0 : }
176 :
177 : fd_topo_obj_callbacks_t fd_obj_cb_accdb = {
178 : .name = "accdb",
179 : .footprint = accdb_footprint,
180 : .align = accdb_align,
181 : .new = accdb_new,
182 : };
183 :
184 : static ulong
185 : txncache_footprint( fd_topo_t const * topo,
186 0 : fd_topo_obj_t const * obj ) {
187 0 : int larger_max_cost_per_block = fd_pod_queryf_int( topo->props, 0, "obj.%lu.larger_max_cost_per_block", obj->id );
188 0 : return fd_txncache_shmem_footprint( VAL("max_live_slots"), VAL("max_txn_per_slot"), larger_max_cost_per_block );
189 0 : }
190 :
191 : static ulong
192 : txncache_align( fd_topo_t const * topo FD_FN_UNUSED,
193 0 : fd_topo_obj_t const * obj FD_FN_UNUSED ) {
194 0 : return fd_txncache_shmem_align();
195 0 : }
196 :
197 : static void
198 : txncache_new( fd_topo_t const * topo,
199 0 : fd_topo_obj_t const * obj ) {
200 0 : int larger_max_cost_per_block = fd_pod_queryf_int( topo->props, 0, "obj.%lu.larger_max_cost_per_block", obj->id );
201 0 : FD_TEST( fd_txncache_shmem_new( fd_topo_obj_laddr( topo, obj->id ), VAL("max_live_slots"), VAL("max_txn_per_slot"), larger_max_cost_per_block, VAL("seed") ) );
202 0 : }
203 :
204 : fd_topo_obj_callbacks_t fd_obj_cb_txncache = {
205 : .name = "txncache",
206 : .footprint = txncache_footprint,
207 : .align = txncache_align,
208 : .new = txncache_new,
209 : };
210 :
211 : static ulong
212 : rnonce_ss_footprint( fd_topo_t const * topo FD_FN_UNUSED,
213 0 : fd_topo_obj_t const * obj FD_FN_UNUSED ) {
214 0 : return sizeof(fd_rnonce_ss_t);
215 0 : }
216 :
217 : static ulong
218 : rnonce_ss_align( fd_topo_t const * topo FD_FN_UNUSED,
219 0 : fd_topo_obj_t const * obj FD_FN_UNUSED ) {
220 0 : return alignof(fd_rnonce_ss_t);
221 0 : }
222 :
223 : static void
224 : rnonce_ss_new( fd_topo_t const * topo,
225 0 : fd_topo_obj_t const * obj ) {
226 0 : FD_TEST( fd_rng_secure( fd_topo_obj_laddr( topo, obj->id ), sizeof(fd_rnonce_ss_t) ) );
227 0 : }
228 :
229 : fd_topo_obj_callbacks_t fd_obj_cb_rnonce_ss = {
230 : .name = "rnonce_ss",
231 : .footprint = rnonce_ss_footprint,
232 : .align = rnonce_ss_align,
233 : .new = rnonce_ss_new,
234 : };
235 :
236 : static ulong
237 : backup_footprint_cb( fd_topo_t const * topo,
238 0 : fd_topo_obj_t const * obj ) {
239 0 : return fd_backup_footprint( VAL("max_accounts") );
240 0 : }
241 :
242 : static ulong
243 : backup_align_cb( fd_topo_t const * topo FD_FN_UNUSED,
244 0 : fd_topo_obj_t const * obj FD_FN_UNUSED ) {
245 0 : return fd_backup_align();
246 0 : }
247 :
248 : static void
249 : backup_new_cb( fd_topo_t const * topo,
250 0 : fd_topo_obj_t const * obj ) {
251 0 : FD_TEST( fd_backup_new( fd_topo_obj_laddr( topo, obj->id ), VAL("max_accounts") ) );
252 0 : }
253 :
254 : fd_topo_obj_callbacks_t fd_obj_cb_backup = {
255 : .name = "backup",
256 : .footprint = backup_footprint_cb,
257 : .align = backup_align_cb,
258 : .new = backup_new_cb,
259 : };
260 :
261 : #undef VAL
|