Line data Source code
1 : /* The backtest command spawns a smaller topology for replaying shreds from
2 : rocksdb (or other sources TBD) and reproduce the behavior of replay tile.
3 :
4 : The smaller topology is:
5 : shred_out replay_exec
6 : backtest-------------->replay------------->exec
7 : ^ |^ | ^ |
8 : |____________________|| | |________________|
9 : replay_out | | exec_replay
10 : | |------------------------------>no consumer
11 : no producer------------- stake_out, send_out, poh_out
12 : store_replay
13 :
14 : */
15 : #define _GNU_SOURCE
16 : #include "../../firedancer/topology.h"
17 : #include "../../shared/commands/configure/configure.h"
18 : #include "../../shared/commands/run/run.h" /* initialize_workspaces */
19 : #include "../../shared/commands/watch/watch.h"
20 : #include "../../shared/fd_config.h" /* config_t */
21 : #include "../../../disco/tiles.h"
22 : #include "../../../disco/topo/fd_topob.h"
23 : #include "../../../util/pod/fd_pod_format.h"
24 : #include "../../../discof/replay/fd_replay_tile.h"
25 : #include "../../../discof/restore/utils/fd_ssctrl.h"
26 : #include "../../../discof/restore/utils/fd_ssmsg.h"
27 : #include "../../../discof/tower/fd_tower_tile.h"
28 : #include "../../../discof/replay/fd_exec.h"
29 : #include "../../../ballet/lthash/fd_lthash.h"
30 : #include "../../../flamenco/runtime/context/fd_capture_ctx.h"
31 : #include "../../../disco/pack/fd_pack_cost.h"
32 : #include "../../../flamenco/progcache/fd_progcache_admin.h"
33 :
34 : #include "../main.h"
35 :
36 : #include <errno.h>
37 : #include <unistd.h>
38 : #include <fcntl.h>
39 :
40 : extern fd_topo_obj_callbacks_t * CALLBACKS[];
41 : fd_topo_run_tile_t fdctl_tile_run( fd_topo_tile_t const * tile );
42 :
43 : static void
44 0 : backtest_topo( config_t * config ) {
45 :
46 0 : config->development.sandbox = 0;
47 0 : config->development.no_clone = 1;
48 :
49 0 : ulong exec_tile_cnt = config->firedancer.layout.exec_tile_count;
50 :
51 0 : int disable_snap_loader = !config->gossip.entrypoints_cnt;
52 0 : int solcap_enabled = strlen( config->capture.solcap_capture )>0;
53 :
54 0 : fd_topo_t * topo = { fd_topob_new( &config->topo, config->name ) };
55 0 : topo->max_page_size = fd_cstr_to_shmem_page_sz( config->hugetlbfs.max_page_size );
56 0 : topo->gigantic_page_threshold = config->hugetlbfs.gigantic_page_threshold_mib << 20;
57 :
58 0 : ulong cpu_idx = 0;
59 :
60 0 : fd_topob_wksp( topo, "metric_in" );
61 :
62 : /**********************************************************************/
63 : /* Add the backtest tile to topo */
64 : /**********************************************************************/
65 0 : fd_topob_wksp( topo, "backt" );
66 0 : fd_topo_tile_t * backt_tile = fd_topob_tile( topo, "backt", "backt", "metric_in", cpu_idx++, 0, 0 );
67 :
68 : /**********************************************************************/
69 : /* Add the replay tile to topo */
70 : /**********************************************************************/
71 0 : fd_topob_wksp( topo, "replay" );
72 0 : fd_topo_tile_t * replay_tile = fd_topob_tile( topo, "replay", "replay", "metric_in", cpu_idx++, 0, 0 );
73 :
74 : /* specified by [tiles.replay] */
75 :
76 0 : fd_topob_wksp( topo, "funk" );
77 0 : fd_topo_obj_t * funk_obj = setup_topo_funk( topo, "funk",
78 0 : config->firedancer.funk.max_account_records,
79 0 : config->firedancer.funk.max_database_transactions,
80 0 : config->firedancer.funk.heap_size_gib );
81 0 : fd_topob_tile_uses( topo, replay_tile, funk_obj, FD_SHMEM_JOIN_MODE_READ_WRITE );
82 :
83 0 : fd_topob_wksp( topo, "progcache" );
84 0 : fd_topo_obj_t * progcache_obj = setup_topo_progcache( topo, "progcache",
85 0 : fd_progcache_est_rec_max( config->firedancer.runtime.program_cache.heap_size_mib<<20,
86 0 : config->firedancer.runtime.program_cache.mean_cache_entry_size ),
87 0 : config->firedancer.funk.max_database_transactions,
88 0 : config->firedancer.runtime.program_cache.heap_size_mib<<20 );
89 0 : fd_topob_tile_uses( topo, replay_tile, progcache_obj, FD_SHMEM_JOIN_MODE_READ_WRITE );
90 :
91 : /**********************************************************************/
92 : /* Add the executor tiles to topo */
93 : /**********************************************************************/
94 0 : fd_topob_wksp( topo, "exec" );
95 0 : #define FOR(cnt) for( ulong i=0UL; i<cnt; i++ )
96 0 : FOR(exec_tile_cnt) fd_topob_tile( topo, "exec", "exec", "metric_in", cpu_idx++, 0, 0 );
97 :
98 : /**********************************************************************/
99 : /* Add the snapshot tiles to topo */
100 : /**********************************************************************/
101 0 : fd_topo_tile_t * snapin_tile = NULL;
102 0 : if( FD_UNLIKELY( !disable_snap_loader ) ) {
103 0 : fd_topob_wksp( topo, "snapct" );
104 0 : fd_topob_wksp( topo, "snapld" );
105 0 : fd_topob_wksp( topo, "snapdc" );
106 0 : fd_topob_wksp( topo, "snapin" );
107 0 : fd_topo_tile_t * snapct_tile = fd_topob_tile( topo, "snapct", "snapct", "metric_in", cpu_idx++, 0, 0 );
108 0 : fd_topo_tile_t * snapld_tile = fd_topob_tile( topo, "snapld", "snapld", "metric_in", cpu_idx++, 0, 0 );
109 0 : fd_topo_tile_t * snapdc_tile = fd_topob_tile( topo, "snapdc", "snapdc", "metric_in", cpu_idx++, 0, 0 );
110 0 : snapin_tile = fd_topob_tile( topo, "snapin", "snapin", "metric_in", cpu_idx++, 0, 0 );
111 0 : snapct_tile->allow_shutdown = 1;
112 0 : snapld_tile->allow_shutdown = 1;
113 0 : snapdc_tile->allow_shutdown = 1;
114 0 : snapin_tile->allow_shutdown = 1;
115 0 : } else {
116 0 : fd_topob_wksp( topo, "genesi" );
117 0 : fd_topob_tile( topo, "genesi", "genesi", "metric_in", cpu_idx++, 0, 0 )->allow_shutdown = 1;
118 0 : }
119 :
120 : /**********************************************************************/
121 : /* Setup backtest->replay link (shred_out) in topo */
122 : /**********************************************************************/
123 :
124 : /* The repair tile is replaced by the backtest tile for the repair to
125 : replay link. The frag interface is a "slice", ie. entry batch,
126 : which is provided by the backtest tile, which reads in the entry
127 : batches from the CLI-specified source (eg. RocksDB). */
128 :
129 0 : fd_topob_wksp( topo, "shred_out" );
130 0 : fd_topob_link( topo, "shred_out", "shred_out", 65536UL, FD_SHRED_OUT_MTU, 1UL );
131 0 : fd_topob_tile_in( topo, "replay", 0UL, "metric_in", "shred_out", 0UL, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
132 0 : fd_topob_tile_out( topo, "backt", 0UL, "shred_out", 0UL );
133 :
134 : /**********************************************************************/
135 : /* Setup snapshot links in topo */
136 : /**********************************************************************/
137 0 : if( FD_LIKELY( !disable_snap_loader ) ) {
138 0 : fd_topob_wksp( topo, "snapct_ld" );
139 0 : fd_topob_wksp( topo, "snapld_dc" );
140 0 : fd_topob_wksp( topo, "snapdc_in" );
141 0 : fd_topob_wksp( topo, "snapin_rd" );
142 0 : fd_topob_wksp( topo, "snapin_manif" );
143 0 : fd_topob_wksp( topo, "snapct_repr" );
144 :
145 0 : fd_topob_link( topo, "snapct_ld", "snapct_ld", 128UL, sizeof(fd_ssctrl_init_t), 1UL );
146 0 : fd_topob_link( topo, "snapld_dc", "snapld_dc", 16384UL, USHORT_MAX, 1UL );
147 0 : fd_topob_link( topo, "snapdc_in", "snapdc_in", 16384UL, USHORT_MAX, 1UL );
148 0 : fd_topob_link( topo, "snapin_rd", "snapin_rd", 128UL, 0UL, 1UL );
149 0 : fd_topob_link( topo, "snapin_manif", "snapin_manif", 4UL, sizeof(fd_snapshot_manifest_t), 1UL ); /* TODO: Should be depth 1 or 2 but replay backpressures */
150 0 : fd_topob_link( topo, "snapct_repr", "snapct_repr", 128UL, 0UL, 1UL )->permit_no_consumers = 1;
151 :
152 0 : fd_topob_tile_in ( topo, "snapct", 0UL, "metric_in", "snapin_rd", 0UL, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
153 0 : fd_topob_tile_in ( topo, "snapct", 0UL, "metric_in", "snapld_dc", 0UL, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
154 0 : fd_topob_tile_out( topo, "snapct", 0UL, "snapct_ld", 0UL );
155 0 : fd_topob_tile_out( topo, "snapct", 0UL, "snapct_repr", 0UL );
156 0 : fd_topob_tile_in ( topo, "snapld", 0UL, "metric_in", "snapct_ld", 0UL, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
157 0 : fd_topob_tile_out( topo, "snapld", 0UL, "snapld_dc", 0UL );
158 0 : fd_topob_tile_in ( topo, "snapdc", 0UL, "metric_in", "snapld_dc", 0UL, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
159 0 : fd_topob_tile_out( topo, "snapdc", 0UL, "snapdc_in", 0UL );
160 0 : fd_topob_tile_in ( topo, "snapin", 0UL, "metric_in", "snapdc_in", 0UL, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
161 0 : fd_topob_tile_out( topo, "snapin", 0UL, "snapin_rd", 0UL );
162 0 : fd_topob_tile_out( topo, "snapin", 0UL, "snapin_manif", 0UL );
163 0 : fd_topob_tile_in ( topo, "replay", 0UL, "metric_in", "snapin_manif", 0UL, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
164 0 : } else {
165 0 : fd_topob_wksp( topo, "genesi_out" );
166 0 : fd_topob_link( topo, "genesi_out", "genesi_out", 2UL, 10UL*1024UL*1024UL+32UL+sizeof(fd_lthash_value_t), 1UL );
167 0 : fd_topob_tile_out( topo, "genesi", 0UL, "genesi_out", 0UL );
168 0 : fd_topob_tile_in ( topo, "replay", 0UL, "metric_in", "genesi_out", 0UL, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
169 0 : }
170 :
171 : /**********************************************************************/
172 : /* More backtest->replay links in topo */
173 : /**********************************************************************/
174 :
175 : /* The tower tile is replaced by the backtest tile for the tower to
176 : replay link. The backtest tile simply sends monotonically
177 : increasing rooted slot numbers to the replay tile, once after each
178 : "replayed a full slot" notification received from the replay tile.
179 : This allows the replay tile to advance its watermark, and publish
180 : various data structures. This is an oversimplified barebones mock
181 : of the tower tile. */
182 0 : fd_topob_wksp( topo, "tower_out" );
183 0 : fd_topob_link( topo, "tower_out", "tower_out", 1024UL, sizeof(fd_tower_slot_done_t), 1UL );
184 0 : fd_topob_tile_in( topo, "replay", 0UL, "metric_in", "tower_out", 0UL, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
185 0 : fd_topob_tile_out( topo, "backt", 0UL, "tower_out", 0UL );
186 :
187 : /**********************************************************************/
188 : /* Setup replay->stake/send/poh links in topo w/o consumers */
189 : /**********************************************************************/
190 0 : fd_topob_wksp( topo, "replay_stake" );
191 0 : fd_topob_wksp( topo, "replay_poh" );
192 :
193 0 : fd_topob_link( topo, "replay_stake", "replay_stake", 128UL, 40UL + 40200UL * 40UL, 1UL );
194 0 : ulong bank_tile_cnt = config->layout.bank_tile_count;
195 0 : FOR(bank_tile_cnt) fd_topob_link( topo, "replay_poh", "replay_poh", 128UL, (4096UL*sizeof(fd_txn_p_t))+sizeof(fd_microblock_trailer_t), 1UL );
196 :
197 0 : fd_topob_tile_out( topo, "replay", 0UL, "replay_stake", 0UL );
198 0 : FOR(bank_tile_cnt) fd_topob_tile_out( topo, "replay", 0UL, "replay_poh", i );
199 :
200 0 : topo->links[ replay_tile->out_link_id[ fd_topo_find_tile_out_link( topo, replay_tile, "replay_stake", 0 ) ] ].permit_no_consumers = 1;
201 0 : FOR(bank_tile_cnt) topo->links[ replay_tile->out_link_id[ fd_topo_find_tile_out_link( topo, replay_tile, "replay_poh", i ) ] ].permit_no_consumers = 1;
202 :
203 : /**********************************************************************/
204 : /* Setup replay->backtest link (replay_notif) in topo */
205 : /**********************************************************************/
206 :
207 0 : fd_topob_wksp( topo, "replay_out" );
208 0 : fd_topob_link( topo, "replay_out", "replay_out", 8192UL, sizeof( fd_replay_message_t ), 1UL );
209 0 : fd_topob_tile_out( topo, "replay", 0UL, "replay_out", 0UL );
210 0 : fd_topob_tile_in ( topo, "backt", 0UL, "metric_in", "replay_out", 0UL, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
211 0 : if( FD_LIKELY( !disable_snap_loader ) ) {
212 0 : fd_topob_tile_in ( topo, "backt", 0UL, "metric_in", "snapin_manif", 0UL, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
213 0 : } else {
214 0 : fd_topob_tile_in ( topo, "backt", 0UL, "metric_in", "genesi_out", 0UL, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
215 0 : }
216 :
217 : /**********************************************************************/
218 : /* Setup replay->exec link in topo */
219 : /**********************************************************************/
220 0 : fd_topob_wksp( topo, "replay_exec" );
221 0 : fd_topob_link( topo, "replay_exec", "replay_exec", 16384UL, 2240UL, 1UL );
222 0 : fd_topob_tile_out( topo, "replay", 0UL, "replay_exec", 0UL );
223 0 : for( ulong i=0UL; i<exec_tile_cnt; i++ ) {
224 0 : fd_topob_tile_in( topo, "exec", i, "metric_in", "replay_exec", 0UL, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
225 0 : }
226 :
227 : /**********************************************************************/
228 : /* Setup exec->replay links in topo, to send solcap account updates
229 : so that they are serialized, and to notify replay tile that a txn
230 : has been finalized by the exec tile. */
231 : /**********************************************************************/
232 0 : fd_topob_wksp( topo, "exec_replay" );
233 :
234 : /* If solcap is enabled, we need to overload this link to also send
235 : solcap account updates to the replay tile. We can't use a separate
236 : link for this without introducing a race. This will get removed with solcap V2. */
237 0 : if( FD_UNLIKELY( solcap_enabled ) ) {
238 : /* TODO: remove this with solcap V2 */
239 0 : FOR(exec_tile_cnt) fd_topob_link( topo, "exec_replay", "exec_replay", 1024UL, FD_CAPTURE_CTX_ACCOUNT_UPDATE_MSG_FOOTPRINT, 1UL );
240 0 : } else {
241 0 : FOR(exec_tile_cnt) fd_topob_link( topo, "exec_replay", "exec_replay", 16384UL, sizeof(fd_exec_task_done_msg_t), 1UL );
242 0 : }
243 :
244 0 : FOR(exec_tile_cnt) fd_topob_tile_out( topo, "exec", i, "exec_replay", i );
245 0 : FOR(exec_tile_cnt) fd_topob_tile_in( topo, "replay", 0UL, "metric_in", "exec_replay", i, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
246 :
247 : /**********************************************************************/
248 : /* Setup the shared objs used by replay and exec tiles */
249 : /**********************************************************************/
250 :
251 0 : fd_topob_wksp( topo, "store" );
252 0 : fd_topo_obj_t * store_obj = setup_topo_store( topo, "store", config->firedancer.store.max_completed_shred_sets, 1 );
253 0 : fd_topob_tile_uses( topo, backt_tile, store_obj, FD_SHMEM_JOIN_MODE_READ_WRITE );
254 0 : fd_topob_tile_uses( topo, replay_tile, store_obj, FD_SHMEM_JOIN_MODE_READ_WRITE );
255 0 : FD_TEST( fd_pod_insertf_ulong( topo->props, store_obj->id, "store" ) );
256 :
257 : /* banks_obj shared by replay and exec tiles */
258 0 : fd_topob_wksp( topo, "banks" );
259 0 : fd_topo_obj_t * banks_obj = setup_topo_banks( topo, "banks", config->firedancer.runtime.max_live_slots, config->firedancer.runtime.max_fork_width );
260 0 : fd_topob_tile_uses( topo, replay_tile, banks_obj, FD_SHMEM_JOIN_MODE_READ_WRITE );
261 0 : FOR(exec_tile_cnt) fd_topob_tile_uses( topo, &topo->tiles[ fd_topo_find_tile( topo, "exec", i ) ], banks_obj, FD_SHMEM_JOIN_MODE_READ_WRITE );
262 0 : FD_TEST( fd_pod_insertf_ulong( topo->props, banks_obj->id, "banks" ) );
263 :
264 : /* bank_hash_cmp_obj shared by replay and exec tiles */
265 0 : fd_topob_wksp( topo, "bh_cmp" );
266 0 : fd_topo_obj_t * bank_hash_cmp_obj = setup_topo_bank_hash_cmp( topo, "bh_cmp" );
267 0 : fd_topob_tile_uses( topo, replay_tile, bank_hash_cmp_obj, FD_SHMEM_JOIN_MODE_READ_WRITE );
268 0 : FOR(exec_tile_cnt) fd_topob_tile_uses( topo, &topo->tiles[ fd_topo_find_tile( topo, "exec", i ) ], bank_hash_cmp_obj, FD_SHMEM_JOIN_MODE_READ_WRITE );
269 0 : FD_TEST( fd_pod_insertf_ulong( topo->props, bank_hash_cmp_obj->id, "bh_cmp" ) );
270 :
271 : /* exec_spad_obj used by exec tiles */
272 0 : fd_topob_wksp( topo, "exec_spad" );
273 0 : for( ulong i=0UL; i<exec_tile_cnt; i++ ) {
274 0 : fd_topo_obj_t * exec_spad_obj = fd_topob_obj( topo, "exec_spad", "exec_spad" );
275 0 : fd_topob_tile_uses( topo, &topo->tiles[ fd_topo_find_tile( topo, "exec", i ) ], exec_spad_obj, FD_SHMEM_JOIN_MODE_READ_WRITE );
276 0 : FD_TEST( fd_pod_insertf_ulong( topo->props, exec_spad_obj->id, "exec_spad.%lu", i ) );
277 0 : }
278 :
279 : /* txncache_obj, busy_obj and poh_slot_obj only by replay tile */
280 0 : fd_topob_wksp( topo, "txncache" );
281 0 : fd_topob_wksp( topo, "bank_busy" );
282 0 : fd_topo_obj_t * txncache_obj = setup_topo_txncache( topo, "txncache",
283 0 : config->firedancer.runtime.max_live_slots,
284 0 : fd_ulong_pow2_up( FD_PACK_MAX_TXNCACHE_TXN_PER_SLOT ) );
285 0 : fd_topob_tile_uses( topo, replay_tile, txncache_obj, FD_SHMEM_JOIN_MODE_READ_WRITE );
286 0 : if( FD_LIKELY( !disable_snap_loader ) ) {
287 0 : fd_topob_tile_uses( topo, &topo->tiles[ fd_topo_find_tile( topo, "snapin", 0UL ) ], txncache_obj, FD_SHMEM_JOIN_MODE_READ_WRITE );
288 0 : }
289 0 : for( ulong i=0UL; i<exec_tile_cnt; i++ ) {
290 0 : fd_topob_tile_uses( topo, &topo->tiles[ fd_topo_find_tile( topo, "exec", i ) ], txncache_obj, FD_SHMEM_JOIN_MODE_READ_WRITE );
291 0 : }
292 0 : for( ulong i=0UL; i<bank_tile_cnt; i++ ) {
293 0 : fd_topob_tile_uses( topo, &topo->tiles[ fd_topo_find_tile( topo, "bank", i ) ], txncache_obj, FD_SHMEM_JOIN_MODE_READ_WRITE );
294 0 : }
295 :
296 0 : FD_TEST( fd_pod_insertf_ulong( topo->props, txncache_obj->id, "txncache" ) );
297 0 : for( ulong i=0UL; i<bank_tile_cnt; i++ ) {
298 0 : fd_topo_obj_t * busy_obj = fd_topob_obj( topo, "fseq", "bank_busy" );
299 0 : fd_topob_tile_uses( topo, replay_tile, busy_obj, FD_SHMEM_JOIN_MODE_READ_WRITE );
300 0 : FD_TEST( fd_pod_insertf_ulong( topo->props, busy_obj->id, "bank_busy.%lu", i ) );
301 0 : }
302 :
303 0 : if( FD_LIKELY( !disable_snap_loader ) ) {
304 0 : fd_topob_tile_uses( topo, snapin_tile, funk_obj, FD_SHMEM_JOIN_MODE_READ_WRITE );
305 0 : }
306 :
307 0 : for( ulong i=0UL; i<topo->tile_cnt; i++ ) {
308 0 : fd_topo_tile_t * tile = &topo->tiles[ i ];
309 0 : fd_topo_configure_tile( tile, config );
310 :
311 0 : if( !strcmp( tile->name, "replay" ) ) {
312 0 : tile->replay.enable_bank_hash_cmp = 0;
313 0 : tile->replay.enable_features_cnt = config->tiles.replay.enable_features_cnt;
314 0 : for( ulong i = 0; i < tile->replay.enable_features_cnt; i++ ) {
315 0 : strncpy( tile->replay.enable_features[i], config->tiles.replay.enable_features[i], sizeof(tile->replay.enable_features[i]) );
316 0 : }
317 0 : }
318 0 : }
319 :
320 : // fd_topob_auto_layout( topo, 0 );
321 0 : fd_topob_finish( topo, CALLBACKS );
322 0 : }
323 :
324 : extern int * fd_log_private_shared_lock;
325 :
326 : static void
327 0 : backtest_cmd_topo( config_t * config ) {
328 0 : backtest_topo( config );
329 0 : }
330 :
331 : static args_t
332 0 : configure_args( void ) {
333 0 : args_t args = {
334 0 : .configure.command = CONFIGURE_CMD_INIT,
335 0 : };
336 :
337 0 : ulong stage_idx = 0UL;
338 0 : args.configure.stages[ stage_idx++ ] = &fd_cfg_stage_hugetlbfs;
339 0 : args.configure.stages[ stage_idx++ ] = &fd_cfg_stage_snapshots;
340 0 : args.configure.stages[ stage_idx++ ] = NULL;
341 :
342 0 : return args;
343 0 : }
344 :
345 : void
346 : backtest_cmd_args( int * pargc,
347 : char *** pargv,
348 0 : args_t * args ) {
349 0 : args->backtest.no_watch = fd_env_strip_cmdline_contains( pargc, pargv, "--no-watch" );
350 0 : }
351 :
352 : void
353 : backtest_cmd_perm( args_t * args FD_PARAM_UNUSED,
354 : fd_cap_chk_t * chk,
355 0 : config_t const * config ) {
356 0 : args_t c_args = configure_args();
357 0 : configure_cmd_perm( &c_args, chk, config );
358 0 : run_cmd_perm( NULL, chk, config );
359 0 : }
360 :
361 : static void
362 : backtest_cmd_fn( args_t * args FD_PARAM_UNUSED,
363 0 : config_t * config ) {
364 0 : args_t c_args = configure_args();
365 0 : configure_cmd_fn( &c_args, config );
366 :
367 0 : initialize_workspaces( config );
368 0 : initialize_stacks( config );
369 :
370 0 : fd_log_private_shared_lock[ 1 ] = 0;
371 0 : fd_topo_join_workspaces( &config->topo, FD_SHMEM_JOIN_MODE_READ_WRITE );
372 0 : fd_topo_fill( &config->topo );
373 :
374 0 : args_t watch_args;
375 0 : int pipefd[2];
376 0 : if( !args->backtest.no_watch ) {
377 0 : if( FD_UNLIKELY( pipe2( pipefd, O_NONBLOCK ) ) ) FD_LOG_ERR(( "pipe2() failed (%i-%s)", errno, fd_io_strerror( errno ) ));
378 :
379 0 : watch_args.watch.drain_output_fd = pipefd[0];
380 0 : if( FD_UNLIKELY( -1==dup2( pipefd[ 1 ], STDERR_FILENO ) ) ) FD_LOG_ERR(( "dup2() failed (%i-%s)", errno, fd_io_strerror( errno ) ));
381 0 : }
382 :
383 0 : fd_topo_run_single_process( &config->topo, 2, config->uid, config->gid, fdctl_tile_run );
384 0 : if( args->backtest.no_watch ) {
385 0 : for(;;) pause();
386 0 : } else {
387 0 : watch_cmd_fn( &watch_args, config );
388 0 : }
389 0 : }
390 :
391 : action_t fd_action_backtest = {
392 : .name = "backtest",
393 : .args = backtest_cmd_args,
394 : .fn = backtest_cmd_fn,
395 : .perm = backtest_cmd_perm,
396 : .topo = backtest_cmd_topo,
397 : };
|