Line data Source code
1 : #ifndef HEADER_fd_src_flamenco_runtime_fd_types_custom 2 : #define HEADER_fd_src_flamenco_runtime_fd_types_custom 3 : 4 : #include "fd_types_meta.h" 5 : #include "fd_bincode.h" 6 : #include "../../ballet/ed25519/fd_ed25519.h" 7 : #include "../../ballet/txn/fd_txn.h" 8 : #include "../../util/net/fd_ip4.h" 9 : 10 0 : #define FD_HASH_FOOTPRINT (32UL) 11 0 : #define FD_HASH_ALIGN (8UL) 12 0 : #define FD_PUBKEY_FOOTPRINT FD_HASH_FOOTPRINT 13 0 : #define FD_PUBKEY_ALIGN FD_HASH_ALIGN 14 : #define FD_SIGNATURE_ALIGN (8UL) 15 : 16 : /* TODO this should not have packed alignment, but it's misused everywhere */ 17 : 18 : union __attribute__((packed)) fd_hash { 19 : uchar hash[ FD_HASH_FOOTPRINT ]; 20 : uchar key [ FD_HASH_FOOTPRINT ]; // Making fd_hash and fd_pubkey interchangeable 21 : 22 : // Generic type specific accessors 23 : ulong ul [ FD_HASH_FOOTPRINT / sizeof(ulong) ]; 24 : uint ui [ FD_HASH_FOOTPRINT / sizeof(uint) ]; 25 : uchar uc [ FD_HASH_FOOTPRINT ]; 26 : }; 27 : 28 : typedef union fd_hash fd_hash_t; 29 : typedef union fd_hash fd_pubkey_t; 30 : 31 : FD_FN_PURE static inline int 32 : fd_hash_eq( fd_hash_t const * a, 33 0 : fd_hash_t const * b ) { 34 0 : return 0==memcmp( a, b, sizeof(fd_hash_t) ); 35 0 : } 36 : 37 : union fd_signature { 38 : uchar uc[ 64 ]; 39 : ulong ul[ 8 ]; 40 : }; 41 : 42 : typedef union fd_signature fd_signature_t; 43 : 44 : FD_PROTOTYPES_BEGIN 45 : 46 : #define fd_hash_check_zero(_x) (!((_x)->ul[0] | (_x)->ul[1] | (_x)->ul[2] | (_x)->ul[3])) 47 : #define fd_hash_set_zero(_x) {((_x)->ul[0] = 0); ((_x)->ul[1] = 0); ((_x)->ul[2] = 0); ((_x)->ul[3] = 0);} 48 : 49 30 : #define fd_pubkey_new fd_hash_new 50 972 : #define fd_pubkey_encode fd_hash_encode 51 : #define fd_pubkey_destroy fd_hash_destroy 52 6 : #define fd_pubkey_size fd_hash_size 53 : #define fd_pubkey_check_zero fd_hash_check_zero 54 : #define fd_pubkey_set_zero fd_hash_set_zero 55 273 : #define fd_pubkey_walk fd_hash_walk 56 489 : #define fd_pubkey_decode_inner fd_hash_decode_inner 57 : #define fd_pubkey_decode_footprint fd_hash_decode_footprint 58 72 : #define fd_pubkey_decode_footprint_inner fd_hash_decode_footprint_inner 59 : #define fd_pubkey_decode fd_hash_decode 60 0 : #define fd_pubkey_eq fd_hash_eq 61 : 62 : struct __attribute__((aligned(8UL))) fd_option_slot { 63 : uchar is_some; 64 : ulong slot; 65 : }; 66 : typedef struct fd_option_slot fd_option_slot_t; 67 : 68 : /* Index structure needed for transaction status (metadata) blocks */ 69 : struct fd_txnstatusidx { 70 : fd_ed25519_sig_t sig; 71 : ulong offset; 72 : ulong status_sz; 73 : }; 74 : typedef struct fd_txnstatusidx fd_txnstatusidx_t; 75 : 76 : /* IPv4 ***************************************************************/ 77 : 78 : typedef uint fd_gossip_ip4_addr_t; 79 : #define FD_GOSSIP_IP4_ADDR_ALIGN alignof(fd_gossip_ip4_addr_t) 80 : 81 : /* IPv6 ***************************************************************/ 82 : 83 : union fd_gossip_ip6_addr { 84 : uchar uc[ 16 ]; 85 : ushort us[ 8 ]; 86 : uint ul[ 4 ]; 87 : }; 88 : 89 : typedef union fd_gossip_ip6_addr fd_gossip_ip6_addr_t; 90 : #define FD_GOSSIP_IP6_ADDR_ALIGN alignof(fd_gossip_ip6_addr_t) 91 : 92 : int 93 : fd_solana_vote_account_decode_footprint( fd_bincode_decode_ctx_t * ctx, ulong * total_sz ); 94 : 95 : int 96 : fd_solana_vote_account_decode_footprint_inner( fd_bincode_decode_ctx_t * ctx, ulong * total_sz ); 97 : 98 : void * 99 : fd_solana_vote_account_decode( void * mem, fd_bincode_decode_ctx_t * ctx ); 100 : 101 : void 102 : fd_solana_vote_account_decode_inner( void * struct_mem, void * * alloc_mem, fd_bincode_decode_ctx_t * ctx ); 103 : 104 : /* Transaction wrapper ************************************************/ 105 : 106 : /* fd_flamenco_txn_t is yet another fd_txn_t wrapper. 107 : This should die as soon as we have a better stubs generator. */ 108 : 109 : struct fd_flamenco_txn { 110 : union { 111 : uchar txn_buf[ FD_TXN_MAX_SZ ]; 112 : __extension__ fd_txn_t txn[0]; 113 : }; 114 : uchar raw[ FD_TXN_MTU ]; 115 : ulong raw_sz; 116 : }; 117 : 118 : typedef struct fd_flamenco_txn fd_flamenco_txn_t; 119 : 120 : 121 : static inline void 122 3 : fd_flamenco_txn_new( fd_flamenco_txn_t * self FD_FN_UNUSED ) {} 123 : 124 : static inline void 125 0 : fd_flamenco_txn_destroy( fd_flamenco_txn_t const * self FD_FN_UNUSED ) {} 126 : 127 : FD_FN_CONST static inline ulong 128 0 : fd_flamenco_txn_size( fd_flamenco_txn_t const * self ) { 129 0 : return self->raw_sz; 130 0 : } 131 : 132 : static inline int 133 : fd_flamenco_txn_encode( fd_flamenco_txn_t const * self, 134 0 : fd_bincode_encode_ctx_t * ctx ) { 135 0 : return fd_bincode_bytes_encode( self->raw, self->raw_sz, ctx ); 136 0 : } 137 : 138 : 139 : int FD_FN_UNUSED 140 : fd_flamenco_txn_encode_global( fd_flamenco_txn_t const * self, 141 : fd_bincode_encode_ctx_t * ctx ); 142 : 143 : void * FD_FN_UNUSED 144 : fd_flamenco_txn_decode_global( void * mem, 145 : fd_bincode_decode_ctx_t * ctx ); 146 : 147 : static inline void 148 : fd_flamenco_txn_walk( void * w, 149 : fd_flamenco_txn_t const * self, 150 : fd_types_walk_fn_t fun, 151 : char const * name, 152 9 : uint level ) { 153 : 154 9 : static uchar const zero[ 64 ]={0}; 155 9 : fd_txn_t const * txn = self->txn; 156 9 : uchar const * sig0 = zero; 157 : 158 9 : if( FD_LIKELY( txn->signature_cnt > 0 ) ) 159 9 : sig0 = fd_txn_get_signatures( txn, self->raw )[0]; 160 : 161 : /* For now, just print the transaction's signature */ 162 9 : fun( w, sig0, name, FD_FLAMENCO_TYPE_SIG512, "txn", level ); 163 9 : } 164 : 165 : static inline ulong 166 6 : fd_flamenco_txn_align( void ) { 167 6 : return alignof(fd_flamenco_txn_t); 168 6 : } 169 : 170 : static inline ulong 171 0 : fd_flamenco_txn_footprint( void ) { 172 0 : return sizeof(fd_flamenco_txn_t); 173 0 : } 174 : 175 : int 176 : fd_flamenco_txn_decode_footprint( fd_bincode_decode_ctx_t * ctx, ulong * total_sz ); 177 : 178 : int 179 : fd_flamenco_txn_decode_footprint_inner( fd_bincode_decode_ctx_t * ctx, ulong * total_sz ); 180 : 181 : void * 182 : fd_flamenco_txn_decode( void * mem, fd_bincode_decode_ctx_t * ctx ); 183 : 184 : void 185 : fd_flamenco_txn_decode_inner( void * struct_mem, void * * alloc_mem, fd_bincode_decode_ctx_t * ctx ); 186 : 187 : /* Represents the lamport balance associated with an account. */ 188 : typedef ulong fd_acc_lamports_t; 189 : 190 : typedef struct fd_rust_duration fd_rust_duration_t; 191 : 192 : void 193 : fd_rust_duration_normalize ( fd_rust_duration_t * ); 194 : 195 : int 196 : fd_rust_duration_footprint_validator ( fd_bincode_decode_ctx_t * ctx ); 197 : 198 : int 199 : fd_gossip_duplicate_shred_validator ( fd_bincode_decode_ctx_t * ctx ); 200 : 201 : void fd_vote_accounts_decode_inner( void * struct_mem, void * * alloc_mem, fd_bincode_decode_ctx_t * ctx ); 202 : void fd_vote_accounts_decode_inner_global( void * struct_mem, void * * alloc_mem, fd_bincode_decode_ctx_t * ctx ); 203 : 204 : int fd_tower_sync_decode_footprint_inner( fd_bincode_decode_ctx_t * ctx, ulong * total_sz ); 205 : void fd_tower_sync_decode_inner( void * struct_mem, void * * alloc_mem, fd_bincode_decode_ctx_t * ctx ); 206 : 207 : FD_PROTOTYPES_END 208 : 209 : #endif /* HEADER_fd_src_flamenco_runtime_fd_types_custom */