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