Line data Source code
1 : #ifndef HEADER_fd_src_disco_tiles_h 2 : #define HEADER_fd_src_disco_tiles_h 3 : 4 : #include "stem/fd_stem.h" 5 : #include "shred/fd_shredder.h" 6 : #include "../ballet/shred/fd_shred.h" 7 : #include "../flamenco/leaders/fd_leaders_base.h" 8 : #include "pack/fd_pack.h" 9 : #include "topo/fd_topo.h" 10 : #include "bundle/fd_bundle_crank.h" 11 : #include "../disco/metrics/generated/fd_metrics_pack.h" 12 : 13 : #include <linux/filter.h> 14 : 15 : /* fd_shred34 is a collection of up to 34 shreds batched in a way that's 16 : convenient for use in a dcache and for access from Rust. The limit of 17 : 34 comes so that sizeof( fd_shred34_t ) < USHORT_MAX. */ 18 : 19 : struct __attribute__((aligned(FD_CHUNK_ALIGN))) fd_shred34 { 20 : ulong shred_cnt; 21 : 22 : /* est_txn_cnt: An estimate of the number of transactions contained in this 23 : shred34_t. The true value might not be a whole number, but this is 24 : helpful for diagnostic purposes. */ 25 : ulong est_txn_cnt; 26 : ulong stride; 27 : ulong offset; 28 : ulong shred_sz; /* The size of each shred */ 29 : /* For i in [0, shred_cnt), shred i's payload spans bytes 30 : [i*stride+offset, i*stride+offset+shred_sz ), counting from the 31 : start of the struct, not this point. */ 32 : union { 33 : fd_shred_t shred; 34 : uchar buffer[ FD_SHRED_MAX_SZ ]; 35 : } pkts[ 34 ]; 36 : }; 37 : typedef struct fd_shred34 fd_shred34_t; 38 : 39 : struct fd_became_leader { 40 : ulong slot; 41 : 42 : /* Start and end time of the slot in nanoseconds (from 43 : fd_log_wallclock()). */ 44 : long slot_start_ns; 45 : long slot_end_ns; 46 : 47 : /* An opaque pointer to a Rust Arc<Bank> object, which should only 48 : be used with fd_ext_* functions to execute transactions or drop 49 : the bank. The ownership is complicated, but basically any bank 50 : tile that receives this frag has a strong refcnt to the bank and 51 : should release it when done, other tiles should ignore and never 52 : use the bank. */ 53 : void const * bank; 54 : 55 : /* In Firedancer, we just pass around the bank_idx which has already 56 : been refcounted by the replay tile, rather than a bank pointer. */ 57 : ulong bank_idx; 58 : 59 : /* The maximum number of microblocks that pack is allowed to put 60 : into the block. This allows PoH to accurately track and make sure 61 : microblocks do not need to be dropped. */ 62 : ulong max_microblocks_in_slot; 63 : 64 : /* The number of ticks (effectively empty microblocks) that the PoH 65 : tile will put in the block. This is used to adjust some pack 66 : limits. */ 67 : ulong ticks_per_slot; 68 : 69 : ulong tick_duration_ns; 70 : 71 : /* The number of ticks that the PoH tile has skipped, but needs to 72 : publish to show peers they were skipped correctly. This is used 73 : to adjust some pack limits. */ 74 : ulong total_skipped_ticks; 75 : 76 : /* The number of hashes per tick. This is used to update the 77 : parameter for the proof of history component in case it has 78 : changed. */ 79 : ulong hashcnt_per_tick; 80 : 81 : /* The epoch of the slot for which we are becoming leader. */ 82 : ulong epoch; 83 : 84 : /* Consensus-critical cost limits for the slot we are becoming leader. 85 : These are typically unchanging, but may change after a feature 86 : activation. */ 87 : struct { 88 : ulong slot_max_cost; 89 : ulong slot_max_vote_cost; 90 : ulong slot_max_write_cost_per_acct; 91 : } limits; 92 : 93 : /* Information from the accounts database as of the start of the slot 94 : determined by the bank above that is necessary to crank the bundle 95 : tip programs properly. If bundles are not enabled (determined 96 : externally, but the relevant tiles should know), these fields are 97 : set to 0. */ 98 : struct { 99 : fd_bundle_crank_tip_payment_config_t config[1]; 100 : uchar tip_receiver_owner[32]; 101 : uchar last_blockhash[32]; 102 : } bundle[1]; 103 : }; 104 : typedef struct fd_became_leader fd_became_leader_t; 105 : 106 : struct fd_rooted_bank { 107 : void * bank; 108 : ulong slot; 109 : }; 110 : 111 : typedef struct fd_rooted_bank fd_rooted_bank_t; 112 : 113 : struct fd_completed_bank { 114 : ulong slot; 115 : uchar hash[32]; 116 : }; 117 : 118 : typedef struct fd_completed_bank fd_completed_bank_t; 119 : 120 : struct fd_microblock_trailer { 121 : /* The hash of the transactions in the microblock, ready to be 122 : mixed into PoH. */ 123 : uchar hash[ 32UL ]; 124 : 125 : /* A sequentially increasing index of the first transaction in the 126 : microblock, across all slots ever processed by pack. This is used 127 : by monitoring tools that maintain an ordered history of 128 : transactions. */ 129 : ulong pack_txn_idx; 130 : 131 : /* The tips included in the transaction, in lamports. 0 for non-bundle 132 : transactions */ 133 : ulong tips; 134 : 135 : /* If the duration of a microblock is the difference between the 136 : publish timestamp of the microblock from pack and the publish 137 : timestamp of the microblock from bank, then these represent the 138 : elapsed time between the start of the microblock and the 3 state 139 : transitions (ready->start loading, loading -> execute, execute -> 140 : done) for the first transaction. 141 : 142 : For example, if a microblock starts at t=10 and ends at t=20, and 143 : txn_exec_end_pct is UCHAR_MAX / 2, then this transaction started 144 : executing at roughly 10+(20-10)*(128/UCHAR_MAX)=15 */ 145 : uchar txn_start_pct; 146 : uchar txn_load_end_pct; 147 : uchar txn_end_pct; 148 : uchar txn_preload_end_pct; 149 : }; 150 : typedef struct fd_microblock_trailer fd_microblock_trailer_t; 151 : 152 0 : #define FD_PACK_END_SLOT_REASON_TIME (1) 153 0 : #define FD_PACK_END_SLOT_REASON_MICROBLOCK (2) 154 0 : #define FD_PACK_END_SLOT_REASON_LEADER_SWITCH (3) 155 : 156 : struct fd_done_packing { 157 : ulong microblocks_in_slot; 158 : 159 : fd_pack_limits_usage_t limits_usage[ 1 ]; 160 : fd_pack_limits_t limits[ 1 ]; 161 : 162 : ulong block_results [ FD_METRICS_COUNTER_PACK_TRANSACTION_SCHEDULE_CNT ]; 163 : ulong end_block_results[ FD_METRICS_COUNTER_PACK_TRANSACTION_SCHEDULE_CNT ]; 164 : 165 : fd_pack_smallest_t pending_smallest[ 1 ]; 166 : fd_pack_smallest_t pending_votes_smallest[ 1 ]; 167 : 168 : int end_slot_reason; 169 : }; 170 : typedef struct fd_done_packing fd_done_packing_t; 171 : 172 : struct fd_microblock_bank_trailer { 173 : /* An opaque pointer to the bank to use when executing and committing 174 : transactions. The lifetime of the bank is owned by the PoH tile, 175 : which guarantees it is valid while pack or bank tiles might be 176 : using it. */ 177 : void const * bank; 178 : 179 : /* In full Firedancer we just pass an index of the bank in a pool of 180 : banks. The lifetime is fully managed by the replay tile, which has 181 : given us a refcount while we are leader for this bank. bank value 182 : above will be NULL. */ 183 : ulong bank_idx; 184 : 185 : /* The sequentially increasing index of the microblock, across all 186 : banks. This is used by PoH to ensure microblocks get committed 187 : in the same order they are executed. */ 188 : ulong microblock_idx; 189 : uint pack_idx; 190 : 191 : /* A sequentially increasing index of the first transaction in the 192 : microblock, across all slots ever processed by pack. This is used 193 : by monitoring tools that maintain an ordered history of 194 : transactions. */ 195 : ulong pack_txn_idx; 196 : 197 : /* If the microblock is a bundle, with a set of potentially 198 : conflicting transactions that should be executed in order, and 199 : all either commit or fail atomically. */ 200 : int is_bundle; 201 : }; 202 : typedef struct fd_microblock_bank_trailer fd_microblock_bank_trailer_t; 203 : 204 : typedef struct __attribute__((packed)) { 205 : ulong tick_duration_ns; 206 : ulong hashcnt_per_tick; 207 : ulong ticks_per_slot; 208 : ulong tick_height; 209 : uchar last_entry_hash[32]; 210 : } fd_poh_init_msg_t; 211 : 212 : #endif /* HEADER_fd_src_disco_tiles_h */