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 : /* An opaque pointer to a Rust Arc<Bank> object, which should only 24 : be used with fd_ext_* functions to execute transactions or drop 25 : the bank. The ownership is complicated, but basically any bank 26 : tile that receives this frag has a strong refcnt to the bank and 27 : should release it when done, other tiles should ignore and never 28 : use the bank. */ 29 : void const * bank; 30 : 31 : /* In Firedancer, we just pass around the bank_idx which has already 32 : been refcounted by the replay tile, rather than a bank pointer. */ 33 : ulong bank_idx; 34 : 35 : /* The maximum number of microblocks that pack is allowed to put 36 : into the block. This allows PoH to accurately track and make sure 37 : microblocks do not need to be dropped. */ 38 : ulong max_microblocks_in_slot; 39 : 40 : /* The number of ticks (effectively empty microblocks) that the PoH 41 : tile will put in the block. This is used to adjust some pack 42 : limits. */ 43 : ulong ticks_per_slot; 44 : 45 : ulong tick_duration_ns; 46 : 47 : /* The number of ticks that the PoH tile has skipped, but needs to 48 : publish to show peers they were skipped correctly. This is used 49 : to adjust some pack limits. */ 50 : ulong total_skipped_ticks; 51 : 52 : /* The number of hashes per tick. This is used to update the 53 : parameter for the proof of history component in case it has 54 : changed. */ 55 : ulong hashcnt_per_tick; 56 : 57 : /* The epoch of the slot for which we are becoming leader. */ 58 : ulong epoch; 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 : struct fd_rooted_bank { 85 : void * bank; 86 : ulong slot; 87 : }; 88 : 89 : typedef struct fd_rooted_bank fd_rooted_bank_t; 90 : 91 : struct fd_completed_bank { 92 : ulong slot; 93 : uchar hash[32]; 94 : }; 95 : 96 : typedef struct fd_completed_bank fd_completed_bank_t; 97 : 98 : /* fd_txn_ns_dt contains nanosecond offsets for an executed solana 99 : transaction relative to the publish event by pack for its 100 : corresponding microblock. 101 : 102 : In Firedancer, these states align with the struct declaration order, 103 : but in Frankendancer the "check" phase happens before "load". */ 104 : struct __attribute__((packed)) fd_txn_ns_dt { 105 : float load_start; 106 : float check_start; 107 : float exec_start; 108 : float commit_start; 109 : float commit_end; 110 : }; 111 : 112 : typedef struct fd_txn_ns_dt fd_txn_ns_dt_t; 113 : 114 : struct fd_microblock_trailer { 115 : /* The hash of the transactions in the microblock, ready to be 116 : mixed into PoH. */ 117 : uchar hash[ 32UL ]; 118 : 119 : /* A sequentially increasing index of the first transaction in the 120 : microblock, across all slots ever processed by pack. This is used 121 : by monitoring tools that maintain an ordered history of 122 : transactions. */ 123 : ulong pack_txn_idx; 124 : 125 : /* The tips included in the transaction, in lamports. 0 for non-bundle 126 : transactions */ 127 : ulong tips; 128 : 129 : fd_txn_ns_dt_t txn_ns_dt; 130 : }; 131 : typedef struct fd_microblock_trailer fd_microblock_trailer_t; 132 : 133 : /* Sentinel sig values for messages on the pack_poh. Normal 134 : done_packing messages use fd_disco_execle_sig( slot, pack_idx ). */ 135 0 : #define FD_PACK_MSG_DONE_DRAINING (ULONG_MAX) 136 0 : #define FD_PACK_MSG_REDUCE_MB_BOUND (ULONG_MAX-1UL) 137 : 138 0 : #define FD_PACK_END_SLOT_REASON_TIME (1) 139 0 : #define FD_PACK_END_SLOT_REASON_MICROBLOCK (2) 140 0 : #define FD_PACK_END_SLOT_REASON_LEADER_SWITCH (3) 141 : 142 : struct fd_done_packing { 143 : ulong microblocks_in_slot; 144 : 145 : fd_pack_limits_usage_t limits_usage[ 1 ]; 146 : fd_pack_limits_t limits[ 1 ]; 147 : 148 : ulong block_results [ FD_METRICS_COUNTER_PACK_TXN_SCHEDULED_CNT ]; 149 : ulong end_block_results[ FD_METRICS_COUNTER_PACK_TXN_SCHEDULED_CNT ]; 150 : 151 : fd_pack_smallest_t pending_smallest[ 1 ]; 152 : fd_pack_smallest_t pending_votes_smallest[ 1 ]; 153 : 154 : int end_slot_reason; 155 : }; 156 : typedef struct fd_done_packing fd_done_packing_t; 157 : 158 : struct fd_microblock_execle_trailer { 159 : /* An opaque pointer to the bank to use when executing and committing 160 : transactions. The lifetime of the bank is owned by the PoH tile, 161 : which guarantees it is valid while pack or bank tiles might be 162 : using it. */ 163 : void const * bank; 164 : 165 : /* In full Firedancer we just pass an index of the bank in a pool of 166 : banks. The lifetime is fully managed by the replay tile, which has 167 : given us a refcount while we are leader for this bank. bank value 168 : above will be NULL. */ 169 : ulong bank_idx; 170 : 171 : /* The sequentially increasing index of the microblock, across all 172 : execles. This is used by PoH to ensure microblocks get committed 173 : in the same order they are executed. */ 174 : ulong microblock_idx; 175 : uint pack_idx; 176 : 177 : /* A sequentially increasing index of the first transaction in the 178 : microblock, across all slots ever processed by pack. This is used 179 : by monitoring tools that maintain an ordered history of 180 : transactions. */ 181 : ulong pack_txn_idx; 182 : 183 : /* If the microblock is a bundle, with a set of potentially 184 : conflicting transactions that should be executed in order, and 185 : all either commit or fail atomically. */ 186 : int is_bundle; 187 : }; 188 : typedef struct fd_microblock_execle_trailer fd_microblock_execle_trailer_t; 189 : 190 : #endif /* HEADER_fd_src_disco_tiles_h */