Skip to content

Commit 2a98888

Browse files
committed
solcap: v2
1 parent 06fab31 commit 2a98888

34 files changed

+1184
-3830
lines changed

src/app/firedancer-dev/commands/backtest.c

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,14 @@ backtest_topo( config_t * config ) {
8787
#define FOR(cnt) for( ulong i=0UL; i<cnt; i++ )
8888
FOR(exec_tile_cnt) fd_topob_tile( topo, "exec", "exec", "metric_in", cpu_idx++, 0, 0 );
8989
90+
/**********************************************************************/
91+
/* Add the capture tile to topo */
92+
/**********************************************************************/
93+
if (solcap_enabled) {
94+
fd_topob_wksp( topo, "captur" );
95+
fd_topob_tile( topo, "captur", "captur", "metric_in", cpu_idx++, 0, 0 );
96+
}
97+
9098
/**********************************************************************/
9199
/* Add the snapshot tiles to topo */
92100
/**********************************************************************/
@@ -223,15 +231,7 @@ backtest_topo( config_t * config ) {
223231
/**********************************************************************/
224232
fd_topob_wksp( topo, "exec_replay" );
225233

226-
/* If solcap is enabled, we need to overload this link to also send
227-
solcap account updates to the replay tile. We can't use a separate
228-
link for this without introducing a race. This will get removed with solcap V2. */
229-
if( FD_UNLIKELY( solcap_enabled ) ) {
230-
/* TODO: remove this with solcap V2 */
231-
FOR(exec_tile_cnt) fd_topob_link( topo, "exec_replay", "exec_replay", 1024UL, FD_CAPTURE_CTX_ACCOUNT_UPDATE_MSG_FOOTPRINT, 1UL );
232-
} else {
233-
FOR(exec_tile_cnt) fd_topob_link( topo, "exec_replay", "exec_replay", 16384UL, sizeof(fd_exec_task_done_msg_t), 1UL );
234-
}
234+
FOR(exec_tile_cnt) fd_topob_link( topo, "exec_replay", "exec_replay", 16384UL, sizeof(fd_exec_task_done_msg_t), 1UL );
235235

236236
FOR(exec_tile_cnt) fd_topob_tile_out( topo, "exec", i, "exec_replay", i );
237237
FOR(exec_tile_cnt) fd_topob_tile_in( topo, "replay", 0UL, "metric_in", "exec_replay", i, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
@@ -240,6 +240,15 @@ backtest_topo( config_t * config ) {
240240
/* Setup the shared objs used by replay and exec tiles */
241241
/**********************************************************************/
242242

243+
if ( FD_UNLIKELY( solcap_enabled) ) {
244+
fd_topob_link( topo, "cap_repl", "captur", 32UL, SOLCAP_WRITE_ACCOUNT_DATA_MTU, 1UL );
245+
fd_topob_tile_out( topo, "replay", 0UL, "cap_repl", 0UL );
246+
fd_topob_tile_in( topo, "captur", 0UL, "metric_in", "cap_repl", 0UL, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
247+
FOR(exec_tile_cnt) fd_topob_link( topo, "cap_exec", "captur", 32UL, SOLCAP_WRITE_ACCOUNT_DATA_MTU, 1UL );
248+
FOR(exec_tile_cnt) fd_topob_tile_out( topo, "exec", i, "cap_exec", i );
249+
FOR(exec_tile_cnt) fd_topob_tile_in( topo, "captur", 0UL, "metric_in", "cap_exec", i, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
250+
}
251+
243252
fd_topob_wksp( topo, "store" );
244253
fd_topo_obj_t * store_obj = setup_topo_store( topo, "store", config->firedancer.store.max_completed_shred_sets, 1 );
245254
fd_topob_tile_uses( topo, backt_tile, store_obj, FD_SHMEM_JOIN_MODE_READ_WRITE );

src/app/firedancer-dev/main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ extern fd_topo_run_tile_t fd_tile_archiver_feeder;
101101
extern fd_topo_run_tile_t fd_tile_archiver_writer;
102102
extern fd_topo_run_tile_t fd_tile_archiver_playback;
103103
extern fd_topo_run_tile_t fd_tile_shredcap;
104+
extern fd_topo_run_tile_t fd_tile_captur;
104105

105106
extern fd_topo_run_tile_t fd_tile_snaprd;
106107
extern fd_topo_run_tile_t fd_tile_snapdc;
@@ -152,6 +153,7 @@ fd_topo_run_tile_t * TILES[] = {
152153
&fd_tile_snapin,
153154
&fd_tile_genesi,
154155
&fd_tile_ipecho,
156+
&fd_tile_captur,
155157
NULL,
156158
};
157159

src/app/firedancer/topology.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,6 +1119,10 @@ fd_topo_configure_tile( fd_topo_tile_t * tile,
11191119
tile->shredcap.enable_publish_stake_weights = 0; /* this is not part of the config */
11201120
strncpy( tile->shredcap.manifest_path, "", PATH_MAX ); /* this is not part of the config */
11211121

1122+
} else if( FD_UNLIKELY( !strcmp( tile->name, "captur" ) ) ) {
1123+
1124+
strncpy( tile->capctx.solcap_capture, config->capture.solcap_capture, sizeof(tile->capctx.solcap_capture) );
1125+
11221126
} else {
11231127
FD_LOG_ERR(( "unknown tile name `%s`", tile->name ));
11241128
}

src/app/shared/fd_config.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@ struct fd_configf {
155155
struct {
156156
ulong max_completed_shred_sets;
157157
} store;
158+
159+
struct {
160+
char path[ PATH_MAX ];
161+
} capctx;
158162
};
159163

160164
typedef struct fd_configf fd_configf_t;

src/disco/stem/fd_stem.c

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@
3737
or monitoring tools. The ctx is a user-provided context object from
3838
when the stem tile was initialized.
3939
40+
CUSTOM_INPUT_SELECTION
41+
Is called to determine if the stem should shuffle the input
42+
selection. The ctx is a user-provided context object from when the
43+
stem tile was initialized. The stem should return 1 if the input
44+
selection should be shuffled, 0 otherwise. Used alongside
45+
STEM_CUSTOM_INPUT_ADVANCE_FLAG to determine if the input selection
46+
should be advanced.
47+
4048
BEFORE_CREDIT
4149
Is called every iteration of the stem run loop, whether there is a
4250
new frag ready to receive or not. This callback is also still
@@ -484,14 +492,19 @@ STEM_(run1)( ulong in_cnt,
484492
/* We also do the same with the ins to prevent there being a
485493
correlated order frag origins from different inputs
486494
downstream at extreme fan in and extreme in load. */
487-
488-
if( FD_LIKELY( in_cnt>1UL ) ) {
495+
#ifdef STEM_CUSTOM_INPUT_SELECTION
496+
int shuffle_flag = STEM_CUSTOM_INPUT_ADVANCE_FLAG(ctx);
497+
#else
498+
int shuffle_flag = 1;
499+
#endif
500+
if( FD_LIKELY( in_cnt>1UL && shuffle_flag ) ) {
489501
swap_idx = (ulong)fd_rng_uint_roll( rng, (uint)in_cnt );
490502
fd_stem_tile_in_t in_tmp;
491503
in_tmp = in[ swap_idx ];
492504
in[ swap_idx ] = in[ 0 ];
493505
in[ 0 ] = in_tmp;
494506
}
507+
495508
}
496509

497510
/* Reload housekeeping timer */
@@ -579,10 +592,12 @@ STEM_(run1)( ulong in_cnt,
579592
}
580593
#endif
581594

582-
fd_stem_tile_in_t * this_in = &in[ in_seq ];
595+
fd_stem_tile_in_t * this_in = &in[ in_seq ];
596+
#ifdef STEM_CUSTOM_INPUT_SELECTION
597+
#else
583598
in_seq++;
584599
if( in_seq>=in_cnt ) in_seq = 0UL; /* cmov */
585-
600+
#endif
586601
/* Check if this in has any new fragments to mux */
587602

588603
ulong this_in_seq = this_in->seq;
@@ -714,6 +729,15 @@ STEM_(run1)( ulong in_cnt,
714729
this_in->accum[ FD_METRICS_COUNTER_LINK_CONSUMED_COUNT_OFF ]++;
715730
this_in->accum[ FD_METRICS_COUNTER_LINK_CONSUMED_SIZE_BYTES_OFF ] += (uint)sz;
716731

732+
/* Custom input selection: advance to next input based on flag */
733+
#ifdef STEM_CUSTOM_INPUT_SELECTION
734+
int should_advance = STEM_CUSTOM_INPUT_ADVANCE_FLAG(ctx);
735+
if( FD_LIKELY( should_advance ) ) {
736+
in_seq++;
737+
if( in_seq>=in_cnt ) in_seq = 0UL; /* cmov */
738+
}
739+
#endif
740+
717741
metric_regime_ticks[1] += housekeeping_ticks;
718742
metric_regime_ticks[4] += prefrag_ticks;
719743
long next = fd_tickcount();
@@ -815,3 +839,5 @@ STEM_(run)( fd_topo_t * topo,
815839
#undef STEM_CALLBACK_RETURNABLE_FRAG
816840
#undef STEM_CALLBACK_AFTER_FRAG
817841
#undef STEM_CALLBACK_AFTER_POLL_OVERRUN
842+
#undef STEM_CUSTOM_INPUT_SELECTION
843+
#undef STEM_CUSTOM_INPUT_ADVANCE_FLAG

src/disco/topo/fd_topo.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,10 @@ struct fd_topo_tile {
560560

561561
char genesis_path[ PATH_MAX ];
562562
} genesi;
563+
564+
struct {
565+
char solcap_capture[ PATH_MAX ];
566+
} capctx;
563567
};
564568
};
565569

src/discof/capture/Local.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
$(call add-objs,fd_capture_tile,fd_discof)

0 commit comments

Comments
 (0)