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 : } limits; 68 : 69 : /* Information from the accounts database as of the start of the slot 70 : determined by the bank above that is necessary to crank the bundle 71 : tip programs properly. If bundles are not enabled (determined 72 : externally, but the relevant tiles should know), these fields are 73 : set to 0. */ 74 : struct { 75 : fd_bundle_crank_tip_payment_config_t config[1]; 76 : uchar tip_receiver_owner[32]; 77 : uchar last_blockhash[32]; 78 : } bundle[1]; 79 : }; 80 : typedef struct fd_became_leader fd_became_leader_t; 81 : 82 : struct fd_rooted_bank { 83 : void * bank; 84 : ulong slot; 85 : }; 86 : 87 : typedef struct fd_rooted_bank fd_rooted_bank_t; 88 : 89 : struct fd_completed_bank { 90 : ulong slot; 91 : uchar hash[32]; 92 : }; 93 : 94 : typedef struct fd_completed_bank fd_completed_bank_t; 95 : 96 : struct fd_microblock_trailer { 97 : /* The hash of the transactions in the microblock, ready to be 98 : mixed into PoH. */ 99 : uchar hash[ 32UL ]; 100 : 101 : /* A sequentially increasing index of the first transaction in the 102 : microblock, across all slots ever processed by pack. This is used 103 : by monitoring tools that maintain an ordered history of 104 : transactions. */ 105 : ulong pack_txn_idx; 106 : 107 : /* The tips included in the transaction, in lamports. 0 for non-bundle 108 : transactions */ 109 : ulong tips; 110 : 111 : /* If the duration of a microblock is the difference between the 112 : publish timestamp of the microblock from pack and the publish 113 : timestamp of the microblock from execle, then these represent the 114 : elapsed time between the start of the microblock and the 3 state 115 : transitions (ready->start loading, loading -> execute, execute -> 116 : done) for the first transaction. 117 : 118 : For example, if a microblock starts at t=10 and ends at t=20, and 119 : txn_exec_end_pct is UCHAR_MAX / 2, then this transaction started 120 : executing at roughly 10+(20-10)*(128/UCHAR_MAX)=15 */ 121 : uchar txn_start_pct; 122 : uchar txn_load_end_pct; 123 : uchar txn_end_pct; 124 : uchar txn_preload_end_pct; 125 : 126 : }; 127 : typedef struct fd_microblock_trailer fd_microblock_trailer_t; 128 : 129 : /* Sentinel sig values for messages on the pack_poh. Normal 130 : done_packing messages use fd_disco_execle_sig( slot, pack_idx ). */ 131 0 : #define FD_PACK_MSG_DONE_DRAINING (ULONG_MAX) 132 0 : #define FD_PACK_MSG_REDUCE_MB_BOUND (ULONG_MAX-1UL) 133 : 134 0 : #define FD_PACK_END_SLOT_REASON_TIME (1) 135 0 : #define FD_PACK_END_SLOT_REASON_MICROBLOCK (2) 136 0 : #define FD_PACK_END_SLOT_REASON_LEADER_SWITCH (3) 137 : 138 : struct fd_done_packing { 139 : ulong microblocks_in_slot; 140 : 141 : fd_pack_limits_usage_t limits_usage[ 1 ]; 142 : fd_pack_limits_t limits[ 1 ]; 143 : 144 : ulong block_results [ FD_METRICS_COUNTER_PACK_TRANSACTION_SCHEDULE_CNT ]; 145 : ulong end_block_results[ FD_METRICS_COUNTER_PACK_TRANSACTION_SCHEDULE_CNT ]; 146 : 147 : fd_pack_smallest_t pending_smallest[ 1 ]; 148 : fd_pack_smallest_t pending_votes_smallest[ 1 ]; 149 : 150 : int end_slot_reason; 151 : }; 152 : typedef struct fd_done_packing fd_done_packing_t; 153 : 154 : struct fd_microblock_execle_trailer { 155 : /* An opaque pointer to the bank to use when executing and committing 156 : transactions. The lifetime of the bank is owned by the PoH tile, 157 : which guarantees it is valid while pack or bank tiles might be 158 : using it. */ 159 : void const * bank; 160 : 161 : /* In full Firedancer we just pass an index of the bank in a pool of 162 : banks. The lifetime is fully managed by the replay tile, which has 163 : given us a refcount while we are leader for this bank. bank value 164 : above will be NULL. */ 165 : ulong bank_idx; 166 : 167 : /* The sequentially increasing index of the microblock, across all 168 : execles. This is used by PoH to ensure microblocks get committed 169 : in the same order they are executed. */ 170 : ulong microblock_idx; 171 : uint pack_idx; 172 : 173 : /* A sequentially increasing index of the first transaction in the 174 : microblock, across all slots ever processed by pack. This is used 175 : by monitoring tools that maintain an ordered history of 176 : transactions. */ 177 : ulong pack_txn_idx; 178 : 179 : /* If the microblock is a bundle, with a set of potentially 180 : conflicting transactions that should be executed in order, and 181 : all either commit or fail atomically. */ 182 : int is_bundle; 183 : }; 184 : typedef struct fd_microblock_execle_trailer fd_microblock_execle_trailer_t; 185 : 186 : typedef struct __attribute__((packed)) { 187 : ulong tick_duration_ns; 188 : ulong hashcnt_per_tick; 189 : ulong ticks_per_slot; 190 : ulong tick_height; 191 : uchar last_entry_hash[32]; 192 : } fd_poh_init_msg_t; 193 : 194 : #endif /* HEADER_fd_src_disco_tiles_h */