Skip to content

Commit 3840d97

Browse files
committed
solcap: v2
1 parent 421040e commit 3840d97

34 files changed

+1167
-3821
lines changed

contrib/test/run_solcap_tests.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,5 @@ $OBJDIR/bin/firedancer-dev configure init all --config $DUMP/$LEDGER/devnet-3987
7676
$OBJDIR/bin/firedancer-dev backtest --config $DUMP/$LEDGER/devnet-398736132_current.toml
7777
$OBJDIR/bin/firedancer-dev configure fini all --config $DUMP/$LEDGER/devnet-398736132_current.toml &> /dev/null
7878

79-
$OBJDIR/bin/fd_solcap_import $DUMP/$LEDGER/bank_hash_details/ $DUMP/$LEDGER/solana.solcap
80-
$OBJDIR/bin/fd_solcap_diff $DUMP/$LEDGER/solana.solcap $DUMP/$LEDGER/fd.solcap -v 4
81-
8279
# check that the ledger is not corrupted after a run
8380
check_ledger_checksum

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

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,14 @@ backtest_topo( config_t * config ) {
9595
#define FOR(cnt) for( ulong i=0UL; i<cnt; i++ )
9696
FOR(exec_tile_cnt) fd_topob_tile( topo, "exec", "exec", "metric_in", cpu_idx++, 0, 0 );
9797
98+
/**********************************************************************/
99+
/* Add the capture tile to topo */
100+
/**********************************************************************/
101+
if (solcap_enabled) {
102+
fd_topob_wksp( topo, "captur" );
103+
fd_topob_tile( topo, "captur", "captur", "metric_in", cpu_idx++, 0, 0 );
104+
}
105+
98106
/**********************************************************************/
99107
/* Add the snapshot tiles to topo */
100108
/**********************************************************************/
@@ -231,15 +239,7 @@ backtest_topo( config_t * config ) {
231239
/**********************************************************************/
232240
fd_topob_wksp( topo, "exec_replay" );
233241

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-
if( FD_UNLIKELY( solcap_enabled ) ) {
238-
/* TODO: remove this with solcap V2 */
239-
FOR(exec_tile_cnt) fd_topob_link( topo, "exec_replay", "exec_replay", 1024UL, FD_CAPTURE_CTX_ACCOUNT_UPDATE_MSG_FOOTPRINT, 1UL );
240-
} else {
241-
FOR(exec_tile_cnt) fd_topob_link( topo, "exec_replay", "exec_replay", 16384UL, sizeof(fd_exec_task_done_msg_t), 1UL );
242-
}
242+
FOR(exec_tile_cnt) fd_topob_link( topo, "exec_replay", "exec_replay", 16384UL, sizeof(fd_exec_task_done_msg_t), 1UL );
243243

244244
FOR(exec_tile_cnt) fd_topob_tile_out( topo, "exec", i, "exec_replay", i );
245245
FOR(exec_tile_cnt) fd_topob_tile_in( topo, "replay", 0UL, "metric_in", "exec_replay", i, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
@@ -248,6 +248,15 @@ backtest_topo( config_t * config ) {
248248
/* Setup the shared objs used by replay and exec tiles */
249249
/**********************************************************************/
250250

251+
if ( FD_UNLIKELY( solcap_enabled) ) {
252+
fd_topob_link( topo, "cap_repl", "captur", 32UL, SOLCAP_WRITE_ACCOUNT_DATA_MTU, 1UL );
253+
fd_topob_tile_out( topo, "replay", 0UL, "cap_repl", 0UL );
254+
fd_topob_tile_in( topo, "captur", 0UL, "metric_in", "cap_repl", 0UL, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
255+
FOR(exec_tile_cnt) fd_topob_link( topo, "cap_exec", "captur", 32UL, SOLCAP_WRITE_ACCOUNT_DATA_MTU, 1UL );
256+
FOR(exec_tile_cnt) fd_topob_tile_out( topo, "exec", i, "cap_exec", i );
257+
FOR(exec_tile_cnt) fd_topob_tile_in( topo, "captur", 0UL, "metric_in", "cap_exec", i, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
258+
}
259+
251260
fd_topob_wksp( topo, "store" );
252261
fd_topo_obj_t * store_obj = setup_topo_store( topo, "store", config->firedancer.store.max_completed_shred_sets, 1 );
253262
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
@@ -98,6 +98,7 @@ extern fd_topo_run_tile_t fd_tile_archiver_feeder;
9898
extern fd_topo_run_tile_t fd_tile_archiver_writer;
9999
extern fd_topo_run_tile_t fd_tile_archiver_playback;
100100
extern fd_topo_run_tile_t fd_tile_shredcap;
101+
extern fd_topo_run_tile_t fd_tile_captur;
101102

102103
extern fd_topo_run_tile_t fd_tile_snapct;
103104
extern fd_topo_run_tile_t fd_tile_snapld;
@@ -151,6 +152,7 @@ fd_topo_run_tile_t * TILES[] = {
151152
&fd_tile_snapin,
152153
&fd_tile_genesi,
153154
&fd_tile_ipecho,
155+
&fd_tile_captur,
154156
NULL,
155157
};
156158

src/app/firedancer/topology.c

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

1193+
} else if( FD_UNLIKELY( !strcmp( tile->name, "captur" ) ) ) {
1194+
1195+
strncpy( tile->capctx.solcap_capture, config->capture.solcap_capture, sizeof(tile->capctx.solcap_capture) );
1196+
11931197
} else {
11941198
FD_LOG_ERR(( "unknown tile name `%s`", tile->name ));
11951199
}

src/app/shared/fd_config.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,10 @@ struct fd_configf {
150150
struct {
151151
ulong max_completed_shred_sets;
152152
} store;
153+
154+
struct {
155+
char path[ PATH_MAX ];
156+
} capctx;
153157
};
154158

155159
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
@@ -574,6 +574,10 @@ struct fd_topo_tile {
574574
uint target_gid;
575575
uint target_uid;
576576
} genesi;
577+
578+
struct {
579+
char solcap_capture[ PATH_MAX ];
580+
} capctx;
577581
};
578582
};
579583

src/discof/capture/Local.mk

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
ifdef FD_HAS_INT128
2+
ifdef FD_HAS_ALLOCA
3+
$(call add-objs,fd_capture_tile,fd_discof)
4+
endif
5+
endif

0 commit comments

Comments
 (0)