Line data Source code
1 : #ifndef HEADER_fd_src_app_fdctl_run_tiles_h 2 : #define HEADER_fd_src_app_fdctl_run_tiles_h 3 : 4 : #include "stem/fd_stem.h" 5 : #include "shred/fd_shredder.h" 6 : #include "../ballet/shred/fd_shred.h" 7 : #include "../ballet/pack/fd_pack.h" 8 : #include "topo/fd_topo.h" 9 : 10 : #include <linux/filter.h> 11 : 12 : /* fd_shred34 is a collection of up to 34 shreds batched in a way that's 13 : convenient for use in a dcache and for access from Rust. The limit of 14 : 34 comes so that sizeof( fd_shred34_t ) < USHORT_MAX. */ 15 : 16 : struct __attribute__((aligned(FD_CHUNK_ALIGN))) fd_shred34 { 17 : ulong shred_cnt; 18 : 19 : /* est_txn_cnt: An estimate of the number of transactions contained in this 20 : shred34_t. The true value might not be a whole number, but this is 21 : helpful for diagnostic purposes. */ 22 : ulong est_txn_cnt; 23 : ulong stride; 24 : ulong offset; 25 : ulong shred_sz; /* The size of each shred */ 26 : /* For i in [0, shred_cnt), shred i's payload spans bytes 27 : [i*stride+offset, i*stride+offset+shred_sz ), counting from the 28 : start of the struct, not this point. */ 29 : union { 30 : fd_shred_t shred; 31 : uchar buffer[ FD_SHRED_MAX_SZ ]; 32 : } pkts[ 34 ]; 33 : }; 34 : typedef struct fd_shred34 fd_shred34_t; 35 : 36 : struct fd_became_leader { 37 : /* Start and end time of the slot in nanoseconds (from 38 : fd_log_wallclock()). */ 39 : long slot_start_ns; 40 : long slot_end_ns; 41 : 42 : /* An opaque pointer to a Rust Arc<Bank> object, which should only 43 : be used with fd_ext_* functions to execute transactions or drop 44 : the bank. The ownership is complicated, but basically any bank 45 : tile that receives this frag has a strong refcnt to the bank and 46 : should release it when done, other tiles should ignore and never 47 : use the bank. */ 48 : void const * bank; 49 : 50 : /* The maximum number of microblocks that pack is allowed to put 51 : into the block. This allows PoH to accurately track and make sure 52 : microblocks do not need to be dropped. */ 53 : ulong max_microblocks_in_slot; 54 : 55 : /* The number of ticks (effectively empty microblocks) that the PoH 56 : tile will put in the block. This is used to adjust some pack 57 : limits. */ 58 : ulong ticks_per_slot; 59 : 60 : /* The number of ticks that the PoH tile has skipped, but needs to 61 : publish to show peers they were skipped correctly. This is used 62 : to adjust some pack limits. */ 63 : ulong total_skipped_ticks; 64 : }; 65 : typedef struct fd_became_leader fd_became_leader_t; 66 : 67 : struct fd_rooted_bank { 68 : void * bank; 69 : ulong slot; 70 : }; 71 : 72 : typedef struct fd_rooted_bank fd_rooted_bank_t; 73 : 74 : struct fd_completed_bank { 75 : ulong slot; 76 : uchar hash[32]; 77 : }; 78 : 79 : typedef struct fd_completed_bank fd_completed_bank_t; 80 : 81 : struct fd_microblock_trailer { 82 : /* The hash of the transactions in the microblock, ready to be 83 : mixed into PoH. */ 84 : uchar hash[ 32UL ]; 85 : }; 86 : typedef struct fd_microblock_trailer fd_microblock_trailer_t; 87 : 88 : struct fd_done_packing { 89 : ulong microblocks_in_slot; 90 : }; 91 : typedef struct fd_done_packing fd_done_packing_t; 92 : 93 : struct fd_microblock_bank_trailer { 94 : /* An opaque pointer to the bank to use when executing and committing 95 : transactions. The lifetime of the bank is owned by the PoH tile, 96 : which guarantees it is valid while pack or bank tiles might be 97 : using it. */ 98 : void const * bank; 99 : 100 : /* The sequentially increasing index of the microblock, across all 101 : banks. This is used by PoH to ensure microblocks get committed 102 : in the same order they are executed. */ 103 : ulong microblock_idx; 104 : }; 105 : typedef struct fd_microblock_bank_trailer fd_microblock_bank_trailer_t; 106 : 107 : typedef struct __attribute__((packed)) { 108 : ulong tick_duration_ns; 109 : ulong hashcnt_per_tick; 110 : ulong ticks_per_slot; 111 : ulong tick_height; 112 : uchar last_entry_hash[32]; 113 : } fd_poh_init_msg_t; 114 : 115 : /* A fd_txn_m_t is a parsed meta transaction, containing not just the 116 : payload */ 117 : 118 : struct fd_txn_m { 119 : /* The computed slot that this transaction is referencing, aka. the 120 : slot number of the reference_blockhash. If it could not be 121 : determined, this will be the current slot. */ 122 : ulong reference_slot; 123 : 124 : ushort payload_sz; 125 : 126 : /* Can be computed from the txn_t but it's expensive to parse again, 127 : so we just store this redundantly. */ 128 : ushort txn_t_sz; 129 : 130 : /* There are three additional fields at the end here, which are 131 : variable length and not included in the size of this struct. 132 : uchar payload[ ] 133 : fd_txn_t txn_t[ ] 134 : fd_acct_addr_t alut[ ] */ 135 : }; 136 : 137 : typedef struct fd_txn_m fd_txn_m_t; 138 : 139 : static FD_FN_CONST inline ulong 140 0 : fd_txn_m_align( void ) { 141 0 : return alignof( fd_txn_m_t ); 142 0 : } 143 : 144 : static inline ulong 145 : fd_txn_m_footprint( ulong payload_sz, 146 : ulong instr_cnt, 147 : ulong addr_table_lookup_cnt, 148 0 : ulong addr_table_adtl_cnt ) { 149 0 : ulong l = FD_LAYOUT_INIT; 150 0 : l = FD_LAYOUT_APPEND( l, alignof(fd_txn_m_t), sizeof(fd_txn_m_t) ); 151 0 : l = FD_LAYOUT_APPEND( l, 1UL, payload_sz ); 152 0 : l = FD_LAYOUT_APPEND( l, fd_txn_align(), fd_txn_footprint( instr_cnt, addr_table_lookup_cnt ) ); 153 0 : l = FD_LAYOUT_APPEND( l, alignof(fd_acct_addr_t), addr_table_adtl_cnt*sizeof(fd_acct_addr_t) ); 154 0 : return FD_LAYOUT_FINI( l, fd_txn_m_align() ); 155 0 : } 156 : 157 : static inline uchar * 158 0 : fd_txn_m_payload( fd_txn_m_t * txnm ) { 159 0 : return (uchar *)(txnm+1UL); 160 0 : } 161 : 162 : static inline fd_txn_t * 163 0 : fd_txn_m_txn_t( fd_txn_m_t * txnm ) { 164 0 : return (fd_txn_t *)fd_ulong_align_up( (ulong)(txnm+1UL) + txnm->payload_sz, alignof( fd_txn_t ) ); 165 0 : } 166 : 167 : static inline fd_txn_t const * 168 0 : fd_txn_m_txn_t_const( fd_txn_m_t const * txnm ) { 169 0 : return (fd_txn_t const *)fd_ulong_align_up( (ulong)(txnm+1UL) + txnm->payload_sz, alignof( fd_txn_t ) ); 170 0 : } 171 : 172 : static inline fd_acct_addr_t * 173 0 : fd_txn_m_alut( fd_txn_m_t * txnm ) { 174 0 : return (fd_acct_addr_t *)fd_ulong_align_up( fd_ulong_align_up( (ulong)(txnm+1UL) + txnm->payload_sz, alignof( fd_txn_t ) )+txnm->txn_t_sz, alignof( fd_acct_addr_t ) ); 175 0 : } 176 : 177 : static inline ulong 178 : fd_txn_m_realized_footprint( fd_txn_m_t const * txnm, 179 0 : int include_alut ) { 180 0 : return fd_txn_m_footprint( txnm->payload_sz, 181 0 : fd_txn_m_txn_t_const( txnm )->instr_cnt, 182 0 : fd_txn_m_txn_t_const( txnm )->addr_table_lookup_cnt, 183 0 : include_alut ? fd_txn_m_txn_t_const( txnm )->addr_table_adtl_cnt : 0UL ); 184 0 : } 185 : 186 21 : #define FD_TPU_PARSED_MTU FD_ULONG_ALIGN_UP( \ 187 21 : FD_ULONG_ALIGN_UP( \ 188 21 : sizeof(fd_txn_m_t)+FD_TPU_MTU, \ 189 21 : alignof(fd_txn_t) ) \ 190 21 : +FD_TXN_MAX_SZ, \ 191 21 : alignof(fd_txn_m_t) ) 192 : 193 3 : #define FD_TPU_RESOLVED_MTU FD_ULONG_ALIGN_UP( \ 194 3 : FD_ULONG_ALIGN_UP( \ 195 3 : FD_ULONG_ALIGN_UP( \ 196 3 : sizeof(fd_txn_m_t)+FD_TPU_MTU, \ 197 3 : alignof(fd_txn_t) ) \ 198 3 : +FD_TXN_MAX_SZ, \ 199 3 : alignof(fd_acct_addr_t) ) \ 200 3 : +256UL*sizeof(fd_acct_addr_t), \ 201 3 : alignof(fd_txn_m_t) ) 202 : 203 : #endif /* HEADER_fd_src_app_fdctl_run_tiles_h */