From b21072add8305b5b49d6b0ab9d7055013381f0b5 Mon Sep 17 00:00:00 2001 From: Richard Patel Date: Sun, 2 Feb 2025 13:49:16 +0000 Subject: [PATCH] Add 'fddev help' subcommand Closes https://github.com/firedancer-io/firedancer/issues/1869 --- src/app/fdctl/fdctl.h | 3 +-- src/app/fdctl/help.c | 2 +- src/app/fdctl/main1.c | 5 +++-- src/app/fddev/Local.mk | 10 +++++++++- src/app/fddev/fddev.h | 11 +++++++++-- src/app/fddev/help.c | 25 +++++++++++++++++++++++++ src/app/fddev/main1.c | 26 ++++++++++++++------------ 7 files changed, 62 insertions(+), 20 deletions(-) create mode 100644 src/app/fddev/help.c diff --git a/src/app/fdctl/fdctl.h b/src/app/fdctl/fdctl.h index 56ef0724b5..1f63a5e647 100644 --- a/src/app/fdctl/fdctl.h +++ b/src/app/fdctl/fdctl.h @@ -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, diff --git a/src/app/fdctl/help.c b/src/app/fdctl/help.c index f795b1da83..8cf140c356 100644 --- a/src/app/fdctl/help.c +++ b/src/app/fdctl/help.c @@ -13,7 +13,7 @@ help_cmd_fn( args_t * args, --config parameter. */ FD_LOG_STDOUT(( " --config Path to config TOML file\n\n" )); FD_LOG_STDOUT(( "SUBCOMMANDS:\n" )); - for( ulong i=0; i #include -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" }, @@ -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 { @@ -278,7 +279,7 @@ main1( int argc, } action_t * action = NULL; - for( ulong i=0; i\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 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 )); + } +} diff --git a/src/app/fddev/main1.c b/src/app/fddev/main1.c index b6befd47c9..2fa2af9d26 100644 --- a/src/app/fddev/main1.c +++ b/src/app/fddev/main1.c @@ -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 ]; @@ -187,13 +189,13 @@ fddev_main( int argc, } action_t * action = NULL; - for( ulong i=0; i