Line data Source code
1 : #define _GNU_SOURCE
2 : #include "fddev.h"
3 :
4 : #include "../fdctl/configure/configure.h"
5 : #include "../fdctl/run/run.h"
6 :
7 : #include "../../disco/topo/fd_topob.h"
8 : #include "../../util/net/fd_ip4.h"
9 :
10 : #include "../../util/tile/fd_tile_private.h"
11 :
12 : void
13 : load_cmd_perm( args_t * args,
14 : fd_caps_ctx_t * caps,
15 0 : config_t * const config ) {
16 0 : (void)args;
17 :
18 0 : args_t configure_args = {
19 0 : .configure.command = CONFIGURE_CMD_INIT,
20 0 : };
21 0 : FD_TEST( CONFIGURE_STAGE_COUNT>2 );
22 0 : for( ulong i=0; i<CONFIGURE_STAGE_COUNT; i++ ) {
23 0 : if( FD_LIKELY( STAGES[ i ] ) ) {
24 0 : if( FD_UNLIKELY( !strcmp( STAGES[ i ]->name, "hugetlbfs" ) ) )
25 0 : configure_args.configure.stages[ 0 ] = STAGES[ i ];
26 0 : }
27 0 : }
28 0 : configure_args.configure.stages[ 2 ] = NULL;
29 0 : configure_cmd_perm( &configure_args, caps, config );
30 :
31 0 : }
32 :
33 : void
34 : load_cmd_args( int * pargc,
35 : char *** pargv,
36 0 : args_t * args ) {
37 0 : const char * tpu_ip = fd_env_strip_cmdline_cstr ( pargc, pargv, "--tpu-ip", NULL, NULL );
38 0 : const char * rpc_ip = fd_env_strip_cmdline_cstr ( pargc, pargv, "--rpc-ip", NULL, NULL );
39 0 : const char * affinity = fd_env_strip_cmdline_cstr ( pargc, pargv, "--affinity", "-a", NULL );
40 :
41 0 : args->load.tpu_port = fd_env_strip_cmdline_ushort( pargc, pargv, "--tpu-port", NULL, 0 );
42 0 : args->load.rpc_port = fd_env_strip_cmdline_ushort( pargc, pargv, "--rpc-port", NULL, 0 );
43 0 : args->load.benchg = fd_env_strip_cmdline_ulong ( pargc, pargv, "--num-benchg", "-g", 0 );
44 0 : args->load.benchs = fd_env_strip_cmdline_ulong ( pargc, pargv, "--num-benchs", "-s", 0 );
45 0 : args->load.accounts = fd_env_strip_cmdline_ulong ( pargc, pargv, "--num-accounts", NULL, 0 );
46 0 : args->load.connections = fd_env_strip_cmdline_ulong ( pargc, pargv, "--connections", "-c", 0 );
47 0 : args->load.transaction_mode = fd_env_strip_cmdline_int ( pargc, pargv, "--transaction-mode", NULL, 0 );
48 0 : args->load.contending_fraction = fd_env_strip_cmdline_float( pargc, pargv, "--contending-fraction", NULL, 0.0f );
49 0 : args->load.cu_price_spread = fd_env_strip_cmdline_float( pargc, pargv, "--cu-price-spread", NULL, 0.0f );
50 :
51 0 : fd_cstr_fini( fd_cstr_append_cstr_safe( fd_cstr_init( args->load.affinity ), affinity, sizeof( args->load.affinity )-1UL ) );
52 :
53 0 : args->load.tpu_ip = 0;
54 0 : args->load.rpc_ip = 0;
55 0 : if( FD_LIKELY( tpu_ip ) ) {
56 0 : if( FD_UNLIKELY( !fd_cstr_to_ip4_addr( tpu_ip, &args->load.tpu_ip ) ) )
57 0 : FD_LOG_ERR(( "invalid --tpu-ip" ));
58 0 : }
59 0 : if( FD_LIKELY( rpc_ip ) ) {
60 0 : if( FD_UNLIKELY( !fd_cstr_to_ip4_addr( rpc_ip, &args->load.rpc_ip ) ) )
61 0 : FD_LOG_ERR(( "invalid --rpc-ip" ));
62 0 : }
63 :
64 0 : args->load.no_quic = fd_env_strip_cmdline_contains( pargc, pargv, "--no-quic" );
65 :
66 0 : }
67 :
68 : void
69 : load_cmd_fn( args_t * args,
70 0 : config_t * const config ) {
71 :
72 : /* set defaults */
73 0 : if( FD_UNLIKELY( !args->load.tpu_ip ) )
74 0 : args->load.tpu_ip = config->tiles.net.ip_addr;
75 :
76 0 : if( FD_UNLIKELY( !args->load.rpc_ip ) )
77 0 : args->load.rpc_ip = config->tiles.net.ip_addr;
78 :
79 0 : if( FD_UNLIKELY( !args->load.tpu_port ) ) {
80 0 : args->load.tpu_port = fd_ushort_if( args->load.no_quic,
81 0 : config->tiles.quic.regular_transaction_listen_port,
82 0 : config->tiles.quic.quic_transaction_listen_port );
83 0 : }
84 :
85 0 : if( FD_UNLIKELY( !args->load.rpc_port ) )
86 0 : args->load.rpc_port = config->rpc.port;
87 :
88 0 : if( FD_UNLIKELY( !strcmp( args->load.affinity, "" ) ) )
89 0 : fd_cstr_append_cstr_safe( args->load.affinity, config->development.bench.affinity, sizeof( args->load.affinity )-1UL );
90 :
91 0 : if( FD_UNLIKELY( !args->load.benchg ) )
92 0 : args->load.benchg = config->development.bench.benchg_tile_count;
93 :
94 0 : if( FD_UNLIKELY( !args->load.benchs ) )
95 0 : args->load.benchs = config->development.bench.benchs_tile_count;
96 :
97 0 : if( FD_UNLIKELY( !args->load.accounts ) )
98 0 : args->load.accounts = config->development.genesis.fund_initial_accounts;
99 :
100 0 : if( FD_UNLIKELY( !args->load.connections ) )
101 0 : args->load.connections = config->layout.quic_tile_count;
102 :
103 0 : fd_topo_t * topo = { fd_topob_new( &config->topo, config->name ) };
104 0 : add_bench_topo( topo,
105 0 : args->load.affinity,
106 0 : args->load.benchg,
107 0 : args->load.benchs,
108 0 : args->load.accounts,
109 0 : args->load.transaction_mode,
110 0 : args->load.contending_fraction,
111 0 : args->load.cu_price_spread,
112 0 : args->load.connections,
113 0 : args->load.tpu_port,
114 0 : args->load.tpu_ip,
115 0 : args->load.rpc_port,
116 0 : args->load.rpc_ip,
117 0 : args->load.no_quic );
118 0 : config->topo = *topo;
119 :
120 0 : args_t configure_args = {
121 0 : .configure.command = CONFIGURE_CMD_INIT,
122 0 : };
123 0 : for( ulong i=0; i<CONFIGURE_STAGE_COUNT; i++ ) {
124 0 : if( FD_LIKELY( STAGES[ i ] ) ) {
125 0 : if( FD_UNLIKELY( !strcmp( STAGES[ i ]->name, "hugetlbfs" ) ) )
126 0 : configure_args.configure.stages[ 0 ] = STAGES[ i ];
127 0 : }
128 0 : }
129 0 : configure_args.configure.stages[ 2 ] = NULL;
130 0 : configure_cmd_fn( &configure_args, config );
131 :
132 0 : run_firedancer_init( config, 1 );
133 :
134 0 : fd_xdp_fds_t fds = fd_topo_install_xdp( &config->topo );
135 0 : (void)fds;
136 :
137 : // Do we need a sandbox?
138 :
139 0 : fd_topo_run_single_process( &config->topo, 0, config->uid, config->gid, fdctl_tile_run, NULL );
140 :
141 : /* Sleep parent thread forever, Ctrl+C will terminate. */
142 0 : for(;;) pause();
143 0 : }
|