Skip to content

Commit

Permalink
Add 'fddev help' subcommand
Browse files Browse the repository at this point in the history
Closes #1869
  • Loading branch information
riptl authored and firedancer-admin committed Feb 3, 2025
1 parent 578ec4e commit b21072a
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 20 deletions.
3 changes: 1 addition & 2 deletions src/app/fdctl/fdctl.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,7 @@ fdctl_obj_loose( fd_topo_t const * topo,
fd_topo_run_tile_t
fdctl_tile_run( fd_topo_tile_t * tile );

#define ACTIONS_CNT (11UL)
extern action_t ACTIONS[ ACTIONS_CNT ];
extern action_t ACTIONS[];

void fdctl_boot( int * pargc,
char *** pargv,
Expand Down
2 changes: 1 addition & 1 deletion src/app/fdctl/help.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ help_cmd_fn( args_t * args,
--config parameter. */
FD_LOG_STDOUT(( " --config <PATH> Path to config TOML file\n\n" ));
FD_LOG_STDOUT(( "SUBCOMMANDS:\n" ));
for( ulong i=0; i<ACTIONS_CNT ; i++ ) {
for( ulong i=0; ACTIONS[ i ].name ; i++ ) {
FD_LOG_STDOUT(( " %9s %s\n", ACTIONS[ i ].name, ACTIONS[ i ].description ));
}
}
5 changes: 3 additions & 2 deletions src/app/fdctl/main1.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <fcntl.h>
#include <sys/mman.h>

action_t ACTIONS[ ACTIONS_CNT ] = {
action_t ACTIONS[] = {
{ .name = "run", .args = NULL, .fn = run_cmd_fn, .perm = run_cmd_perm, .description = "Start up a Firedancer validator" },
{ .name = "run1", .args = run1_cmd_args, .fn = run1_cmd_fn, .perm = NULL, .description = "Start up a single Firedancer tile" },
{ .name = "run-agave", .args = NULL, .fn = run_agave_cmd_fn, .perm = NULL, .description = "Start up the Agave side of a Firedancer validator" },
Expand All @@ -18,6 +18,7 @@ action_t ACTIONS[ ACTIONS_CNT ] = {
{ .name = "spy", .args = NULL, .fn = spy_cmd_fn, .perm = NULL, .description = "Spy on and print out gossip traffic" },
{ .name = "help", .args = NULL, .fn = help_cmd_fn, .perm = NULL, .description = "Print this help message" },
{ .name = "version", .args = NULL, .fn = version_cmd_fn, .perm = NULL, .description = "Show the current software version" },
{0}
};

struct action_alias {
Expand Down Expand Up @@ -278,7 +279,7 @@ main1( int argc,
}

action_t * action = NULL;
for( ulong i=0; i<ACTIONS_CNT; i++ ) {
for( ulong i=0; ACTIONS[ i ].name; i++ ) {
if( FD_UNLIKELY( !strcmp( command, ACTIONS[ i ].name ) ) ) {
action = &ACTIONS[ i ];
break;
Expand Down
10 changes: 9 additions & 1 deletion src/app/fddev/Local.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,15 @@ include src/app/fdctl/with-version.mk
.PHONY: fddev run monitor

# fddev core
$(call add-objs,main1 dev dev1 txn bench load dump flame wksp,fd_fddev)
$(call add-objs,main1 help wksp,fd_fddev)

# fddev actions
$(call add-objs,bench,fd_fddev)
$(call add-objs,dev dev1,fd_fddev)
$(call add-objs,dump,fd_fddev)
$(call add-objs,flame,fd_fddev)
$(call add-objs,load,fd_fddev)
$(call add-objs,txn,fd_fddev)

# fddev tiles
$(call add-objs,tiles/fd_bencho,fd_fddev)
Expand Down
11 changes: 9 additions & 2 deletions src/app/fddev/fddev.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@

#include "../fdctl/fdctl.h"

int fddev_main( int argc,
char ** argv );
extern action_t DEV_ACTIONS[];

int
fddev_main( int argc,
char ** argv );

void
update_config_for_dev( config_t * const config );
Expand Down Expand Up @@ -131,4 +134,8 @@ void
quic_trace_cmd_fn( args_t * args,
config_t * const config );

void
dev_help_cmd_fn( args_t * args,
config_t * const config );

#endif /* HEADER_fd_src_app_fddev_fddev_h */
25 changes: 25 additions & 0 deletions src/app/fddev/help.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include "fddev.h"

void
dev_help_cmd_fn( args_t * args FD_FN_UNUSED,
config_t * const config FD_FN_UNUSED ) {
FD_LOG_STDOUT(( "Firedancer development binary\n\n" ));
FD_LOG_STDOUT(( "Usage: fddev [OPTIONS] <SUBCOMMAND>\n\n" ));
FD_LOG_STDOUT(( "\nOPTIONS:\n" ));
/* fddev does not have many flag arguments so we hard-code the
--config parameter. */
FD_LOG_STDOUT(( " --config <PATH> Path to config TOML file\n\n" ));

FD_LOG_STDOUT(( "SUBCOMMANDS (fddev):\n" ));
for( ulong i=0; DEV_ACTIONS[ i ].name; i++ ) {
FD_LOG_STDOUT(( " %10s %s\n", DEV_ACTIONS[ i ].name, DEV_ACTIONS[ i ].description ));
}

FD_LOG_STDOUT(( "\nSUBCOMMANDS (fdctl):\n" ));
for( ulong i=0; ACTIONS[ i ].name; i++ ) {
for( ulong j=0; DEV_ACTIONS[ j ].name; j++ ) {
if( 0==strcmp( ACTIONS[ i ].name, DEV_ACTIONS[ j ].name ) ) break;
}
FD_LOG_STDOUT(( " %10s %s\n", ACTIONS[ i ].name, ACTIONS[ i ].description ));
}
}
26 changes: 14 additions & 12 deletions src/app/fddev/main1.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,18 @@ fd_topo_run_tile_t * TILES[] = {
NULL,
};

static action_t DEV_ACTIONS[] = {
{ .name = "dev", .args = dev_cmd_args, .fn = dev_cmd_fn, .perm = dev_cmd_perm },
{ .name = "wksp", .args = NULL, .fn = wksp_cmd_fn, .perm = wksp_cmd_perm },
{ .name = "dev1", .args = dev1_cmd_args, .fn = dev1_cmd_fn, .perm = dev_cmd_perm },
{ .name = "txn", .args = txn_cmd_args, .fn = txn_cmd_fn, .perm = txn_cmd_perm },
{ .name = "bench", .args = bench_cmd_args, .fn = bench_cmd_fn, .perm = bench_cmd_perm },
{ .name = "load", .args = load_cmd_args, .fn = load_cmd_fn, .perm = load_cmd_perm },
{ .name = "dump", .args = dump_cmd_args, .fn = dump_cmd_fn, .perm = NULL, .is_diagnostic=1 },
{ .name = "flame", .args = flame_cmd_args, .fn = flame_cmd_fn, .perm = flame_cmd_perm, .is_diagnostic=1 },
{ .name = "quic-trace", .args = quic_trace_cmd_args, .fn = quic_trace_cmd_fn, .perm = NULL, .is_diagnostic=1 },
action_t DEV_ACTIONS[] = {
{ .name = "bench", .args = bench_cmd_args, .fn = bench_cmd_fn, .perm = bench_cmd_perm, .description = "Test validator TPS benchmark" },
{ .name = "dev", .args = dev_cmd_args, .fn = dev_cmd_fn, .perm = dev_cmd_perm, .description = "Start up a test validator" },
{ .name = "dev1", .args = dev1_cmd_args, .fn = dev1_cmd_fn, .perm = dev_cmd_perm, .description = "Start up a single tile" },
{ .name = "dump", .args = dump_cmd_args, .fn = dump_cmd_fn, .perm = NULL, .description = "Dump tango links to pcap", .is_diagnostic=1 },
{ .name = "flame", .args = flame_cmd_args, .fn = flame_cmd_fn, .perm = flame_cmd_perm, .description = "Capture a perf flamegraph", .is_diagnostic=1 },
{ .name = "help", .args = NULL, .fn = dev_help_cmd_fn, .perm = NULL, .description = "Print this help message", .is_diagnostic=1 },
{ .name = "load", .args = load_cmd_args, .fn = load_cmd_fn, .perm = load_cmd_perm, .description = "Load test an external validator" },
{ .name = "quic-trace", .args = quic_trace_cmd_args, .fn = quic_trace_cmd_fn, .perm = NULL, .description = "Trace quic tile", .is_diagnostic=1 },
{ .name = "txn", .args = txn_cmd_args, .fn = txn_cmd_fn, .perm = txn_cmd_perm, .description = "Send a transaction to an fddev instance" },
{ .name = "wksp", .args = NULL, .fn = wksp_cmd_fn, .perm = wksp_cmd_perm, .description = "Initialize workspaces" },
{0}
};

extern char fd_log_private_path[ 1024 ];
Expand Down Expand Up @@ -187,13 +189,13 @@ fddev_main( int argc,
}

action_t * action = NULL;
for( ulong i=0; i<sizeof(ACTIONS)/sizeof(ACTIONS[ 0 ]); i++ ) {
for( ulong i=0; ACTIONS[ i ].name; i++ ) {
if( FD_UNLIKELY( !strcmp( action_name, ACTIONS[ i ].name ) ) ) {
action = &ACTIONS[ i ];
break;
}
}
for( ulong i=0; i<sizeof(DEV_ACTIONS)/sizeof(DEV_ACTIONS[ 0 ]); i++ ) {
for( ulong i=0; DEV_ACTIONS[ i ].name; i++ ) {
if( FD_UNLIKELY( !strcmp( action_name, DEV_ACTIONS[ i ].name ) ) ) {
action = &DEV_ACTIONS[ i ];
break;
Expand Down

0 comments on commit b21072a

Please sign in to comment.