Skip to content

Commit a0970ba

Browse files
committed
solcap: v2
1 parent 67e432f commit a0970ba

34 files changed

+1202
-3820
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
@@ -100,6 +100,14 @@ backtest_topo( config_t * config ) {
100100
#define FOR(cnt) for( ulong i=0UL; i<cnt; i++ )
101101
FOR(exec_tile_cnt) fd_topob_tile( topo, "exec", "exec", "metric_in", cpu_idx++, 0, 0 );
102102
103+
/**********************************************************************/
104+
/* Add the capture tile to topo */
105+
/**********************************************************************/
106+
if (solcap_enabled) {
107+
fd_topob_wksp( topo, "captur" );
108+
fd_topob_tile( topo, "captur", "captur", "metric_in", cpu_idx++, 0, 0 );
109+
}
110+
103111
/**********************************************************************/
104112
/* Add the snapshot tiles to topo */
105113
/**********************************************************************/
@@ -236,15 +244,7 @@ backtest_topo( config_t * config ) {
236244
/**********************************************************************/
237245
fd_topob_wksp( topo, "exec_replay" );
238246

239-
/* If solcap is enabled, we need to overload this link to also send
240-
solcap account updates to the replay tile. We can't use a separate
241-
link for this without introducing a race. This will get removed with solcap V2. */
242-
if( FD_UNLIKELY( solcap_enabled ) ) {
243-
/* TODO: remove this with solcap V2 */
244-
FOR(exec_tile_cnt) fd_topob_link( topo, "exec_replay", "exec_replay", 1024UL, FD_CAPTURE_CTX_ACCOUNT_UPDATE_MSG_FOOTPRINT, 1UL );
245-
} else {
246-
FOR(exec_tile_cnt) fd_topob_link( topo, "exec_replay", "exec_replay", 16384UL, sizeof(fd_exec_task_done_msg_t), 1UL );
247-
}
247+
FOR(exec_tile_cnt) fd_topob_link( topo, "exec_replay", "exec_replay", 16384UL, sizeof(fd_exec_task_done_msg_t), 1UL );
248248

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

256+
if ( FD_UNLIKELY( solcap_enabled) ) {
257+
fd_topob_link( topo, "cap_repl", "captur", 32UL, SOLCAP_WRITE_ACCOUNT_DATA_MTU, 1UL );
258+
fd_topob_tile_out( topo, "replay", 0UL, "cap_repl", 0UL );
259+
fd_topob_tile_in( topo, "captur", 0UL, "metric_in", "cap_repl", 0UL, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
260+
FOR(exec_tile_cnt) fd_topob_link( topo, "cap_exec", "captur", 32UL, SOLCAP_WRITE_ACCOUNT_DATA_MTU, 1UL );
261+
FOR(exec_tile_cnt) fd_topob_tile_out( topo, "exec", i, "cap_exec", i );
262+
FOR(exec_tile_cnt) fd_topob_tile_in( topo, "captur", 0UL, "metric_in", "cap_exec", i, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
263+
}
264+
256265
fd_topob_wksp( topo, "store" );
257266
fd_topo_obj_t * store_obj = setup_topo_store( topo, "store", config->firedancer.store.max_completed_shred_sets, 1 );
258267
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
@@ -106,6 +106,7 @@ extern fd_topo_run_tile_t fd_tile_archiver_feeder;
106106
extern fd_topo_run_tile_t fd_tile_archiver_writer;
107107
extern fd_topo_run_tile_t fd_tile_archiver_playback;
108108
extern fd_topo_run_tile_t fd_tile_shredcap;
109+
extern fd_topo_run_tile_t fd_tile_captur;
109110

110111
extern fd_topo_run_tile_t fd_tile_snapct;
111112
extern fd_topo_run_tile_t fd_tile_snapld;
@@ -161,6 +162,7 @@ fd_topo_run_tile_t * TILES[] = {
161162
&fd_tile_snapwr,
162163
&fd_tile_genesi,
163164
&fd_tile_ipecho,
165+
&fd_tile_captur,
164166
NULL,
165167
};
166168

src/app/firedancer/topology.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "../../util/tile/fd_tile_private.h"
2121
#include "../../discof/restore/utils/fd_ssctrl.h"
2222
#include "../../discof/restore/utils/fd_ssmsg.h"
23+
#include "../../flamenco/capture/fd_solcap_writer.h"
2324
#include "../../flamenco/progcache/fd_progcache_admin.h"
2425
#include "../../vinyl/meta/fd_vinyl_meta.h"
2526

@@ -270,6 +271,8 @@ fd_topo_initialize( config_t * config ) {
270271
topo->max_page_size = fd_cstr_to_shmem_page_sz( config->hugetlbfs.max_page_size );
271272
topo->gigantic_page_threshold = config->hugetlbfs.gigantic_page_threshold_mib << 20;
272273

274+
int solcap_enabled = strlen( config->capture.solcap_capture ) > 0;
275+
273276
/* topo, name */
274277
fd_topob_wksp( topo, "metric" );
275278
fd_topob_wksp( topo, "genesi" );
@@ -508,6 +511,11 @@ fd_topo_initialize( config_t * config ) {
508511
/**/ fd_topob_tile( topo, "poh", "poh", "metric_in", tile_to_cpu[ topo->tile_cnt ], 0, 1 );
509512
FOR(sign_tile_cnt) fd_topob_tile( topo, "sign", "sign", "metric_in", tile_to_cpu[ topo->tile_cnt ], 0, 1 );
510513

514+
if( FD_UNLIKELY( solcap_enabled ) ) {
515+
fd_topob_wksp( topo, "captur" );
516+
fd_topob_tile( topo, "captur", "captur", "metric_in", tile_to_cpu[ topo->tile_cnt ], 0, 0 );
517+
}
518+
511519
/* topo, tile_name, tile_kind_id, fseq_wksp, link_name, link_kind_id, reliable, polled */
512520
FOR(gossvf_tile_cnt) for( ulong j=0UL; j<net_tile_cnt; j++ )
513521
fd_topob_tile_in( topo, "gossvf", i, "metric_in", "net_gossvf", j, FD_TOPOB_UNRELIABLE, FD_TOPOB_POLLED ); /* No reliable consumers of networking fragments, may be dropped or overrun */
@@ -728,6 +736,15 @@ fd_topo_initialize( config_t * config ) {
728736
FOR(exec_tile_cnt) fd_topob_tile_out( topo, "exec", i, "exec_replay", i );
729737
FOR(exec_tile_cnt) fd_topob_tile_in( topo, "replay", 0UL, "metric_in", "exec_replay", i, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
730738

739+
if( FD_UNLIKELY( solcap_enabled ) ) {
740+
fd_topob_link( topo, "cap_repl", "captur", 32UL, SOLCAP_WRITE_ACCOUNT_DATA_MTU, 1UL );
741+
fd_topob_tile_out( topo, "replay", 0UL, "cap_repl", 0UL );
742+
fd_topob_tile_in( topo, "captur", 0UL, "metric_in", "cap_repl", 0UL, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
743+
FOR(exec_tile_cnt) fd_topob_link( topo, "cap_exec", "captur", 32UL, SOLCAP_WRITE_ACCOUNT_DATA_MTU, 1UL );
744+
FOR(exec_tile_cnt) fd_topob_tile_out( topo, "exec", i, "cap_exec", i );
745+
FOR(exec_tile_cnt) fd_topob_tile_in( topo, "captur", 0UL, "metric_in", "cap_exec", i, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
746+
}
747+
731748
if( FD_LIKELY( !is_auto_affinity ) ) {
732749
if( FD_UNLIKELY( affinity_tile_cnt<topo->tile_cnt ) )
733750
FD_LOG_ERR(( "The topology you are using has %lu tiles, but the CPU affinity specified in the config tile as [layout.affinity] only provides for %lu cores. "
@@ -1246,6 +1263,11 @@ fd_topo_configure_tile( fd_topo_tile_t * tile,
12461263
tile->shredcap.enable_publish_stake_weights = 0; /* this is not part of the config */
12471264
strncpy( tile->shredcap.manifest_path, "", PATH_MAX ); /* this is not part of the config */
12481265

1266+
} else if( FD_UNLIKELY( !strcmp( tile->name, "captur" ) ) ) {
1267+
1268+
tile->capctx.capture_start_slot = config->capture.capture_start_slot;
1269+
strncpy( tile->capctx.solcap_capture, config->capture.solcap_capture, sizeof(tile->capctx.solcap_capture) );
1270+
12491271
} else {
12501272
FD_LOG_ERR(( "unknown tile name `%s`", tile->name ));
12511273
}

src/app/shared/fd_config.h

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

161165
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: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,11 @@ struct fd_topo_tile {
584584
uint target_gid;
585585
uint target_uid;
586586
} genesi;
587+
588+
struct {
589+
ulong capture_start_slot;
590+
char solcap_capture[ PATH_MAX ];
591+
} capctx;
587592
};
588593
};
589594

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)