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 : if( FD_UNLIKELY( header->payload_sz>FD_SLICE_MAX_WITH_HEADERS ) ) { 65 0 : FD_LOG_CRIT(( "Invalid payload size in shredcap slice header: %lu", header->payload_sz )); 66 0 : } 67 0 : } 68 : 69 : /* fd_shredcap_slice_trailer_validate will crash the program if the 70 : trailer is obviously corrupted. */ 71 : static inline void 72 0 : fd_shredcap_slice_trailer_validate( fd_shredcap_slice_trailer_msg_t const * trailer ) { 73 0 : if( FD_UNLIKELY( trailer->magic!=FD_SHREDCAP_SLICE_TRAILER_MAGIC ) ) { 74 0 : FD_LOG_CRIT(( "Invalid magic number in shredcap slice trailer: %lu", trailer->magic )); 75 0 : } 76 0 : if( FD_UNLIKELY( trailer->version != FD_SHREDCAP_SLICE_TRAILER_V1 ) ) { 77 0 : FD_LOG_CRIT(( "Invalid version in shredcap slice trailer: %lu", trailer->version )); 78 0 : } 79 0 : } 80 : 81 : 82 : /* Shredcap bank hash capture format. This format enables us to capture 83 : the bank hashes calculated by the network in the replay tile. We 84 : expect the format to be as follows: 85 : 86 : +-------------------------------------------------------------------+ 87 : | fd_shredcap_bank_hash_msg_v1 | 88 : +-------------------------------------------------------------------+ 89 : | fd_hash_t bank_hash | 90 : +-------------------------------------------------------------------+ 91 : | ... This is repeated for every bank hash in the replay tile | 92 : +-------------------------------------------------------------------+ 93 : 94 : As a note, the bank hashes are not necessarily needed to be in a 95 : strict order. They are recorded in the order that the slots are 96 : finished executing. 97 : */ 98 : 99 : struct __attribute__((packed)) fd_shredcap_bank_hash_msg_v1 { 100 : ulong magic; 101 : ulong version; 102 : ulong slot; 103 : fd_hash_t bank_hash; 104 : }; 105 : typedef struct fd_shredcap_bank_hash_msg_v1 fd_shredcap_bank_hash_msg_t; 106 0 : #define FD_SHREDCAP_BANK_HASH_MAGIC (0X810810810UL) 107 0 : #define FD_SHREDCAP_BANK_HASH_V1 (0x1UL) 108 0 : #define FD_SHREDCAP_BANK_HASH_FOOTPRINT (sizeof(fd_shredcap_bank_hash_msg_t)) 109 : 110 : /* fd_shredcap_bank_hash_msg_validate will crash the program if the 111 : bank hash message is obviously corrupted. */ 112 : static inline void 113 0 : fd_shredcap_bank_hash_msg_validate( fd_shredcap_bank_hash_msg_t const * msg ) { 114 0 : if( FD_UNLIKELY( msg->magic!=FD_SHREDCAP_BANK_HASH_MAGIC ) ) { 115 0 : FD_LOG_CRIT(( "Invalid magic number in shredcap bank hash message: %lu", msg->magic )); 116 0 : } 117 0 : if( FD_UNLIKELY( msg->version!=FD_SHREDCAP_BANK_HASH_V1 ) ) { 118 0 : FD_LOG_CRIT(( "Invalid version in shredcap bank hash message: %lu", msg->version )); 119 0 : } 120 0 : } 121 : 122 : 123 : #endif // HEADER_fd_src_app_fdshredcap_fdshredcap_h 124 : 125 : #endif /* HEADER_fd_src_discof_fd_discof_h */