LCOV - code coverage report
Current view: top level - discof - fd_discof.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 33 0.0 %
Date: 2025-10-13 04:42:14 Functions: 0 3 0.0 %

          Line data    Source code
       1             : #ifndef HEADER_fd_src_discof_fd_discof_h
       2             : #define HEADER_fd_src_discof_fd_discof_h
       3             : 
       4             : #ifndef HEADER_fd_src_app_fdshredcap_fdshredcap_h
       5             : #define HEADER_fd_src_app_fdshredcap_fdshredcap_h
       6             : 
       7             : #include "../flamenco/types/fd_types_custom.h"
       8             : #include "../flamenco/runtime/fd_runtime.h"
       9             : 
      10             : /* TODO: Consider adding a file-wide header and trailer to both of the
      11             :    following file formats. */
      12             : 
      13             : /* TODO: Consider adding a version-agnostic header and trailer to both
      14             :    of the following file formats. */
      15             : 
      16             : /* TODO: Consider adding accessors/mutators for each of these fields. */
      17             : 
      18             : /* Shredcap slice capture format. This format enables us to capture
      19             :    slices of shreds from the repair tile as they are made ready for
      20             :    the replay tile. We expect the format to be as follows:
      21             : 
      22             :    +-------------------------------------------------------------------+
      23             :    | fd_shredcap_slice_header_msg_t                                    |
      24             :    +-------------------------------------------------------------------+
      25             :    | fd_shred_t (header and payload)                                   |
      26             :    | ... This is repeated for every data shred in the slice            |
      27             :    +-------------------------------------------------------------------+
      28             :    | fd_shredcap_slice_trailer_msg_t                                   |
      29             :    +-------------------------------------------------------------------+
      30             :    | ... This is repeated for every captured slice                     |
      31             :    +-------------------------------------------------------------------+
      32             : 
      33             :   */
      34             : 
      35             : struct __attribute__((packed)) fd_shredcap_slice_header_msg_v1  {
      36             :   ulong magic;
      37             :   ulong version;
      38             :   ulong payload_sz;
      39             : };
      40             : typedef struct fd_shredcap_slice_header_msg_v1 fd_shredcap_slice_header_msg_t;
      41           0 : #define FD_SHREDCAP_SLICE_HEADER_MAGIC     (0XF00F00F00UL)
      42           0 : #define FD_SHREDCAP_SLICE_HEADER_V1        (0x1UL)
      43           0 : #define FD_SHREDCAP_SLICE_HEADER_FOOTPRINT (sizeof(fd_shredcap_slice_header_msg_t))
      44             : 
      45             : struct __attribute__((packed)) fd_shredcap_slice_trailer_msg_v1 {
      46             :   ulong magic;
      47             :   ulong version;
      48             : };
      49             : typedef struct fd_shredcap_slice_trailer_msg_v1 fd_shredcap_slice_trailer_msg_t;
      50           0 : #define FD_SHREDCAP_SLICE_TRAILER_MAGIC     (0X79397939UL)
      51           0 : #define FD_SHREDCAP_SLICE_TRAILER_V1        (0x1UL)
      52           0 : #define FD_SHREDCAP_SLICE_TRAILER_FOOTPRINT (sizeof(fd_shredcap_slice_trailer_msg_t))
      53             : 
      54             : /* fd_shredcap_slice_header_validate will crash the program if the
      55             :    header is obviously corrupted. */
      56             : static inline void
      57           0 : fd_shredcap_slice_header_validate( fd_shredcap_slice_header_msg_t const * header ) {
      58           0 :   if( FD_UNLIKELY( header->magic!=FD_SHREDCAP_SLICE_HEADER_MAGIC ) ) {
      59           0 :     FD_LOG_CRIT(( "Invalid magic number in shredcap slice header: %lu", header->magic ));
      60           0 :   }
      61           0 :   if( FD_UNLIKELY( header->version != FD_SHREDCAP_SLICE_HEADER_V1 ) ) {
      62           0 :     FD_LOG_CRIT(( "Invalid version in shredcap slice header: %lu", header->version ));
      63           0 :   }
      64           0 : }
      65             : 
      66             : /* fd_shredcap_slice_trailer_validate will crash the program if the
      67             :    trailer is obviously corrupted. */
      68             : static inline void
      69           0 : fd_shredcap_slice_trailer_validate( fd_shredcap_slice_trailer_msg_t const * trailer ) {
      70           0 :   if( FD_UNLIKELY( trailer->magic!=FD_SHREDCAP_SLICE_TRAILER_MAGIC ) ) {
      71           0 :     FD_LOG_CRIT(( "Invalid magic number in shredcap slice trailer: %lu", trailer->magic ));
      72           0 :   }
      73           0 :   if( FD_UNLIKELY( trailer->version != FD_SHREDCAP_SLICE_TRAILER_V1 ) ) {
      74           0 :     FD_LOG_CRIT(( "Invalid version in shredcap slice trailer: %lu", trailer->version ));
      75           0 :   }
      76           0 : }
      77             : 
      78             : 
      79             : /* Shredcap bank hash capture format. This format enables us to capture
      80             :    the bank hashes calculated by the network in the replay tile. We
      81             :    expect the format to be as follows:
      82             : 
      83             :    +-------------------------------------------------------------------+
      84             :    | fd_shredcap_bank_hash_msg_v1                                      |
      85             :    +-------------------------------------------------------------------+
      86             :    | fd_hash_t bank_hash                                               |
      87             :    +-------------------------------------------------------------------+
      88             :    | ... This is repeated for every bank hash in the replay tile       |
      89             :    +-------------------------------------------------------------------+
      90             : 
      91             :    As a note, the bank hashes are not necessarily needed to be in a
      92             :    strict order. They are recorded in the order that the slots are
      93             :    finished executing.
      94             :   */
      95             : 
      96             : struct __attribute__((packed)) fd_shredcap_bank_hash_msg_v1 {
      97             :   ulong     magic;
      98             :   ulong     version;
      99             :   ulong     slot;
     100             :   fd_hash_t bank_hash;
     101             : };
     102             : typedef struct fd_shredcap_bank_hash_msg_v1 fd_shredcap_bank_hash_msg_t;
     103           0 : #define FD_SHREDCAP_BANK_HASH_MAGIC     (0X810810810UL)
     104           0 : #define FD_SHREDCAP_BANK_HASH_V1        (0x1UL)
     105           0 : #define FD_SHREDCAP_BANK_HASH_FOOTPRINT (sizeof(fd_shredcap_bank_hash_msg_t))
     106             : 
     107             : /* fd_shredcap_bank_hash_msg_validate will crash the program if the
     108             :    bank hash message is obviously corrupted. */
     109             : static inline void
     110           0 : fd_shredcap_bank_hash_msg_validate( fd_shredcap_bank_hash_msg_t const * msg ) {
     111           0 :   if( FD_UNLIKELY( msg->magic!=FD_SHREDCAP_BANK_HASH_MAGIC ) ) {
     112           0 :     FD_LOG_CRIT(( "Invalid magic number in shredcap bank hash message: %lu", msg->magic ));
     113           0 :   }
     114           0 :   if( FD_UNLIKELY( msg->version!=FD_SHREDCAP_BANK_HASH_V1 ) ) {
     115           0 :     FD_LOG_CRIT(( "Invalid version in shredcap bank hash message: %lu", msg->version ));
     116           0 :   }
     117           0 : }
     118             : 
     119             : 
     120             : #endif // HEADER_fd_src_app_fdshredcap_fdshredcap_h
     121             : 
     122             : #endif /* HEADER_fd_src_discof_fd_discof_h */

Generated by: LCOV version 1.14