LCOV - code coverage report
Current view: top level - app/firedancer/commands - shred_version.c (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 27 0.0 %
Date: 2026-10-22 18:10:43 Functions: 0 1 0.0 %

          Line data    Source code
       1             : #include "../../shared/fd_config.h"
       2             : #include "../../shared/fd_action.h"
       3             : 
       4             : #include "../../../disco/topo/fd_topo.h"
       5             : #include "../../../disco/topo/fd_dns_resolve.h"
       6             : #include "../../../discof/ipecho/fd_ipecho_client.h"
       7             : 
       8             : #include <errno.h>
       9             : #include <stdlib.h>
      10             : #include <sys/epoll.h>
      11             : #include <unistd.h>
      12             : 
      13             : void
      14             : shred_version_cmd_fn( args_t *   args,
      15           0 :                       config_t * config ) {
      16           0 :   (void)args;
      17             : 
      18           0 :   void * _client = aligned_alloc( FD_IPECHO_CLIENT_ALIGN, fd_ipecho_client_footprint() );
      19           0 :   FD_TEST( _client );
      20           0 :   fd_ipecho_client_t * client = fd_ipecho_client_join( fd_ipecho_client_new( _client ) );
      21           0 :   FD_TEST( client );
      22             : 
      23           0 :   ulong tile_idx = fd_topo_find_tile( &config->topo, "gossip", 0UL );
      24           0 :   FD_TEST( tile_idx!=ULONG_MAX );
      25             : 
      26           0 :   fd_topo_tile_t * tile = &config->topo.tiles[ tile_idx ];
      27             : 
      28           0 :   fd_ip4_port_t entrypoints[ FD_TOPO_GOSSIP_ENTRYPOINTS_MAX ];
      29           0 :   fd_dns_resolve_peers( tile->gossip.entrypoints[ 0 ], sizeof(tile->gossip.entrypoints[ 0 ]), tile->gossip.entrypoints_cnt, "gossip.entrypoints", entrypoints );
      30           0 :   int epoll_fd = epoll_create1( 0 );
      31           0 :   if( FD_UNLIKELY( -1==epoll_fd ) ) FD_LOG_ERR(( "epoll_create1 failed (%i-%s)", errno, fd_io_strerror( errno ) ));
      32           0 :   fd_ipecho_client_init( client, entrypoints, tile->gossip.entrypoints_cnt, epoll_fd );
      33             : 
      34           0 :   for(;;) {
      35           0 :     ushort shred_version = 0;
      36           0 :     int _charge_busy;
      37           0 :     int err = fd_ipecho_client_poll( client, fd_log_wallclock(), &shred_version, &_charge_busy );
      38           0 :     if( FD_UNLIKELY( -1==err ) ) FD_LOG_ERR(( "couldn't get shred version" ));
      39           0 :     if( FD_UNLIKELY( !err) ) {
      40           0 :       FD_LOG_STDOUT(( "%hu\n", shred_version ));
      41           0 :       break;
      42           0 :     }
      43           0 :     struct epoll_event ev;
      44           0 :     if( FD_UNLIKELY( -1==epoll_wait( epoll_fd, &ev, 1, 100 ) && errno!=EINTR ) ) FD_LOG_ERR(( "epoll_wait failed (%i-%s)", errno, fd_io_strerror( errno ) ));
      45           0 :   }
      46           0 : }
      47             : 
      48             : action_t fd_action_shred_version = {
      49             :   .name        = "shred-version",
      50             :   .fn          = shred_version_cmd_fn,
      51             :   .description = "Retrieve the current shred version from the entrypoints",
      52             :   .detail      = "Connects to the gossip entrypoints listed in the configuration file using the\n"
      53             :                  "IP echo protocol, prints the cluster's current shred version to stdout, and\n"
      54             :                  "exits.  Useful for filling in [consensus.expected_shred_version].  Does not\n"
      55             :                  "require a running validator, but the entrypoints must be reachable.",
      56             :   .usage       = "shred-version",
      57             : };

Generated by: LCOV version 1.14