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 : struct fd_became_leader { 16 : ulong slot; 17 : 18 : /* Start and end time of the slot in nanoseconds (from 19 : fd_log_wallclock()). */ 20 : long slot_start_ns; 21 : long slot_end_ns; 22 : 23 : /* The bank_idx of the leader bank, which has already been 24 : refcounted by the replay tile. */ 25 : ulong bank_idx; 26 : 27 : /* The app-wide bank sequence number of the leader bank (the durable 28 : fork discriminator; bank_idx is reused, bank_seq is not). Used by 29 : monitoring (the GUI) to key per-fork transaction history. */ 30 : ulong bank_seq; 31 : 32 : /* The maximum number of microblocks that pack is allowed to put 33 : into the block. This allows PoH to accurately track and make sure 34 : microblocks do not need to be dropped. */ 35 : ulong max_microblocks_in_slot; 36 : 37 : /* The number of ticks (effectively empty microblocks) that the PoH 38 : tile will put in the block. This is used to adjust some pack 39 : limits. */ 40 : ulong ticks_per_slot; 41 : 42 : ulong tick_duration_ns; 43 : 44 : /* The number of ticks that the PoH tile has skipped, but needs to 45 : publish to show peers they were skipped correctly. This is used 46 : to adjust some pack limits. */ 47 : ulong total_skipped_ticks; 48 : 49 : /* The number of hashes per tick. This is used to update the 50 : parameter for the proof of history component in case it has 51 : changed. */ 52 : ulong hashcnt_per_tick; 53 : 54 : /* The epoch of the slot for which we are becoming leader. */ 55 : ulong epoch; 56 : 57 : /* The block height of the slot for which we are becoming leader. */ 58 : ulong block_height; 59 : 60 : /* Consensus-critical cost limits for the slot we are becoming leader. 61 : These are typically unchanging, but may change after a feature 62 : activation. */ 63 : struct { 64 : ulong slot_max_cost; 65 : ulong slot_max_vote_cost; 66 : ulong slot_max_write_cost_per_acct; 67 : ulong slot_max_allocated_data_per_block; 68 : ulong slot_max_data_shreds; 69 : } limits; 70 : 71 : /* Information from the accounts database as of the start of the slot 72 : determined by the bank above that is necessary to crank the bundle 73 : tip programs properly. If bundles are not enabled (determined 74 : externally, but the relevant tiles should know), these fields are 75 : set to 0. */ 76 : struct { 77 : fd_bundle_crank_tip_payment_config_t config[1]; 78 : uchar tip_receiver_owner[32]; 79 : uchar last_blockhash[32]; 80 : } bundle[1]; 81 : }; 82 : typedef struct fd_became_leader fd_became_leader_t; 83 : 84 : /* fd_txn_ns_dt contains nanosecond offsets for an executed solana 85 : transaction relative to the publish event by pack for its 86 : corresponding microblock. These states align with the struct 87 : declaration order. */ 88 : struct __attribute__((packed)) fd_txn_ns_dt { 89 : float load_start; 90 : float check_start; 91 : float exec_start; 92 : float commit_start; 93 : float commit_end; 94 : }; 95 : 96 : typedef struct fd_txn_ns_dt fd_txn_ns_dt_t; 97 : 98 : struct fd_microblock_trailer { 99 : /* The hash of the transactions in the microblock, ready to be 100 : mixed into PoH. */ 101 : uchar hash[ 32UL ]; 102 : 103 : /* A sequentially increasing index of the first transaction in the 104 : microblock, across all slots ever processed by pack. This is used 105 : by monitoring tools that maintain an ordered history of 106 : transactions. */ 107 : ulong pack_txn_idx; 108 : 109 : /* The tips included in the transaction, in lamports. 0 for non-bundle 110 : transactions */ 111 : ulong tips; 112 : 113 : /* The app-wide bank sequence number of the bank this microblock was 114 : executed against (the durable fork discriminator). Used by 115 : monitoring (the GUI) to key per-fork transaction history. */ 116 : ulong bank_seq; 117 : 118 : fd_txn_ns_dt_t txn_ns_dt; 119 : 120 : /* When the exec tile began executing this microblock (for a bundle, 121 : the bundle start) and when its transaction finished committing 122 : (LONG_MAX if nothing committed). */ 123 : long exec_start_ticks; 124 : long exec_end_ticks; 125 : }; 126 : typedef struct fd_microblock_trailer fd_microblock_trailer_t; 127 : 128 : /* Sentinel sig values for messages on the pack_poh. Normal 129 : done_packing messages use fd_disco_execle_sig( slot, pack_idx ). */ 130 0 : #define FD_PACK_MSG_DONE_DRAINING (ULONG_MAX) 131 0 : #define FD_PACK_MSG_REDUCE_MB_BOUND (ULONG_MAX-1UL) 132 : 133 0 : #define FD_PACK_END_SLOT_REASON_TIME (1) 134 0 : #define FD_PACK_END_SLOT_REASON_MICROBLOCK (2) 135 0 : #define FD_PACK_END_SLOT_REASON_ABANDONED (3) 136 : 137 : struct fd_done_packing { 138 : ulong microblocks_in_slot; 139 : 140 : fd_pack_limits_usage_t limits_usage[ 1 ]; 141 : fd_pack_limits_t limits[ 1 ]; 142 : 143 : ulong block_results [ FD_METRICS_COUNTER_PACK_TXN_SCHEDULE_ATTEMPTED_CNT ]; 144 : ulong end_block_results[ FD_METRICS_COUNTER_PACK_TXN_SCHEDULE_ATTEMPTED_CNT ]; 145 : 146 : fd_pack_smallest_t pending_smallest[ 1 ]; 147 : fd_pack_smallest_t pending_votes_smallest[ 1 ]; 148 : 149 : int end_slot_reason; 150 : 151 : long pack_start_ns; 152 : long pack_end_ns; 153 : ulong bundle_txn_count; 154 : }; 155 : typedef struct fd_done_packing fd_done_packing_t; 156 : 157 : struct fd_microblock_execle_trailer { 158 : /* The index of the bank in a pool of banks. The lifetime is fully 159 : managed by the replay tile, which has given us a refcount while we 160 : are leader for this bank. */ 161 : ulong bank_idx; 162 : 163 : /* The app-wide bank sequence number of the leader bank (the durable 164 : fork discriminator; bank_idx is reused, bank_seq is not). Used by 165 : monitoring (the GUI) to key per-fork transaction history. */ 166 : ulong bank_seq; 167 : 168 : /* The sequentially increasing index of the microblock, across all 169 : execles. This is used by PoH to ensure microblocks get committed 170 : in the same order they are executed. */ 171 : ulong microblock_idx; 172 : uint pack_idx; 173 : 174 : /* A sequentially increasing index of the first transaction in the 175 : microblock, across all slots ever processed by pack. This is used 176 : by monitoring tools that maintain an ordered history of 177 : transactions. */ 178 : ulong pack_txn_idx; 179 : 180 : /* If the microblock is a bundle, with a set of potentially 181 : conflicting transactions that should be executed in order, and 182 : all either commit or fail atomically. */ 183 : int is_bundle; 184 : }; 185 : typedef struct fd_microblock_execle_trailer fd_microblock_execle_trailer_t; 186 : 187 : /* Exact worst-case frag sizes for the pack_execle and execle_poh 188 : links. execle strips the ALT accounts from each fd_txn_e_t before 189 : forwarding to poh, so the poh side is smaller. */ 190 0 : #define FD_PACK_EXECLE_MTU (MAX_TXN_PER_MICROBLOCK*sizeof(fd_txn_e_t)+sizeof(fd_microblock_execle_trailer_t)) 191 0 : #define FD_EXECLE_POH_MTU (MAX_TXN_PER_MICROBLOCK*sizeof(fd_txn_p_t)+sizeof(fd_microblock_trailer_t)) 192 : 193 : #endif /* HEADER_fd_src_disco_tiles_h */