LCOV - code coverage report
Current view: top level - disco/shred - fd_shred_tile.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 20 0.0 %
Date: 2026-10-22 18:10:43 Functions: 0 55 0.0 %

          Line data    Source code
       1             : #ifndef HEADER_fd_src_disco_shred_fd_shred_tile_h
       2             : #define HEADER_fd_src_disco_shred_fd_shred_tile_h
       3             : 
       4             : #include "../tiles.h"
       5             : #include "fd_fec_resolver.h"
       6             : #include "fd_shred_batch.h"
       7             : 
       8           0 : #define FD_SHRED_STEM_BURST ( FD_SHRED_BATCH_FEC_SETS_MAX*(FD_FEC_SHRED_CNT+1UL) )
       9           0 : #define FD_SHRED_FIREDANCER_FEC_EXPOSURE ( FD_SHRED_BATCH_FEC_SETS_MAX )
      10             : 
      11             : /* Leader FEC sets wait for the sign tile in a queue of up to
      12             :    FD_SHRED_SIGN_PEND_MAX. */
      13           0 : #define FD_SHRED_SIGN_PEND_MAX ( 2UL*FD_SHRED_BATCH_FEC_SETS_MAX )
      14             : 
      15             : FD_FN_CONST static inline ulong
      16             : fd_shred_tile_fec_set_cnt( ulong fec_exposure,
      17           0 :                            ulong fec_resolver_depth ) {
      18           0 :   return 2UL*fec_exposure + fec_resolver_depth + FD_SHRED_SIGN_PEND_MAX + 2UL;
      19           0 : }
      20             : 
      21             : /* Forward declarations */
      22             : typedef struct fd_fec_resolver fd_fec_resolver_t;
      23             : typedef struct fd_keyswitch_private fd_keyswitch_t;
      24             : 
      25             : /* Shred tile context structure */
      26             : typedef struct {
      27             :   fd_shredder_t      * shredder;
      28             :   fd_fec_resolver_t  * resolver;
      29             :   fd_pubkey_t          identity_key[1]; /* Just the public key */
      30             :   /* ... rest of the structure members ... */
      31             : } fd_shred_shared_ctx_t;
      32             : 
      33             : /* shred_out has 3 possible message types, but 8 different message sigs
      34             :    to differentiate between different data sources.  All individual
      35             :    shred messages
      36             :    SHRED_SIG_SRC_{TURBINE,LEADER,RECONSTRUCTED,REPAIR,BAD_REPAIR} have
      37             :    the same dcache type fd_shred_base_t.  Only repair/bad_repair shreds
      38             :    will populate the rnonce field.
      39             : 
      40             :    SHRED_SIG_FEC_{EVICTED,COMPLETE,COMPLETE_LEADER,COMPLETE_AGAIN} are
      41             :    not generated on every shred, but rather on events where a FEC set is
      42             :    completed by the fec_resolver or evicted from the fec_resolver.  In
      43             :    the case that a FEC set is completed by the 32nd shred in a FEC set,
      44             :    both a shred message and a complete message will be published.  It
      45             :    is convenient for downstream consumers to have both messages
      46             :    available.
      47             : 
      48             :    The last 32 LSB of sig is the data source of the message, and the
      49             :    first 32 MSB is the shred processing result. */
      50             : 
      51             : /* shred_base_t sigs */
      52           0 : #define SHRED_SIG_SRC_TURBINE         (0U) /* turbine shred */
      53           0 : #define SHRED_SIG_SRC_LEADER          (1U) /* shred created by leader */
      54           0 : #define SHRED_SIG_SRC_RECONSTRUCTED   (2U) /* reconstructed data shred */
      55           0 : #define SHRED_SIG_SRC_REPAIR          (3U) /* repair shred */
      56           0 : #define SHRED_SIG_SRC_BAD_REPAIR      (4U) /* repair shred with unverifiable nonce */
      57             : 
      58             : /* fec_resolver event sigs */
      59           0 : #define SHRED_SIG_FEC_EVICTED         (5UL) /* evicted */
      60           0 : #define SHRED_SIG_FEC_COMPLETE        (6UL) /* FEC set complete */
      61           0 : #define SHRED_SIG_FEC_COMPLETE_LEADER (7UL) /* leader FEC set complete */
      62           0 : #define SHRED_SIG_FEC_COMPLETE_AGAIN  (8UL) /* FEC set complete again, it was already in the store (Alpenglow only) */
      63             : 
      64             : /* SHRED_SIG_FUTURE has no payload: a turbine shred past the fec
      65             :    resolver's slot range, signed by its slot leader, with the slot in
      66             :    the high 32 bits of sig (Alpenglow only) */
      67           0 : #define SHRED_SIG_FUTURE              (9UL)
      68             : 
      69           0 : static inline ulong fd_shred_sig_future     ( ulong slot ) { return (slot<<32UL) | SHRED_SIG_FUTURE; }
      70           0 : static inline ulong fd_shred_sig_future_slot( ulong sig  ) { return sig>>32UL; }
      71             : 
      72             : /* shred processing result (first 32 bits of sig) */
      73             : #define SHRED_SIG_RESULT_COMPLETES     ( 1)
      74             : #define SHRED_SIG_RESULT_OKAY          ( 0) /* default */
      75             : #define SHRED_SIG_RESULT_DUPLICATE     (-1)
      76             : #define SHRED_SIG_RESULT_EQVOC         (-4)
      77             : 
      78             : FD_STATIC_ASSERT( SHRED_SIG_RESULT_COMPLETES == FD_FEC_RESOLVER_SHRED_COMPLETES, "shred sig result does not match fec_resolver result" );
      79             : FD_STATIC_ASSERT( SHRED_SIG_RESULT_OKAY      == FD_FEC_RESOLVER_SHRED_OKAY,      "shred sig result does not match fec_resolver result" );
      80             : FD_STATIC_ASSERT( SHRED_SIG_RESULT_DUPLICATE == FD_FEC_RESOLVER_SHRED_DUPLICATE, "shred sig result does not match fec_resolver result" );
      81             : FD_STATIC_ASSERT( SHRED_SIG_RESULT_EQVOC     == FD_FEC_RESOLVER_SHRED_EQUIVOC,   "shred sig result does not match fec_resolver result" );
      82             : 
      83           0 : static inline int  fd_shred_sig_res( ulong sig ) { return (int)(sig >> 32UL); }
      84           0 : static inline uint fd_shred_sig_src( ulong sig ) { return (uint)sig; }
      85             : 
      86             : /* For all individual shred messages:
      87             :    SHRED_SIG_SRC_{TURBINE,LEADER,RECONSTRUCTED,REPAIR,BAD_REPAIR} */
      88             : struct fd_shred_base {
      89             :   fd_hash_t merkle_root;
      90             :   union {
      91             :     uchar        shred_[ FD_SHRED_MAX_SZ ];
      92             :     fd_shred_t   shred;
      93             :   };
      94             :   uint      rnonce;        /* populated only for repair/bad_repair shreds */
      95             : };
      96             : typedef struct fd_shred_base fd_shred_base_t;
      97             : 
      98             : /* For the FEC evicted message: SHRED_SIG_FEC_EVICTED */
      99             : struct fd_fec_evicted {
     100             :   ulong slot;
     101             :   uint  fec_set_idx;
     102             :   fd_hash_t merkle_root;
     103             : };
     104             : typedef struct fd_fec_evicted fd_fec_evicted_t;
     105             : 
     106             : 
     107             : /* For an FEC complete message: SHRED_SIG_FEC_COMPLETE or SHRED_SIG_FEC_COMPLETE_LEADER */
     108             : struct fd_fec_complete {
     109             :   fd_hash_t  merkle_root;    /* placed first to match format of shred base */
     110             :   fd_shred_t last_shred_hdr; /* header of last data shred in the FEC set */
     111             :   fd_hash_t  chained_merkle_root;
     112             : 
     113             :   ulong turbine_shred_cnt;
     114             :   ulong repair_shred_cnt;
     115             :   ulong reconstructed_shred_cnt; /* data plus coding */
     116             : 
     117             :   /* Bit j set if the shred with in-type index j was received rather
     118             :      than recovered, repair_data_rcvd restricted to data shreds that
     119             :      arrived by repair.  All 0 for LEADER and AGAIN completions. */
     120             :   uint data_shred_rcvd;
     121             :   uint parity_shred_rcvd;
     122             :   uint repair_data_rcvd;
     123             : };
     124             : typedef struct fd_fec_complete fd_fec_complete_t;
     125             : 
     126             : union fd_shred_message {
     127             :   fd_shred_base_t   shred;
     128             :   fd_fec_evicted_t  evicted;
     129             :   fd_fec_complete_t complete;
     130             : };
     131             : typedef union fd_shred_message fd_shred_message_t;
     132             : 
     133             : #endif /* HEADER_fd_src_disco_shred_fd_shred_tile_h */

Generated by: LCOV version 1.14