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 : void
11 : load_cmd_perm( args_t * args,
12 : fd_caps_ctx_t * caps,
13 0 : config_t * const config ) {
14 0 : (void)args;
15 :
16 0 : args_t configure_args = {
17 0 : .configure.command = CONFIGURE_CMD_INIT,
18 0 : };
19 0 : FD_TEST( CONFIGURE_STAGE_COUNT>2 );
20 0 : for( ulong i=0; i<CONFIGURE_STAGE_COUNT; i++ ) {
21 0 : if( FD_LIKELY( STAGES[ i ] ) ) {
22 0 : if( FD_UNLIKELY( !strcmp( STAGES[ i ]->name, "hugetlbfs" ) ) )
23 0 : configure_args.configure.stages[ 0 ] = STAGES[ i ];
24 0 : }
25 0 : }
26 0 : configure_args.configure.stages[ 2 ] = NULL;
27 0 : configure_cmd_perm( &configure_args, caps, config );
28 :
29 0 : }
30 :
31 : void
32 : load_cmd_args( int * pargc,
33 : char *** pargv,
34 0 : args_t * args ) {
35 0 : const char * tpu_ip = fd_env_strip_cmdline_cstr ( pargc, pargv, "--tpu-ip", NULL, NULL );
36 0 : const char * rpc_ip = fd_env_strip_cmdline_cstr ( pargc, pargv, "--rpc-ip", NULL, NULL );
37 0 : const char * affinity = fd_env_strip_cmdline_cstr ( pargc, pargv, "--affinity", NULL, NULL );
38 :
39 0 : args->load.tpu_port = fd_env_strip_cmdline_ushort( pargc, pargv, "--tpu-port", NULL, 0 );
40 0 : args->load.rpc_port = fd_env_strip_cmdline_ushort( pargc, pargv, "--rpc-port", NULL, 0 );
41 0 : args->load.benchg = fd_env_strip_cmdline_ulong ( pargc, pargv, "--num-benchg", NULL, 0 );
42 0 : args->load.benchs = fd_env_strip_cmdline_ulong ( pargc, pargv, "--num-benchs", NULL, 0 );
43 0 : args->load.accounts = fd_env_strip_cmdline_ulong ( pargc, pargv, "--num-accounts", NULL, 0 );
44 0 : args->load.connections = fd_env_strip_cmdline_ulong ( pargc, pargv, "--connections", NULL, 0 );
45 0 : args->load.transaction_mode = fd_env_strip_cmdline_int ( pargc, pargv, "--transaction-mode", NULL, 0 );
46 0 : args->load.contending_fraction = fd_env_strip_cmdline_float( pargc, pargv, "--contending-fraction", NULL, 0.0f );
47 0 : args->load.cu_price_spread = fd_env_strip_cmdline_float( pargc, pargv, "--cu-price-spread", NULL, 0.0f );
48 :
49 0 : fd_cstr_fini( fd_cstr_append_cstr_safe( fd_cstr_init( args->load.affinity ), affinity, sizeof( args->load.affinity )-1UL ) );
50 :
51 0 : args->load.tpu_ip = 0;
52 0 : args->load.rpc_ip = 0;
53 0 : if( FD_LIKELY( tpu_ip ) ) {
54 0 : if( FD_UNLIKELY( !fd_cstr_to_ip4_addr( tpu_ip, &args->load.tpu_ip ) ) )
55 0 : FD_LOG_ERR(( "invalid --tpu-ip" ));
56 0 : }
57 0 : if( FD_LIKELY( rpc_ip ) ) {
58 0 : if( FD_UNLIKELY( !fd_cstr_to_ip4_addr( rpc_ip, &args->load.rpc_ip ) ) )
59 0 : FD_LOG_ERR(( "invalid --rpc-ip" ));
60 0 : }
61 :
62 0 : args->load.no_quic = fd_env_strip_cmdline_contains( pargc, pargv, "--no-quic" );
63 :
64 0 : }
65 :
66 : void
67 : load_cmd_fn( args_t * args,
68 0 : config_t * const config ) {
69 :
70 : /* set defaults */
71 0 : if( FD_UNLIKELY( !args->load.tpu_ip ) )
72 0 : args->load.tpu_ip = config->tiles.net.ip_addr;
73 :
74 0 : if( FD_UNLIKELY( !args->load.rpc_ip ) )
75 0 : args->load.rpc_ip = config->tiles.net.ip_addr;
76 :
77 0 : if( FD_UNLIKELY( !args->load.tpu_port ) ) {
78 0 : args->load.tpu_port = fd_ushort_if( args->load.no_quic,
79 0 : config->tiles.quic.regular_transaction_listen_port,
80 0 : config->tiles.quic.quic_transaction_listen_port );
81 0 : }
82 :
83 0 : if( FD_UNLIKELY( !args->load.rpc_port ) )
84 0 : args->load.rpc_port = config->rpc.port;
85 0 : if( FD_UNLIKELY( !args->load.rpc_port ) )
86 0 : FD_LOG_ERR(( "Missing --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[ 1 ] = NULL;
130 0 : configure_cmd_fn( &configure_args, config );
131 :
132 0 : initialize_workspaces( config );
133 0 : initialize_stacks( config );
134 :
135 0 : FD_LOG_NOTICE(( "Running" ));
136 0 : FD_LOG_NOTICE(( " --tpu-ip " FD_IP4_ADDR_FMT, FD_IP4_ADDR_FMT_ARGS( args->load.tpu_ip ) ));
137 0 : FD_LOG_NOTICE(( " --tpu-port %d", args->load.tpu_port ));
138 0 : FD_LOG_NOTICE(( " --rpc-ip " FD_IP4_ADDR_FMT, FD_IP4_ADDR_FMT_ARGS( args->load.rpc_ip ) ));
139 0 : FD_LOG_NOTICE(( " --rpc-port %d", args->load.rpc_port ));
140 0 : FD_LOG_NOTICE(( " --affinity %s", args->load.affinity ));
141 0 : FD_LOG_NOTICE(( " --num-benchg %lu", args->load.benchg ));
142 0 : FD_LOG_NOTICE(( " --num-benchs %lu", args->load.benchs ));
143 0 : FD_LOG_NOTICE(( " --num-accounts %lu", args->load.accounts ));
144 0 : FD_LOG_NOTICE(( " --connections %lu", args->load.connections ));
145 0 : FD_LOG_NOTICE(( " --transaction-mode %d", args->load.transaction_mode ));
146 0 : FD_LOG_NOTICE(( " --contending-fraction %g", (double)args->load.contending_fraction ));
147 0 : FD_LOG_NOTICE(( " --cu-price-spread %g", (double)args->load.cu_price_spread ));
148 :
149 0 : fd_topo_run_single_process( &config->topo, 0, config->uid, config->gid, fdctl_tile_run, NULL );
150 :
151 : /* Sleep parent thread forever, Ctrl+C will terminate. */
152 0 : for(;;) pause();
153 0 : }
|