LCOV - code coverage report
Current view: top level - disco/shred - fd_shred_tile.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 8 18 44.4 %
Date: 2026-09-17 04:28:31 Functions: 2 78 2.6 %

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

Generated by: LCOV version 1.14