15
15
16
16
*/
17
17
18
- #include "../../shared/commands/configure/configure .h"
18
+ #include "../../firedancer/topology .h"
19
19
#include "../../shared/commands/run/run.h" /* initialize_workspaces */
20
20
#include "../../shared/fd_config.h" /* config_t */
21
21
#include "../../../disco/tiles.h"
22
22
#include "../../../disco/topo/fd_cpu_topo.h" /* fd_topo_cpus */
23
23
#include "../../../disco/topo/fd_topob.h"
24
24
#include "../../../disco/topo/fd_pod_format.h"
25
25
#include "../../../discof/geyser/fd_replay_notif.h"
26
- #include "../../../flamenco/runtime/fd_runtime.h"
27
26
#include "../../../flamenco/runtime/fd_txncache.h"
28
- #include "../../../flamenco/snapshot/fd_snapshot_base.h"
29
27
30
28
#include <unistd.h> /* pause */
31
29
extern fd_topo_obj_callbacks_t * CALLBACKS [];
32
30
fd_topo_run_tile_t fdctl_tile_run ( fd_topo_tile_t const * tile );
33
31
34
- static fd_topo_obj_t *
35
- setup_topo_runtime_pub ( fd_topo_t * topo ,
36
- char const * wksp_name ,
37
- ulong mem_max ) {
38
- fd_topo_obj_t * obj = fd_topob_obj ( topo , "runtime_pub" , wksp_name );
39
- FD_TEST ( fd_pod_insertf_ulong ( topo -> props , mem_max , "obj.%lu.mem_max" , obj -> id ) );
40
- FD_TEST ( fd_pod_insertf_ulong ( topo -> props , 12UL , "obj.%lu.wksp_tag" , obj -> id ) );
41
- return obj ;
42
- }
43
-
44
- static fd_topo_obj_t *
45
- setup_topo_txncache ( fd_topo_t * topo ,
46
- char const * wksp_name ,
47
- ulong max_rooted_slots ,
48
- ulong max_live_slots ,
49
- ulong max_txn_per_slot ,
50
- ulong max_constipated_slots ) {
51
- fd_topo_obj_t * obj = fd_topob_obj ( topo , "txncache" , wksp_name );
52
-
53
- FD_TEST ( fd_pod_insertf_ulong ( topo -> props , max_rooted_slots , "obj.%lu.max_rooted_slots" , obj -> id ) );
54
- FD_TEST ( fd_pod_insertf_ulong ( topo -> props , max_live_slots , "obj.%lu.max_live_slots" , obj -> id ) );
55
- FD_TEST ( fd_pod_insertf_ulong ( topo -> props , max_txn_per_slot , "obj.%lu.max_txn_per_slot" , obj -> id ) );
56
- FD_TEST ( fd_pod_insertf_ulong ( topo -> props , max_constipated_slots , "obj.%lu.max_constipated_slots" , obj -> id ) );
57
-
58
- return obj ;
59
- }
60
-
61
- #include <sys/random.h>
62
- #include "../../../flamenco/runtime/fd_blockstore.h"
63
- static fd_topo_obj_t *
64
- setup_topo_blockstore ( fd_topo_t * topo ,
65
- char const * wksp_name ,
66
- ulong shred_max ,
67
- ulong block_max ,
68
- ulong idx_max ,
69
- ulong txn_max ,
70
- ulong alloc_max ) {
71
- fd_topo_obj_t * obj = fd_topob_obj ( topo , "blockstore" , wksp_name );
72
-
73
- ulong seed ;
74
- FD_TEST ( sizeof (ulong ) == getrandom ( & seed , sizeof (ulong ), 0 ) );
75
-
76
- FD_TEST ( fd_pod_insertf_ulong ( topo -> props , 1UL , "obj.%lu.wksp_tag" , obj -> id ) );
77
- FD_TEST ( fd_pod_insertf_ulong ( topo -> props , seed , "obj.%lu.seed" , obj -> id ) );
78
- FD_TEST ( fd_pod_insertf_ulong ( topo -> props , shred_max , "obj.%lu.shred_max" , obj -> id ) );
79
- FD_TEST ( fd_pod_insertf_ulong ( topo -> props , block_max , "obj.%lu.block_max" , obj -> id ) );
80
- FD_TEST ( fd_pod_insertf_ulong ( topo -> props , idx_max , "obj.%lu.idx_max" , obj -> id ) );
81
- FD_TEST ( fd_pod_insertf_ulong ( topo -> props , txn_max , "obj.%lu.txn_max" , obj -> id ) );
82
- FD_TEST ( fd_pod_insertf_ulong ( topo -> props , alloc_max , "obj.%lu.alloc_max" , obj -> id ) );
83
-
84
- /* DO NOT MODIFY LOOSE WITHOUT CHANGING HOW BLOCKSTORE ALLOCATES INTERNAL STRUCTURES */
85
-
86
- ulong blockstore_footprint = fd_blockstore_footprint ( shred_max , block_max , idx_max , txn_max ) + alloc_max ;
87
- FD_TEST ( fd_pod_insertf_ulong ( topo -> props , blockstore_footprint , "obj.%lu.loose" , obj -> id ) );
88
-
89
- return obj ;
90
- }
91
-
92
- static void
93
- setup_snapshots ( config_t * config ,
94
- fd_topo_tile_t * tile ) {
95
- uchar incremental_is_file , incremental_is_url ;
96
- if ( strnlen ( config -> tiles .replay .incremental , PATH_MAX )> 0UL ) {
97
- incremental_is_file = 1U ;
98
- } else {
99
- incremental_is_file = 0U ;
100
- }
101
- if ( strnlen ( config -> tiles .replay .incremental_url , PATH_MAX )> 0UL ) {
102
- incremental_is_url = 1U ;
103
- } else {
104
- incremental_is_url = 0U ;
105
- }
106
- if ( FD_UNLIKELY ( incremental_is_file && incremental_is_url ) ) {
107
- FD_LOG_ERR (( "At most one of the incremental snapshot source strings in the configuration file under [tiles.replay.incremental] and [tiles.replay.incremental_url] may be set." ));
108
- }
109
- tile -> replay .incremental_src_type = INT_MAX ;
110
- if ( FD_LIKELY ( incremental_is_url ) ) {
111
- strncpy ( tile -> replay .incremental , config -> tiles .replay .incremental_url , sizeof (tile -> replay .incremental ) );
112
- tile -> replay .incremental_src_type = FD_SNAPSHOT_SRC_HTTP ;
113
- }
114
- if ( FD_UNLIKELY ( incremental_is_file ) ) {
115
- strncpy ( tile -> replay .incremental , config -> tiles .replay .incremental , sizeof (tile -> replay .incremental ) );
116
- tile -> replay .incremental_src_type = FD_SNAPSHOT_SRC_FILE ;
117
- }
118
-
119
- uchar snapshot_is_file , snapshot_is_url ;
120
- if ( strnlen ( config -> tiles .replay .snapshot , PATH_MAX )> 0UL ) {
121
- snapshot_is_file = 1U ;
122
- } else {
123
- snapshot_is_file = 0U ;
124
- }
125
- if ( strnlen ( config -> tiles .replay .snapshot_url , PATH_MAX )> 0UL ) {
126
- snapshot_is_url = 1U ;
127
- } else {
128
- snapshot_is_url = 0U ;
129
- }
130
- if ( FD_UNLIKELY ( snapshot_is_file && snapshot_is_url ) ) {
131
- FD_LOG_ERR (( "At most one of the full snapshot source strings in the configuration file under [tiles.replay.snapshot] and [tiles.replay.snapshot_url] may be set." ));
132
- }
133
- tile -> replay .snapshot_src_type = INT_MAX ;
134
- if ( FD_LIKELY ( snapshot_is_url ) ) {
135
- strncpy ( tile -> replay .snapshot , config -> tiles .replay .snapshot_url , sizeof (tile -> replay .snapshot ) );
136
- tile -> replay .snapshot_src_type = FD_SNAPSHOT_SRC_HTTP ;
137
- }
138
- if ( FD_UNLIKELY ( snapshot_is_file ) ) {
139
- strncpy ( tile -> replay .snapshot , config -> tiles .replay .snapshot , sizeof (tile -> replay .snapshot ) );
140
- tile -> replay .snapshot_src_type = FD_SNAPSHOT_SRC_FILE ;
141
- }
142
- }
143
-
144
32
static void
145
33
backtest_topo ( config_t * config ) {
146
34
fd_topo_cpus_t cpus [1 ];
@@ -164,75 +52,19 @@ backtest_topo( config_t * config ) {
164
52
/**********************************************************************/
165
53
fd_topob_wksp ( topo , "metric" );
166
54
fd_topob_wksp ( topo , "metric_in" );
167
- fd_topo_tile_t * metric_tile = fd_topob_tile ( topo , "metric" , "metric" , "metric_in" , metric_cpu_idx , 0 , 0 );
168
- if ( FD_UNLIKELY ( !fd_cstr_to_ip4_addr ( config -> tiles .metric .prometheus_listen_address , & metric_tile -> metric .prometheus_listen_addr ) ) )
169
- FD_LOG_ERR (( "failed to parse prometheus listen address `%s`" , config -> tiles .metric .prometheus_listen_address ));
170
- metric_tile -> metric .prometheus_listen_port = config -> tiles .metric .prometheus_listen_port ;
55
+ fd_topob_tile ( topo , "metric" , "metric" , "metric_in" , metric_cpu_idx , 0 , 0 );
171
56
172
57
/**********************************************************************/
173
58
/* Add the rocksdb tile to topo */
174
59
/**********************************************************************/
175
60
fd_topob_wksp ( topo , "rocksdb" );
176
- fd_topo_tile_t * rocksdb_tile = fd_topob_tile ( topo , "arch_b" , "rocksdb" , "metric_in" , rocksdb_cpu_idx , 0 , 0 );
177
- rocksdb_tile -> archiver .end_slot = config -> tiles .archiver .end_slot ;
178
- strncpy ( rocksdb_tile -> archiver .archiver_path , config -> tiles .archiver .archiver_path , PATH_MAX );
179
- if ( FD_UNLIKELY ( 0 == strlen ( rocksdb_tile -> archiver .archiver_path ) ) ) {
180
- FD_LOG_ERR (( "Rocksdb not found, check `archiver.archiver_path` in toml" ));
181
- } else {
182
- FD_LOG_NOTICE (( "Found rocksdb path from config: %s" , rocksdb_tile -> archiver .archiver_path ));
183
- }
61
+ fd_topo_tile_t * rocksdb_tile = fd_topob_tile ( topo , "arch_b" , "rocksdb" , "metric_in" , rocksdb_cpu_idx , 0 , 0 );
184
62
185
63
/**********************************************************************/
186
64
/* Add the replay tile to topo */
187
65
/**********************************************************************/
188
66
fd_topob_wksp ( topo , "replay" );
189
67
fd_topo_tile_t * replay_tile = fd_topob_tile ( topo , "replay" , "replay" , "metric_in" , replay_cpu_idx , 0 , 0 );
190
- replay_tile -> replay .fec_max = config -> tiles .shred .max_pending_shred_sets ;
191
- replay_tile -> replay .max_vote_accounts = config -> firedancer .runtime .limits .max_vote_accounts ;
192
-
193
- /* specified by [tiles.replay] */
194
-
195
- strncpy ( replay_tile -> replay .blockstore_file , config -> firedancer .blockstore .file , sizeof (replay_tile -> replay .blockstore_file ) );
196
- strncpy ( replay_tile -> replay .blockstore_checkpt , config -> firedancer .blockstore .checkpt , sizeof (replay_tile -> replay .blockstore_checkpt ) );
197
-
198
- replay_tile -> replay .tx_metadata_storage = config -> rpc .extended_tx_metadata_storage ;
199
- strncpy ( replay_tile -> replay .capture , config -> tiles .replay .capture , sizeof (replay_tile -> replay .capture ) );
200
- strncpy ( replay_tile -> replay .funk_checkpt , config -> tiles .replay .funk_checkpt , sizeof (replay_tile -> replay .funk_checkpt ) );
201
- replay_tile -> replay .funk_rec_max = config -> tiles .replay .funk_rec_max ;
202
- replay_tile -> replay .funk_sz_gb = config -> tiles .replay .funk_sz_gb ;
203
- replay_tile -> replay .funk_txn_max = config -> tiles .replay .funk_txn_max ;
204
- strncpy ( replay_tile -> replay .funk_file , config -> tiles .replay .funk_file , sizeof (replay_tile -> replay .funk_file ) );
205
- replay_tile -> replay .plugins_enabled = config -> tiles .gui .enabled ;
206
-
207
- if ( FD_UNLIKELY ( !strncmp ( config -> tiles .replay .genesis , "" , 1 )
208
- && !strncmp ( config -> tiles .replay .snapshot , "" , 1 ) ) ) {
209
- fd_cstr_printf_check ( config -> tiles .replay .genesis , PATH_MAX , NULL , "%s/genesis.bin" , config -> paths .ledger );
210
- }
211
- strncpy ( replay_tile -> replay .genesis , config -> tiles .replay .genesis , sizeof (replay_tile -> replay .genesis ) );
212
-
213
- setup_snapshots ( config , replay_tile );
214
-
215
- strncpy ( replay_tile -> replay .slots_replayed , config -> tiles .replay .slots_replayed , sizeof (replay_tile -> replay .slots_replayed ) );
216
- strncpy ( replay_tile -> replay .status_cache , config -> tiles .replay .status_cache , sizeof (replay_tile -> replay .status_cache ) );
217
- strncpy ( replay_tile -> replay .cluster_version , config -> tiles .replay .cluster_version , sizeof (replay_tile -> replay .cluster_version ) );
218
- replay_tile -> replay .bank_tile_count = config -> layout .bank_tile_count ;
219
- replay_tile -> replay .exec_tile_count = config -> firedancer .layout .exec_tile_count ;
220
- replay_tile -> replay .writer_tile_cuont = config -> firedancer .layout .writer_tile_count ;
221
- strncpy ( replay_tile -> replay .tower_checkpt , config -> tiles .replay .tower_checkpt , sizeof (replay_tile -> replay .tower_checkpt ) );
222
-
223
- replay_tile -> replay .enable_features_cnt = config -> tiles .replay .enable_features_cnt ;
224
- for ( ulong i = 0 ; i < replay_tile -> replay .enable_features_cnt ; i ++ ) {
225
- strncpy ( replay_tile -> replay .enable_features [i ], config -> tiles .replay .enable_features [i ], sizeof (replay_tile -> replay .enable_features [i ]) );
226
- }
227
-
228
- /* not specified by [tiles.replay] */
229
-
230
- strncpy ( replay_tile -> replay .identity_key_path , config -> paths .identity_key , sizeof (replay_tile -> replay .identity_key_path ) );
231
- replay_tile -> replay .ip_addr = config -> net .ip_addr ;
232
- replay_tile -> replay .vote = config -> firedancer .consensus .vote ;
233
- strncpy ( replay_tile -> replay .vote_account_path , config -> paths .vote_account , sizeof (replay_tile -> replay .vote_account_path ) );
234
- replay_tile -> replay .full_interval = config -> tiles .batch .full_interval ;
235
- replay_tile -> replay .incremental_interval = config -> tiles .batch .incremental_interval ;
236
68
237
69
/**********************************************************************/
238
70
/* Add the executor tiles to topo */
@@ -397,7 +229,7 @@ backtest_topo( config_t * config ) {
397
229
}
398
230
399
231
/* root_slot_obj shared by replay and rocksdb tiles */
400
- fd_topob_wksp ( topo , "root_slot" );
232
+ fd_topob_wksp ( topo , "root_slot" );
401
233
fd_topo_obj_t * root_slot_obj = fd_topob_obj ( topo , "fseq" , "root_slot" );
402
234
fd_topob_tile_uses ( topo , replay_tile , root_slot_obj , FD_SHMEM_JOIN_MODE_READ_WRITE );
403
235
fd_topob_tile_uses ( topo , rocksdb_tile , root_slot_obj , FD_SHMEM_JOIN_MODE_READ_ONLY );
@@ -427,6 +259,29 @@ backtest_topo( config_t * config ) {
427
259
fd_topob_tile_uses ( topo , replay_tile , constipated_obj , FD_SHMEM_JOIN_MODE_READ_WRITE );
428
260
FD_TEST ( fd_pod_insertf_ulong ( topo -> props , constipated_obj -> id , "constipate" ) );
429
261
262
+ for ( ulong i = 0UL ; i < topo -> tile_cnt ; i ++ ) {
263
+ fd_topo_tile_t * tile = & topo -> tiles [ i ];
264
+ if ( !strcmp ( tile -> name , "rocksdb" ) ) {
265
+ tile -> archiver .end_slot = config -> tiles .archiver .end_slot ;
266
+ strncpy ( tile -> archiver .archiver_path , config -> tiles .archiver .archiver_path , PATH_MAX );
267
+ if ( FD_UNLIKELY ( 0 == strlen ( tile -> archiver .archiver_path ) ) ) {
268
+ FD_LOG_ERR (( "Rocksdb not found, check `archiver.archiver_path` in toml" ));
269
+ } else {
270
+ FD_LOG_NOTICE (( "Found rocksdb path from config: %s" , tile -> archiver .archiver_path ));
271
+ }
272
+ } else if ( !fd_topo_configure_tile ( tile , config ) ) {
273
+ FD_LOG_ERR (( "unknown tile name %lu `%s`" , i , tile -> name ));
274
+ }
275
+
276
+ /* Override */
277
+ if ( !strcmp ( tile -> name , "replay" ) ) {
278
+ tile -> replay .enable_features_cnt = config -> tiles .replay .enable_features_cnt ;
279
+ for ( ulong i = 0 ; i < tile -> replay .enable_features_cnt ; i ++ ) {
280
+ strncpy ( tile -> replay .enable_features [i ], config -> tiles .replay .enable_features [i ], sizeof (tile -> replay .enable_features [i ]) );
281
+ }
282
+ }
283
+ }
284
+
430
285
/**********************************************************************/
431
286
/* Finish and print out the topo information */
432
287
/**********************************************************************/
@@ -436,7 +291,7 @@ backtest_topo( config_t * config ) {
436
291
437
292
static void
438
293
backtest_cmd_fn ( args_t * args FD_PARAM_UNUSED ,
439
- config_t * config ) {
294
+ config_t * config ) {
440
295
FD_LOG_NOTICE (( "Start to run the backtest cmd" ));
441
296
backtest_topo ( config );
442
297
@@ -459,13 +314,13 @@ backtest_cmd_fn( args_t * args FD_PARAM_UNUSED,
459
314
460
315
static void
461
316
backtest_cmd_perm ( args_t * args FD_PARAM_UNUSED ,
462
- fd_cap_chk_t * chk FD_PARAM_UNUSED ,
463
- config_t const * config FD_PARAM_UNUSED ) {}
317
+ fd_cap_chk_t * chk FD_PARAM_UNUSED ,
318
+ config_t const * config FD_PARAM_UNUSED ) {}
464
319
465
320
static void
466
321
backtest_cmd_args ( int * pargc FD_PARAM_UNUSED ,
467
- char * * * pargv FD_PARAM_UNUSED ,
468
- args_t * args FD_PARAM_UNUSED ) {}
322
+ char * * * pargv FD_PARAM_UNUSED ,
323
+ args_t * args FD_PARAM_UNUSED ) {}
469
324
470
325
action_t fd_action_backtest = {
471
326
.name = "backtest" ,
0 commit comments