LCOV - code coverage report
Current view: top level - app/firedancer-dev/commands - rotor.c (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 43 0.0 %
Date: 2026-09-17 04:28:31 Functions: 0 3 0.0 %

          Line data    Source code
       1             : /* The rotor command attaches to a running validator's rotor tile and
       2             :    prints the alpenglow chainer's orphan/repair worklist state. */
       3             : 
       4             : #include "../../../disco/topo/fd_topob.h"
       5             : #include "../../shared/fd_config.h" /* config_t */
       6             : #include "../../shared_dev/commands/dev.h" /* dev_cmd_perm */
       7             : 
       8             : #include "../../../discof/rotor/fd_rotor_tile.c" /* ctx_t + chainer layout helpers */
       9             : 
      10             : #include <stdio.h>
      11             : 
      12             : extern action_t fd_action_rotor;
      13             : 
      14             : /* rotor_chainer_reloc snapshots the chainer struct at chainer_laddr and
      15             :    fixes up its internal pointers for THIS process's mapping.  The tile
      16             :    stored direct pointers valid only in its own address space, so we
      17             :    replay fd_chainer_new's layout to recompute local addresses.  MUST
      18             :    mirror fd_chainer_new. */
      19             : 
      20             : static fd_chainer_t
      21           0 : rotor_chainer_reloc( void * chainer_laddr, ulong ele_max, ulong max_shreds_per_block ) {
      22           0 :   fd_chainer_t c = *(fd_chainer_t *)chainer_laddr;
      23             : 
      24           0 :   ulong blk_max       = ele_max * FD_CHAINER_SLOT_VER_MAX;
      25           0 :   ulong fec_max       = blk_max * ( max_shreds_per_block / FD_FEC_SHRED_CNT );
      26           0 :   ulong fec_chain_cnt = fd_fec_map_chain_cnt_est( fec_max );
      27           0 :   ulong blk_chain_cnt = fd_slotv_map_chain_cnt_est( blk_max );
      28             : 
      29           0 :   FD_SCRATCH_ALLOC_INIT( l, chainer_laddr );
      30           0 :   (void)          FD_SCRATCH_ALLOC_APPEND( l, fd_chainer_align(),      sizeof(fd_chainer_t)                        );
      31           0 :   c.fec_pool     = fd_fec_pool_join    ( FD_SCRATCH_ALLOC_APPEND( l, fd_fec_pool_align(),     fd_fec_pool_footprint    ( fec_max )        ) );
      32           0 :   c.fec_map      = fd_fec_map_join     ( FD_SCRATCH_ALLOC_APPEND( l, fd_fec_map_align(),      fd_fec_map_footprint     ( fec_chain_cnt )  ) );
      33           0 :   c.slotv_pool   = fd_slotv_pool_join  ( FD_SCRATCH_ALLOC_APPEND( l, fd_slotv_pool_align(),   fd_slotv_pool_footprint  ( blk_max )        ) );
      34           0 :   c.fec_tbl      =                       FD_SCRATCH_ALLOC_APPEND( l, alignof(uint),           fec_max*sizeof(uint)                        );
      35           0 :   c.slotv_map    = fd_slotv_map_join   ( FD_SCRATCH_ALLOC_APPEND( l, fd_slotv_map_align(),    fd_slotv_map_footprint   ( blk_chain_cnt ) ) );
      36           0 :   c.work_pool    = fd_work_pool_join   ( FD_SCRATCH_ALLOC_APPEND( l, fd_work_pool_align(),    fd_work_pool_footprint   ( blk_max )        ) );
      37           0 :   c.work_map     = fd_work_map_join    ( FD_SCRATCH_ALLOC_APPEND( l, fd_work_map_align(),     fd_work_map_footprint    ( blk_chain_cnt )) );
      38           0 :   c.repair_treap = fd_work_repair_join ( FD_SCRATCH_ALLOC_APPEND( l, fd_work_repair_align(),  fd_work_repair_footprint ( blk_max )        ) );
      39           0 :   c.orphan_treap = fd_work_orphan_join ( FD_SCRATCH_ALLOC_APPEND( l, fd_work_orphan_align(),  fd_work_orphan_footprint ( blk_max )        ) );
      40           0 :   c.bfs          = bfs_join            ( FD_SCRATCH_ALLOC_APPEND( l, bfs_align(),             bfs_footprint            ( blk_max )        ) );
      41           0 :   c.out_queue    = out_queue_join      ( FD_SCRATCH_ALLOC_APPEND( l, out_queue_align(),       out_queue_footprint      ( fec_max )        ) );
      42             : 
      43           0 :   return c;
      44           0 : }
      45             : 
      46             : static void
      47             : rotor_cmd_args( int *    pargc FD_PARAM_UNUSED,
      48             :                 char *** pargv FD_PARAM_UNUSED,
      49           0 :                 args_t * args  FD_PARAM_UNUSED ) {}
      50             : 
      51             : static void
      52             : rotor_cmd_fn( args_t *   args FD_PARAM_UNUSED,
      53           0 :               config_t * config ) {
      54           0 :   fd_topo_t * topo = &config->topo;
      55             : 
      56           0 :   ulong wksp_id = fd_topo_find_wksp( topo, "rotor" );
      57           0 :   if( FD_UNLIKELY( wksp_id==ULONG_MAX ) ) FD_LOG_ERR(( "rotor workspace not found (is the validator running with --alpenglow?)" ));
      58           0 :   fd_topo_wksp_t * rotor_wksp = &topo->workspaces[ wksp_id ];
      59           0 :   fd_topo_join_workspace( topo, rotor_wksp, FD_SHMEM_JOIN_MODE_READ_ONLY, FD_TOPO_CORE_DUMP_LEVEL_DISABLED );
      60             : 
      61           0 :   ulong tile_id = fd_topo_find_tile( topo, "rotor", 0UL );
      62           0 :   if( FD_UNLIKELY( tile_id==ULONG_MAX ) ) FD_LOG_ERR(( "rotor tile not found" ));
      63           0 :   fd_topo_tile_t * tile    = &topo->tiles[ tile_id ];
      64           0 :   void *           scratch = fd_topo_obj_laddr( topo, tile->tile_obj_id );
      65           0 :   if( FD_UNLIKELY( !scratch ) ) FD_LOG_ERR(( "Failed to access rotor tile scratch memory" ));
      66             : 
      67           0 :   ulong ele_max              = tile->rotor.slot_max;
      68           0 :   ulong max_shreds_per_block = tile->rotor.max_shreds_per_block;
      69             : 
      70             :   /* Walk the tile scratch layout (ctx, protocol, chainer) to the chainer
      71             :      local address; mirrors the rotor tile's unprivileged_init. */
      72           0 :   FD_SCRATCH_ALLOC_INIT( l, scratch );
      73           0 :   (void)               FD_SCRATCH_ALLOC_APPEND( l, alignof(ctx_t),        sizeof(ctx_t)                    );
      74           0 :   (void)               FD_SCRATCH_ALLOC_APPEND( l, fd_repair_align(),    fd_repair_footprint()            );
      75           0 :   void * chainer_laddr = FD_SCRATCH_ALLOC_APPEND( l, fd_chainer_align(), fd_chainer_footprint( ele_max, max_shreds_per_block ) );
      76             : 
      77           0 :   fd_chainer_t c = rotor_chainer_reloc( chainer_laddr, ele_max, max_shreds_per_block );
      78           0 :   if( FD_UNLIKELY( c.magic!=FD_CHAINER_MAGIC ) ) FD_LOG_ERR(( "bad chainer magic 0x%lx (tile not initialized?)", c.magic ));
      79             : 
      80           0 :   fd_chainer_print( &c );
      81             :   fflush( stdout );
      82           0 : }
      83             : 
      84             : action_t fd_action_rotor = {
      85             :   .name        = "rotor",
      86             :   .args        = rotor_cmd_args,
      87             :   .fn          = rotor_cmd_fn,
      88             :   .perm        = dev_cmd_perm,
      89             :   .description = "Print the alpenglow rotor tile's chainer worklist state",
      90             :   .usage       = "rotor",
      91             : };

Generated by: LCOV version 1.14