Skip to content

Commit 5eb62c9

Browse files
committed
solcap: v2
1 parent 2703795 commit 5eb62c9

Some content is hidden

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

42 files changed

+1714
-2825
lines changed

contrib/test/run_solcap_tests.sh

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

85-
$OBJDIR/bin/fd_solcap_import $DUMP/$LEDGER/bank_hash_details/ $DUMP/$LEDGER/solana.solcap
86-
$OBJDIR/bin/fd_solcap_diff $DUMP/$LEDGER/solana.solcap $DUMP/$LEDGER/fd.solcap -v 4
87-
8885
# check that the ledger is not corrupted after a run
8986
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
@@ -110,6 +110,7 @@ extern fd_topo_run_tile_t fd_tile_archiver_writer;
110110
extern fd_topo_run_tile_t fd_tile_archiver_playback;
111111
extern fd_topo_run_tile_t fd_tile_shredcap;
112112
extern fd_topo_run_tile_t fd_tile_vinyl;
113+
extern fd_topo_run_tile_t fd_tile_capture;
113114

114115
extern fd_topo_run_tile_t fd_tile_snapct;
115116
extern fd_topo_run_tile_t fd_tile_snapld;
@@ -172,6 +173,7 @@ fd_topo_run_tile_t * TILES[] = {
172173
&fd_tile_genesi,
173174
&fd_tile_ipecho,
174175
&fd_tile_vinyl,
176+
&fd_tile_capture,
175177
NULL,
176178
};
177179

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
#include "../../vinyl/io/fd_vinyl_io.h" /* FD_VINYL_IO_TYPE_* */
@@ -285,6 +286,8 @@ fd_topo_initialize( config_t * config ) {
285286
topo->max_page_size = fd_cstr_to_shmem_page_sz( config->hugetlbfs.max_page_size );
286287
topo->gigantic_page_threshold = config->hugetlbfs.gigantic_page_threshold_mib << 20;
287288

289+
int solcap_enabled = strlen( config->capture.solcap_capture ) > 0;
290+
288291
/* topo, name */
289292
fd_topob_wksp( topo, "metric" );
290293
fd_topob_wksp( topo, "genesi" );
@@ -560,6 +563,11 @@ fd_topo_initialize( config_t * config ) {
560563
/**/ fd_topob_tile( topo, "poh", "poh", "metric_in", tile_to_cpu[ topo->tile_cnt ], 0, 1 );
561564
FOR(sign_tile_cnt) fd_topob_tile( topo, "sign", "sign", "metric_in", tile_to_cpu[ topo->tile_cnt ], 0, 1 );
562565

566+
if( FD_UNLIKELY( solcap_enabled ) ) {
567+
fd_topob_wksp( topo, "captur" );
568+
fd_topob_tile( topo, "captur", "captur", "metric_in", tile_to_cpu[ topo->tile_cnt ], 0, 0 );
569+
}
570+
563571
/* topo, tile_name, tile_kind_id, fseq_wksp, link_name, link_kind_id, reliable, polled */
564572
FOR(gossvf_tile_cnt) for( ulong j=0UL; j<net_tile_cnt; j++ )
565573
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 */
@@ -839,6 +847,15 @@ fd_topo_initialize( config_t * config ) {
839847
fd_topob_tile_in( topo, "replay", 0UL, "metric_in", "rpc_replay", 0UL, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
840848
}
841849

850+
if( FD_UNLIKELY( solcap_enabled ) ) {
851+
fd_topob_link( topo, "cap_repl", "captur", 32UL, SOLCAP_WRITE_ACCOUNT_DATA_MTU, 1UL );
852+
fd_topob_tile_out( topo, "replay", 0UL, "cap_repl", 0UL );
853+
fd_topob_tile_in( topo, "captur", 0UL, "metric_in", "cap_repl", 0UL, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
854+
FOR(exec_tile_cnt) fd_topob_link( topo, "cap_exec", "captur", 32UL, SOLCAP_WRITE_ACCOUNT_DATA_MTU, 1UL );
855+
FOR(exec_tile_cnt) fd_topob_tile_out( topo, "exec", i, "cap_exec", i );
856+
FOR(exec_tile_cnt) fd_topob_tile_in( topo, "captur", 0UL, "metric_in", "cap_exec", i, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
857+
}
858+
842859
if( FD_LIKELY( !is_auto_affinity ) ) {
843860
if( FD_UNLIKELY( affinity_tile_cnt<topo->tile_cnt ) )
844861
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. "
@@ -1394,6 +1411,13 @@ fd_topo_configure_tile( fd_topo_tile_t * tile,
13941411
tile->bundle.tls_cert_verify = !!config->tiles.bundle.tls_cert_verify;
13951412

13961413
} else if( FD_UNLIKELY( !strcmp( tile->name, "vinyl" ) ) ) {
1414+
1415+
} else if( FD_UNLIKELY( !strcmp( tile->name, "captur" ) ) ) {
1416+
1417+
tile->capctx.capture_start_slot = config->capture.capture_start_slot;
1418+
strncpy( tile->capctx.solcap_capture, config->capture.solcap_capture, sizeof(tile->capctx.solcap_capture) );
1419+
tile->capctx.recent_only = config->capture.recent_only;
1420+
tile->capctx.recent_slots_per_file = config->capture.recent_slots_per_file;
13971421

13981422
tile->vinyl.vinyl_meta_map_obj_id = fd_pod_query_ulong( config->topo.props, "vinyl.meta_map", ULONG_MAX );
13991423
tile->vinyl.vinyl_meta_pool_obj_id = fd_pod_query_ulong( config->topo.props, "vinyl.meta_pool", ULONG_MAX );

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
@@ -168,6 +168,10 @@ struct fd_configf {
168168
struct {
169169
ulong max_completed_shred_sets;
170170
} store;
171+
172+
struct {
173+
char path[ PATH_MAX ];
174+
} capctx;
171175
};
172176

173177
typedef struct fd_configf fd_configf_t;
@@ -499,6 +503,8 @@ struct fd_config {
499503
ulong capture_start_slot;
500504
char dump_proto_dir[ PATH_MAX ];
501505
char solcap_capture[ PATH_MAX ];
506+
int recent_only;
507+
ulong recent_slots_per_file;
502508
int dump_elf_to_pb;
503509
int dump_syscall_to_pb;
504510
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
@@ -249,6 +249,8 @@ fd_config_extract_pod( uchar * pod,
249249

250250
CFG_POP ( ulong, capture.capture_start_slot );
251251
CFG_POP ( cstr, capture.solcap_capture );
252+
CFG_POP ( bool, capture.recent_only );
253+
CFG_POP ( ulong, capture.recent_slots_per_file );
252254
CFG_POP ( cstr, capture.dump_proto_dir );
253255
CFG_POP ( bool, capture.dump_elf_to_pb );
254256
CFG_POP ( bool, capture.dump_syscall_to_pb );

src/disco/topo/fd_topo.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,13 @@ struct fd_topo_tile {
616616
int io_type; /* FD_VINYL_IO_TYPE_* */
617617
uint uring_depth;
618618
} vinyl;
619+
620+
struct {
621+
ulong capture_start_slot;
622+
char solcap_capture[ PATH_MAX ];
623+
int recent_only;
624+
ulong recent_slots_per_file;
625+
} capctx;
619626
};
620627
};
621628

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)