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