From 51bcd55562796354d80b1173310a0cee6da8d035 Mon Sep 17 00:00:00 2001 From: Richard Patel Date: Fri, 15 Nov 2024 13:35:22 +0000 Subject: [PATCH] fdctl: optimize imports Also remove circular dependencies --- src/app/fdctl/caps.h | 4 ++-- src/app/fdctl/config.c | 7 ++----- src/app/fdctl/configure/configure.c | 2 -- src/app/fdctl/configure/ethtool-channels.c | 1 - src/app/fdctl/configure/ethtool-gro.c | 1 - src/app/fdctl/fuzz_fdctl_config.c | 1 - src/app/fdctl/main1.c | 1 - src/app/fdctl/monitor/helper.c | 2 -- src/app/fdctl/monitor/monitor.c | 7 ++----- src/app/fdctl/run/run.c | 1 - src/app/fdctl/spy.c | 2 -- src/app/fdctl/utility.c | 2 ++ src/app/fdctl/utility.h | 2 +- src/app/fddev/bench.c | 3 --- src/app/fddev/configure/genesis.c | 1 - src/app/fddev/dev.c | 3 --- src/app/fddev/flame.c | 1 - src/app/fddev/load.c | 2 -- src/app/fddev/tiles/fd_benchg.c | 3 +-- src/app/fddev/tiles/fd_bencho.c | 7 +++---- src/app/fddev/tiles/fd_benchs.c | 3 +-- src/disco/topo/fd_topo.c | 1 - src/disco/topo/fd_topo_run.c | 3 +-- 23 files changed, 15 insertions(+), 45 deletions(-) diff --git a/src/app/fdctl/caps.h b/src/app/fdctl/caps.h index 0dc5cae4ff..8d037326a2 100644 --- a/src/app/fdctl/caps.h +++ b/src/app/fdctl/caps.h @@ -1,7 +1,7 @@ #ifndef HEADER_fd_src_app_fdctl_caps_h #define HEADER_fd_src_app_fdctl_caps_h -#include "fdctl.h" +#include "../../util/fd_util_base.h" /* API for checking capabilities, and accumulating information about what capabilities or permissions are missing that are required to run @@ -67,7 +67,7 @@ void fd_caps_check_capability( fd_caps_ctx_t * ctx, char const * name, uint capability, - char const * reason ); + char const * reason ); /* fd_caps_check_resource() checks if the current process is running with the provided resource, a RLIMIT_* constant, at or above the diff --git a/src/app/fdctl/config.c b/src/app/fdctl/config.c index eaedd773b3..d683cae14a 100644 --- a/src/app/fdctl/config.c +++ b/src/app/fdctl/config.c @@ -4,17 +4,14 @@ #include "fdctl.h" #include "run/topos/topos.h" -#include "run/run.h" #include "../../ballet/toml/fd_toml.h" -#include "../../disco/topo/fd_topob.h" #include "../../disco/topo/fd_pod_format.h" #include "../../flamenco/runtime/fd_blockstore.h" #include "../../flamenco/runtime/fd_txncache.h" #include "../../funk/fd_funk.h" #include "../../util/net/fd_eth.h" #include "../../util/net/fd_ip4.h" -#include "../../util/tile/fd_tile_private.h" #include #include @@ -463,13 +460,13 @@ fdctl_cfg_from_env( int * pargc, static uchar pod_mem2[ 1UL<<20 ]; uchar * pod1 = fd_pod_join( fd_pod_new( pod_mem1, sizeof(pod_mem1) ) ); uchar * pod2 = fd_pod_join( fd_pod_new( pod_mem2, sizeof(pod_mem2) ) ); - + uchar scratch[ 4096 ]; long toml_err = fd_toml_parse( fdctl_default_config, fdctl_default_config_sz, pod1, scratch, sizeof(scratch) ); if( FD_UNLIKELY( toml_err!=FD_TOML_SUCCESS ) ) FD_LOG_ERR(( "Invalid config (%s)", "default.toml" )); toml_err = fd_toml_parse( fdctl_default_firedancer_config, fdctl_default_firedancer_config_sz, pod2, scratch, sizeof(scratch) ); if( FD_UNLIKELY( toml_err!=FD_TOML_SUCCESS ) ) FD_LOG_ERR(( "Invalid config (%s)", "default-firedancer.toml" )); - + if( FD_UNLIKELY( !fdctl_pod_to_cfg( config, pod1 ) ) ) FD_LOG_ERR(( "Invalid config (%s)", "default.toml" )); if( FD_UNLIKELY( !fdctl_pod_to_cfg( config, pod2 ) ) ) FD_LOG_ERR(( "Invalid config (%s)", "default-firedancer.toml" )); fd_pod_delete( fd_pod_leave( pod1 ) ); diff --git a/src/app/fdctl/configure/configure.c b/src/app/fdctl/configure/configure.c index 99c956575f..39363cf28f 100644 --- a/src/app/fdctl/configure/configure.c +++ b/src/app/fdctl/configure/configure.c @@ -1,8 +1,6 @@ #include "configure.h" #include -#include -#include void configure_cmd_args( int * pargc, diff --git a/src/app/fdctl/configure/ethtool-channels.c b/src/app/fdctl/configure/ethtool-channels.c index 4d72347503..a1cfeddfcf 100644 --- a/src/app/fdctl/configure/ethtool-channels.c +++ b/src/app/fdctl/configure/ethtool-channels.c @@ -1,7 +1,6 @@ #include "configure.h" #include -#include #include #include #include diff --git a/src/app/fdctl/configure/ethtool-gro.c b/src/app/fdctl/configure/ethtool-gro.c index c0b5fe78b5..1626b9855f 100644 --- a/src/app/fdctl/configure/ethtool-gro.c +++ b/src/app/fdctl/configure/ethtool-gro.c @@ -1,7 +1,6 @@ #include "configure.h" #include -#include #include #include #include diff --git a/src/app/fdctl/fuzz_fdctl_config.c b/src/app/fdctl/fuzz_fdctl_config.c index e1ac017959..2dadbc94b7 100644 --- a/src/app/fdctl/fuzz_fdctl_config.c +++ b/src/app/fdctl/fuzz_fdctl_config.c @@ -1,7 +1,6 @@ #include "config_parse.h" #include "../../ballet/toml/fd_toml.h" #include "../../util/fd_util.h" -#include "../../util/sanitize/fd_fuzz.h" #include #include diff --git a/src/app/fdctl/main1.c b/src/app/fdctl/main1.c index 2796d91cc9..6d65b1c71c 100644 --- a/src/app/fdctl/main1.c +++ b/src/app/fdctl/main1.c @@ -1,6 +1,5 @@ #define _GNU_SOURCE #define FD_UNALIGNED_ACCESS_STYLE 0 -#include "../../util/bits/fd_bits.h" #include "fdctl.h" diff --git a/src/app/fdctl/monitor/helper.c b/src/app/fdctl/monitor/helper.c index 1aa833b0d0..3a2375eabd 100644 --- a/src/app/fdctl/monitor/helper.c +++ b/src/app/fdctl/monitor/helper.c @@ -2,8 +2,6 @@ #include -#include "../../../disco/fd_disco.h" - #define PRINT( ... ) do { \ int n = snprintf( *buf, *buf_sz, __VA_ARGS__ ); \ if( FD_UNLIKELY( n<0 ) ) FD_LOG_ERR(( "snprintf failed" )); \ diff --git a/src/app/fdctl/monitor/monitor.c b/src/app/fdctl/monitor/monitor.c index c720073f5d..85fdee3573 100644 --- a/src/app/fdctl/monitor/monitor.c +++ b/src/app/fdctl/monitor/monitor.c @@ -2,9 +2,6 @@ #include "generated/monitor_seccomp.h" #include "helper.h" -#include "../run/run.h" -#include "../../../disco/tiles.h" -#include "../../../disco/fd_disco.h" #include #include @@ -156,7 +153,7 @@ link_snap( link_snap_t * snap_cur, if( FD_LIKELY( topo->tiles[ tile_idx ].in_link_poll[ in_idx ] ) ) { in_metrics = (ulong const *)fd_metrics_link_in( topo->tiles[ tile_idx ].metrics, in_idx ); } - + fd_topo_link_t * link = &topo->links[ topo->tiles[ tile_idx ].in_link_id[ in_idx ] ]; ulong producer_id = fd_topo_find_link_producer( topo, link ); FD_TEST( producer_id!=ULONG_MAX ); @@ -345,7 +342,7 @@ run_monitor( config_t * const config, PRINT( " | " ); printf_err_cnt ( &buf, &buf_sz, cur->nvcsw, prv->nvcsw ); PRINT( " | " ); printf_err_bool( &buf, &buf_sz, cur->in_backp, prv->in_backp ); PRINT( " | " ); printf_err_cnt ( &buf, &buf_sz, cur->backp_cnt, prv->backp_cnt ); - + ulong cur_hkeep_ticks = cur->regime_ticks[0]+cur->regime_ticks[1]+cur->regime_ticks[2]; ulong prv_hkeep_ticks = prv->regime_ticks[0]+prv->regime_ticks[1]+prv->regime_ticks[2]; diff --git a/src/app/fdctl/run/run.c b/src/app/fdctl/run/run.c index dd1acb7871..c0b31201bb 100644 --- a/src/app/fdctl/run/run.c +++ b/src/app/fdctl/run/run.c @@ -9,7 +9,6 @@ #include "generated/pidns_seccomp.h" #endif -#include "../../../disco/tiles.h" #include "../../../disco/topo/fd_pod_format.h" #include "../../../waltz/xdp/fd_xdp1.h" #include "../../../flamenco/runtime/fd_blockstore.h" diff --git a/src/app/fdctl/spy.c b/src/app/fdctl/spy.c index 79fab046f0..7f146cd506 100644 --- a/src/app/fdctl/spy.c +++ b/src/app/fdctl/spy.c @@ -6,8 +6,6 @@ #include "fdctl.h" #include "../../flamenco/gossip/fd_gossip.h" -#include "../../util/fd_util.h" -#include "../../ballet/base58/fd_base58.h" #include "../../flamenco/types/fd_types_yaml.h" #include "../../util/net/fd_eth.h" #include diff --git a/src/app/fdctl/utility.c b/src/app/fdctl/utility.c index 65ac00c628..d1592cb509 100644 --- a/src/app/fdctl/utility.c +++ b/src/app/fdctl/utility.c @@ -1,6 +1,8 @@ #define _GNU_SOURCE #include "utility.h" +#include "../../util/fd_util.h" +#include #include #include #include diff --git a/src/app/fdctl/utility.h b/src/app/fdctl/utility.h index 18db093b15..e479a546b0 100644 --- a/src/app/fdctl/utility.h +++ b/src/app/fdctl/utility.h @@ -1,7 +1,7 @@ #ifndef HEADER_fd_src_app_fdctl_utility_h #define HEADER_fd_src_app_fdctl_utility_h -#include "fdctl.h" +#include "../../util/fd_util_base.h" #include diff --git a/src/app/fddev/bench.c b/src/app/fddev/bench.c index 3f7ef695ab..61787a53ca 100644 --- a/src/app/fddev/bench.c +++ b/src/app/fddev/bench.c @@ -3,11 +3,8 @@ #include "../fdctl/configure/configure.h" #include "../fdctl/run/run.h" -#include "rpc_client/fd_rpc_client.h" #include "../../disco/topo/fd_topob.h" -#include "../../disco/keyguard/fd_keyload.h" -#include "../../util/net/fd_ip4.h" #include "../../util/shmem/fd_shmem_private.h" #include diff --git a/src/app/fddev/configure/genesis.c b/src/app/fddev/configure/genesis.c index 5f8fd2ce2b..2d792fd88d 100644 --- a/src/app/fddev/configure/genesis.c +++ b/src/app/fddev/configure/genesis.c @@ -2,7 +2,6 @@ #define FD_SCRATCH_USE_HANDHOLDING 1 #include "../../fdctl/configure/configure.h" -#include #include #include #include diff --git a/src/app/fddev/dev.c b/src/app/fddev/dev.c index 36fd0d0a93..127a4404fe 100644 --- a/src/app/fddev/dev.c +++ b/src/app/fddev/dev.c @@ -5,7 +5,6 @@ #include "../fdctl/configure/configure.h" #include "../fdctl/run/run.h" -#include "../../util/wksp/fd_wksp_private.h" #include #include @@ -14,8 +13,6 @@ #include #include -#include "../../util/tile/fd_tile_private.h" - void dev_cmd_args( int * pargc, char *** pargv, diff --git a/src/app/fddev/flame.c b/src/app/fddev/flame.c index eabab38225..0e6976366d 100644 --- a/src/app/fddev/flame.c +++ b/src/app/fddev/flame.c @@ -1,6 +1,5 @@ #define _GNU_SOURCE #include "fddev.h" -#include "../../util/net/fd_pcap.h" #include #include diff --git a/src/app/fddev/load.c b/src/app/fddev/load.c index 7662fe8c4c..e10b019ea4 100644 --- a/src/app/fddev/load.c +++ b/src/app/fddev/load.c @@ -7,8 +7,6 @@ #include "../../disco/topo/fd_topob.h" #include "../../util/net/fd_ip4.h" -#include "../../util/tile/fd_tile_private.h" - void load_cmd_perm( args_t * args, fd_caps_ctx_t * caps, diff --git a/src/app/fddev/tiles/fd_benchg.c b/src/app/fddev/tiles/fd_benchg.c index 7fc8a1b31f..186be85577 100644 --- a/src/app/fddev/tiles/fd_benchg.c +++ b/src/app/fddev/tiles/fd_benchg.c @@ -1,5 +1,4 @@ -#include "../../../disco/tiles.h" - +#include "../../../disco/topo/fd_topo.h" #include "../../../flamenco/types/fd_types_custom.h" #include "../../../flamenco/runtime/fd_system_ids_pp.h" diff --git a/src/app/fddev/tiles/fd_bencho.c b/src/app/fddev/tiles/fd_bencho.c index 17b3164389..ca77de6a62 100644 --- a/src/app/fddev/tiles/fd_bencho.c +++ b/src/app/fddev/tiles/fd_bencho.c @@ -1,5 +1,4 @@ -#include "../../../disco/tiles.h" - +#include "../../../disco/topo/fd_topo.h" #include "../rpc_client/fd_rpc_client.h" #include "../rpc_client/fd_rpc_client_private.h" @@ -93,7 +92,7 @@ service_block_hash( fd_bencho_ctx_t * ctx, ctx->blockhash_state = FD_BENCHO_STATE_WAIT; ctx->blockhash_deadline = fd_log_wallclock() + 400L * 1000L * 1000L; /* 400 millis til we fetch new blockhash */ fd_memcpy( fd_chunk_to_laddr( ctx->mem, ctx->out_chunk ), response->result.latest_block_hash.block_hash, 32 ); - fd_stem_publish( stem, 0UL, 0UL, ctx->out_chunk, 32UL, 0UL, 0UL, 0UL ); + fd_stem_publish( stem, 0UL, 0UL, ctx->out_chunk, 32UL, 0UL, 0UL, 0UL ); ctx->out_chunk = fd_dcache_compact_next( ctx->out_chunk, 32, ctx->out_chunk0, ctx->out_wmark ); fd_rpc_client_close( ctx->rpc, ctx->blockhash_request ); @@ -138,7 +137,7 @@ service_txn_count( fd_bencho_ctx_t * ctx ) { if( FD_UNLIKELY( response->status!=FD_RPC_CLIENT_SUCCESS ) ) FD_LOG_ERR(( "RPC server returned error %ld", response->status )); - + ulong txns = response->result.transaction_count.transaction_count; if( FD_LIKELY( ctx->txncount_measured1 ) ) FD_LOG_NOTICE(( "%lu txn/s", (ulong)((double)(txns - ctx->txncount_prev)/1.2 ))); diff --git a/src/app/fddev/tiles/fd_benchs.c b/src/app/fddev/tiles/fd_benchs.c index b00396c27c..5491dfa3ba 100644 --- a/src/app/fddev/tiles/fd_benchs.c +++ b/src/app/fddev/tiles/fd_benchs.c @@ -1,8 +1,7 @@ /* _GNU_SOURCE for recvmmsg and sendmmsg */ #define _GNU_SOURCE -#include "../../../disco/tiles.h" -#include "../../../waltz/xdp/fd_xsk_aio.h" +#include "../../../disco/topo/fd_topo.h" #include "../../../waltz/quic/fd_quic.h" #include "../../../waltz/tls/test_tls_helper.h" diff --git a/src/disco/topo/fd_topo.c b/src/disco/topo/fd_topo.c index 44a8d5d24e..3659a83b69 100644 --- a/src/disco/topo/fd_topo.c +++ b/src/disco/topo/fd_topo.c @@ -1,6 +1,5 @@ #include "fd_topo.h" -#include "../fd_disco_base.h" #include "../metrics/fd_metrics.h" #include "../quic/fd_tpu.h" #include "../../util/wksp/fd_wksp_private.h" diff --git a/src/disco/topo/fd_topo_run.c b/src/disco/topo/fd_topo_run.c index f1ad608707..a3f17459a5 100644 --- a/src/disco/topo/fd_topo_run.c +++ b/src/disco/topo/fd_topo_run.c @@ -4,7 +4,6 @@ #include "../metrics/fd_metrics.h" #include "../../waltz/xdp/fd_xdp1.h" #include "../../util/tile/fd_tile_private.h" -#include "../../util/shmem/fd_shmem_private.h" #include #include @@ -197,7 +196,7 @@ fd_topo_install_xdp( fd_topo_t * topo ) { FD_TEST( net0_tile_idx!=ULONG_MAX ); fd_topo_tile_t const * net0_tile = &topo->tiles[ net0_tile_idx ]; - ushort udp_port_candidates[] = { + ushort udp_port_candidates[] = { (ushort)net0_tile->net.legacy_transaction_listen_port, (ushort)net0_tile->net.quic_transaction_listen_port, (ushort)net0_tile->net.shred_listen_port,