Skip to content

Commit 765f7f5

Browse files
committed
solcap: v2
1 parent 5c7ec94 commit 765f7f5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1723
-4076
lines changed

contrib/test/run_solcap_tests.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,5 @@ $OBJDIR/bin/firedancer-dev configure init all --config $DUMP/$LEDGER/devnet-3987
8181
$OBJDIR/bin/firedancer-dev backtest --config $DUMP/$LEDGER/devnet-398736132_current.toml
8282
$OBJDIR/bin/firedancer-dev configure fini all --config $DUMP/$LEDGER/devnet-398736132_current.toml
8383

84-
$OBJDIR/bin/fd_solcap_import $DUMP/$LEDGER/bank_hash_details/ $DUMP/$LEDGER/solana.solcap
85-
$OBJDIR/bin/fd_solcap_diff $DUMP/$LEDGER/solana.solcap $DUMP/$LEDGER/fd.solcap -v 4
86-
8784
# check that the ledger is not corrupted after a run
8885
check_ledger_checksum

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

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#include "../../../discof/tower/fd_tower_tile.h"
2828
#include "../../../discof/replay/fd_exec.h"
2929
#include "../../../ballet/lthash/fd_lthash.h"
30-
#include "../../../flamenco/runtime/context/fd_capture_ctx.h"
30+
#include "../../../discof/capture/fd_capture_ctx.h"
3131
#include "../../../disco/pack/fd_pack_cost.h"
3232
#include "../../../flamenco/progcache/fd_progcache_admin.h"
3333

@@ -102,6 +102,14 @@ backtest_topo( config_t * config ) {
102102
#define FOR(cnt) for( ulong i=0UL; i<cnt; i++ )
103103
FOR(exec_tile_cnt) fd_topob_tile( topo, "exec", "exec", "metric_in", cpu_idx++, 0, 0 );
104104
105+
/**********************************************************************/
106+
/* Add the capture tile to topo */
107+
/**********************************************************************/
108+
if( solcap_enabled ) {
109+
fd_topob_wksp( topo, "captur" );
110+
fd_topob_tile( topo, "captur", "captur", "metric_in", cpu_idx++, 0, 0 );
111+
}
112+
105113
/**********************************************************************/
106114
/* Add the snapshot tiles to topo */
107115
/**********************************************************************/
@@ -283,15 +291,7 @@ backtest_topo( config_t * config ) {
283291
/**********************************************************************/
284292
fd_topob_wksp( topo, "exec_replay" );
285293

286-
/* If solcap is enabled, we need to overload this link to also send
287-
solcap account updates to the replay tile. We can't use a separate
288-
link for this without introducing a race. This will get removed with solcap V2. */
289-
if( FD_UNLIKELY( solcap_enabled ) ) {
290-
/* TODO: remove this with solcap V2 */
291-
FOR(exec_tile_cnt) fd_topob_link( topo, "exec_replay", "exec_replay", 1024UL, FD_CAPTURE_CTX_ACCOUNT_UPDATE_MSG_FOOTPRINT, 1UL );
292-
} else {
293-
FOR(exec_tile_cnt) fd_topob_link( topo, "exec_replay", "exec_replay", 16384UL, sizeof(fd_exec_task_done_msg_t), 1UL );
294-
}
294+
FOR(exec_tile_cnt) fd_topob_link( topo, "exec_replay", "exec_replay", 16384UL, sizeof(fd_exec_task_done_msg_t), 1UL );
295295

296296
FOR(exec_tile_cnt) fd_topob_tile_out( topo, "exec", i, "exec_replay", i );
297297
FOR(exec_tile_cnt) fd_topob_tile_in( topo, "replay", 0UL, "metric_in", "exec_replay", i, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
@@ -300,6 +300,18 @@ backtest_topo( config_t * config ) {
300300
/* Setup the shared objs used by replay and exec tiles */
301301
/**********************************************************************/
302302

303+
if( FD_UNLIKELY( solcap_enabled ) ) {
304+
/* 32 sections of SOLCAP_WRITE_ACCOUNT_DATA_MTU bytes each ≈ 4MB.
305+
This is done to ideally avoid cache thrashing and allow for all
306+
the links to sit on L3 cache. */
307+
fd_topob_link( topo, "cap_repl", "captur", 32UL, SOLCAP_WRITE_ACCOUNT_DATA_MTU, 1UL );
308+
fd_topob_tile_out( topo, "replay", 0UL, "cap_repl", 0UL );
309+
fd_topob_tile_in( topo, "captur", 0UL, "metric_in", "cap_repl", 0UL, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
310+
FOR(exec_tile_cnt) fd_topob_link( topo, "cap_exec", "captur", 32UL, SOLCAP_WRITE_ACCOUNT_DATA_MTU, 1UL );
311+
FOR(exec_tile_cnt) fd_topob_tile_out( topo, "exec", i, "cap_exec", i );
312+
FOR(exec_tile_cnt) fd_topob_tile_in( topo, "captur", 0UL, "metric_in", "cap_exec", i, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
313+
}
314+
303315
fd_topob_wksp( topo, "store" );
304316
fd_topo_obj_t * store_obj = setup_topo_store( topo, "store", config->firedancer.store.max_completed_shred_sets, 1 );
305317
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
@@ -111,6 +111,7 @@ extern fd_topo_run_tile_t fd_tile_archiver_writer;
111111
extern fd_topo_run_tile_t fd_tile_archiver_playback;
112112
extern fd_topo_run_tile_t fd_tile_shredcap;
113113
extern fd_topo_run_tile_t fd_tile_vinyl;
114+
extern fd_topo_run_tile_t fd_tile_capture;
114115

115116
extern fd_topo_run_tile_t fd_tile_snapct;
116117
extern fd_topo_run_tile_t fd_tile_snapld;
@@ -173,6 +174,7 @@ fd_topo_run_tile_t * TILES[] = {
173174
&fd_tile_genesi,
174175
&fd_tile_ipecho,
175176
&fd_tile_vinyl,
177+
&fd_tile_capture,
176178
NULL,
177179
};
178180

src/app/firedancer/topology.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "../../util/tile/fd_tile_private.h"
2323
#include "../../discof/restore/utils/fd_ssctrl.h"
2424
#include "../../discof/restore/utils/fd_ssmsg.h"
25+
#include "../../flamenco/capture/fd_solcap_writer.h"
2526
#include "../../flamenco/progcache/fd_progcache_admin.h"
2627
#include "../../vinyl/meta/fd_vinyl_meta.h"
2728

@@ -290,6 +291,8 @@ fd_topo_initialize( config_t * config ) {
290291
topo->max_page_size = fd_cstr_to_shmem_page_sz( config->hugetlbfs.max_page_size );
291292
topo->gigantic_page_threshold = config->hugetlbfs.gigantic_page_threshold_mib << 20;
292293

294+
int solcap_enabled = strlen( config->capture.solcap_capture ) > 0;
295+
293296
/* topo, name */
294297
fd_topob_wksp( topo, "metric" );
295298
fd_topob_wksp( topo, "genesi" );
@@ -561,6 +564,11 @@ fd_topo_initialize( config_t * config ) {
561564
/**/ fd_topob_tile( topo, "poh", "poh", "metric_in", tile_to_cpu[ topo->tile_cnt ], 0, 1 );
562565
FOR(sign_tile_cnt) fd_topob_tile( topo, "sign", "sign", "metric_in", tile_to_cpu[ topo->tile_cnt ], 0, 1 );
563566

567+
if( FD_UNLIKELY( solcap_enabled ) ) {
568+
fd_topob_wksp( topo, "captur" );
569+
fd_topob_tile( topo, "captur", "captur", "metric_in", tile_to_cpu[ topo->tile_cnt ], 0, 0 );
570+
}
571+
564572
/* topo, tile_name, tile_kind_id, fseq_wksp, link_name, link_kind_id, reliable, polled */
565573
FOR(gossvf_tile_cnt) for( ulong j=0UL; j<net_tile_cnt; j++ )
566574
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 */
@@ -843,6 +851,15 @@ fd_topo_initialize( config_t * config ) {
843851
FOR(exec_tile_cnt) fd_topob_tile_out( topo, "exec", i, "exec_replay", i );
844852
FOR(exec_tile_cnt) fd_topob_tile_in( topo, "replay", 0UL, "metric_in", "exec_replay", i, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
845853

854+
if( FD_UNLIKELY( solcap_enabled ) ) {
855+
fd_topob_link( topo, "cap_repl", "captur", 32UL, SOLCAP_WRITE_ACCOUNT_DATA_MTU, 1UL );
856+
fd_topob_tile_out( topo, "replay", 0UL, "cap_repl", 0UL );
857+
fd_topob_tile_in( topo, "captur", 0UL, "metric_in", "cap_repl", 0UL, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
858+
FOR(exec_tile_cnt) fd_topob_link( topo, "cap_exec", "captur", 32UL, SOLCAP_WRITE_ACCOUNT_DATA_MTU, 1UL );
859+
FOR(exec_tile_cnt) fd_topob_tile_out( topo, "exec", i, "cap_exec", i );
860+
FOR(exec_tile_cnt) fd_topob_tile_in( topo, "captur", 0UL, "metric_in", "cap_exec", i, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
861+
}
862+
846863
if( FD_LIKELY( !is_auto_affinity ) ) {
847864
if( FD_UNLIKELY( affinity_tile_cnt<topo->tile_cnt ) )
848865
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. "
@@ -1404,6 +1421,13 @@ fd_topo_configure_tile( fd_topo_tile_t * tile,
14041421
tile->bundle.tls_cert_verify = !!config->tiles.bundle.tls_cert_verify;
14051422

14061423
} else if( FD_UNLIKELY( !strcmp( tile->name, "vinyl" ) ) ) {
1424+
1425+
} else if( FD_UNLIKELY( !strcmp( tile->name, "captur" ) ) ) {
1426+
1427+
tile->capctx.capture_start_slot = config->capture.capture_start_slot;
1428+
strncpy( tile->capctx.solcap_capture, config->capture.solcap_capture, sizeof(tile->capctx.solcap_capture) );
1429+
tile->capctx.recent_only = config->capture.recent_only;
1430+
tile->capctx.recent_slots_per_file = config->capture.recent_slots_per_file;
14071431

14081432
} else {
14091433
FD_LOG_ERR(( "unknown tile name `%s`", tile->name ));

src/app/ledger/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "../../flamenco/types/fd_types.h"
22
#include "../../flamenco/runtime/fd_rocksdb.h"
3-
#include "../../flamenco/runtime/context/fd_capture_ctx.h"
3+
#include "../../discof/capture/fd_capture_ctx.h"
44
#include <unistd.h>
55
#include <sys/stat.h>
66

src/app/shared/fd_config.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ struct fd_configf {
160160
struct {
161161
ulong max_completed_shred_sets;
162162
} store;
163+
164+
struct {
165+
char path[ PATH_MAX ];
166+
} capctx;
163167
};
164168

165169
typedef struct fd_configf fd_configf_t;
@@ -491,6 +495,8 @@ struct fd_config {
491495
ulong capture_start_slot;
492496
char dump_proto_dir[ PATH_MAX ];
493497
char solcap_capture[ PATH_MAX ];
498+
int recent_only;
499+
ulong recent_slots_per_file;
494500
int dump_elf_to_pb;
495501
int dump_syscall_to_pb;
496502
int dump_instr_to_pb;

src/app/shared/fd_config_parse.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,8 @@ fd_config_extract_pod( uchar * pod,
244244

245245
CFG_POP ( ulong, capture.capture_start_slot );
246246
CFG_POP ( cstr, capture.solcap_capture );
247+
CFG_POP ( bool, capture.recent_only );
248+
CFG_POP ( ulong, capture.recent_slots_per_file );
247249
CFG_POP ( cstr, capture.dump_proto_dir );
248250
CFG_POP ( bool, capture.dump_elf_to_pb );
249251
CFG_POP ( bool, capture.dump_syscall_to_pb );

src/disco/topo/fd_topo.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,16 @@ struct fd_topo_tile {
612612
ulong vinyl_data_obj_id;
613613
char vinyl_bstream_path[ PATH_MAX ];
614614
} vinyl;
615+
616+
struct {
617+
ulong capture_start_slot;
618+
char solcap_capture[ PATH_MAX ];
619+
int recent_only;
620+
ulong recent_slots_per_file;
621+
int solcap_fd;
622+
int solcap_fd_0; /* First FD (single file mode) or recent_0.solcap */
623+
int solcap_fd_1; /* Second FD (recent_1.solcap, or same as fd_0) */
624+
} capctx;
615625
};
616626
};
617627

src/discof/capture/Local.mk

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

0 commit comments

Comments
 (0)