LCOV - code coverage report
Current view: top level - discof/poh - fd_poh.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 14 0.0 %
Date: 2026-10-22 18:10:43 Functions: 0 24 0.0 %

          Line data    Source code
       1             : #ifndef HEADER_fd_src_discof_poh_fd_poh_h
       2             : #define HEADER_fd_src_discof_poh_fd_poh_h
       3             : 
       4             : #include "../../disco/pack/fd_pack.h"
       5             : 
       6             : /* The maximum number of microblocks pack may put in a slot: one per
       7             :    non-tick hash position (one per tick in low power mode), less the
       8             :    phantom microblock PoH reserves for the done_packing message.  This
       9             :    is not consensus critical; PoH reserves this many hashes so it never
      10             :    runs out of positions to mixin microblocks still coming from pack.
      11             :    Pack shrinks its live bound with the time left in the slot (see
      12             :    compute_dynamic_max_microblocks in fd_pack_tile.c), so the reserve
      13             :    is gone by the end of the slot rather than hashed through. */
      14             : 
      15             : /* Alpenglow has one tick per block, so the hash budget does not bound
      16             :    microblocks; pack is given this fixed budget instead. */
      17           0 : #define FD_POH_ALPENGLOW_MAX_MICROBLOCKS_PER_SLOT (131072UL)
      18             : 
      19             : FD_FN_CONST static inline ulong
      20             : fd_poh_max_microblocks_per_slot( ulong ticks_per_slot,
      21           0 :                                  ulong hashcnt_per_tick ) {
      22           0 :   return ticks_per_slot*(fd_ulong_max( hashcnt_per_tick, 2UL )-1UL)-1UL; /* low power genesis encodes hashes_per_tick as 0 or 1 */
      23           0 : }
      24             : 
      25             : /* When we are hashing in the background in case a prior leader skips
      26             :    their slot, we need to store the result of each tick hash so we can
      27             :    publish them when we become leader.  The network requires at least
      28             :    one leader slot to publish in each epoch for the leader schedule to
      29             :    generate, so in the worst case we might need two full epochs of slots
      30             :    to store the hashes.  (Eg, if epoch T only had a published slot in
      31             :    position 0 and epoch T+1 only had a published slot right at the end).
      32             : 
      33             :    There is a tighter bound: the block data limit at the 200ms slot
      34             :    params is FD_PACK_MAX_DATA_PER_BLOCK, or 7,810,880 bytes per slot.
      35             :    At 48 bytes per tick, it is not possible to publish a slot that skips
      36             :    162,727 or more prior slots. */
      37             : #define MAX_SKIPPED_TICKS (1UL+(FD_PACK_MAX_DATA_PER_BLOCK/48UL))
      38             : 
      39             : /* Per-transaction lifecycle timing for a leader block, captured by poh
      40             :    in mix order for telemetry purposes.  The records are stored in a
      41             :    shared txn_timing[] array. */
      42             : 
      43             : struct fd_leader_txn_timing_rec {
      44             :   long received_ns;
      45             :   long dispatched_ticks;
      46             :   long replayed_ticks;
      47             :   long poh_mixed_ticks;
      48             : };
      49             : 
      50             : typedef struct fd_leader_txn_timing_rec fd_leader_txn_timing_rec_t;
      51             : 
      52             : FD_STATIC_ASSERT( sizeof(fd_leader_txn_timing_rec_t)==32UL, leader_txn_timing_rec );
      53             : 
      54             : /* The ldr_tt object holds FD_LEADER_TXN_TIMING_TABLE_CNT tables back to
      55             :    back, each with room for config->limits.max_txn_per_slot records, so
      56             :    the table stride is a runtime value: index them with
      57             :    fd_leader_txn_timing_table(). */
      58             : 
      59             : struct fd_leader_txn_timing_table {
      60             :   ulong slot;
      61             :   ulong cnt;
      62             :   fd_leader_txn_timing_rec_t rec[]; /* max_txn_per_slot */
      63             : };
      64             : 
      65             : typedef struct fd_leader_txn_timing_table fd_leader_txn_timing_table_t;
      66             : 
      67           0 : #define FD_LEADER_TXN_TIMING_TABLE_CNT (2UL)
      68             : 
      69             : FD_FN_CONST static inline ulong
      70           0 : fd_leader_txn_timing_table_footprint( ulong max_txn_per_slot ) {
      71           0 :   return sizeof(fd_leader_txn_timing_table_t)+max_txn_per_slot*sizeof(fd_leader_txn_timing_rec_t);
      72           0 : }
      73             : 
      74             : FD_FN_CONST static inline fd_leader_txn_timing_table_t const *
      75             : fd_leader_txn_timing_table_const( fd_leader_txn_timing_table_t const * tables,
      76             :                                   ulong                                idx,
      77           0 :                                   ulong                                max_txn_per_slot ) {
      78           0 :   return (fd_leader_txn_timing_table_t const *)( (uchar const *)tables + idx*fd_leader_txn_timing_table_footprint( max_txn_per_slot ) );
      79           0 : }
      80             : 
      81             : FD_FN_CONST static inline fd_leader_txn_timing_table_t *
      82             : fd_leader_txn_timing_table( fd_leader_txn_timing_table_t * tables,
      83             :                             ulong                          idx,
      84           0 :                             ulong                          max_txn_per_slot ) {
      85           0 :   return (fd_leader_txn_timing_table_t *)fd_leader_txn_timing_table_const( tables, idx, max_txn_per_slot );
      86           0 : }
      87             : 
      88             : struct fd_poh_leader_slot_ended {
      89             :   int   completed;
      90             :   ulong slot;
      91             :   uchar blockhash[ 32UL ];
      92             : 
      93             :   ulong timing_table_idx;
      94             : 
      95             :   ulong microblock_count;
      96             :   ulong pack_block_cost;
      97             :   ulong pack_vote_cost;
      98             :   ulong pack_data_bytes;
      99             :   ulong bundle_txn_count;
     100             :   int   pack_end_reason;
     101             :   long  pack_start_ns;
     102             :   long  pack_end_ns;
     103             : };
     104             : 
     105             : typedef struct fd_poh_leader_slot_ended fd_poh_leader_slot_ended_t;
     106             : 
     107             : struct fd_poh_out_private {
     108             :   ulong       idx;
     109             :   fd_wksp_t * mem;
     110             :   ulong       chunk0;
     111             :   ulong       wmark;
     112             :   ulong       chunk;
     113             : };
     114             : 
     115             : typedef struct fd_poh_out_private fd_poh_out_t;
     116             : 
     117             : #endif /* HEADER_fd_src_discof_poh_fd_poh_h */

Generated by: LCOV version 1.14