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 : typedef struct fd_microblock_trailer fd_microblock_trailer_t; 127 : 128 0 : #define FD_PACK_END_SLOT_REASON_TIME (1) 129 0 : #define FD_PACK_END_SLOT_REASON_MICROBLOCK (2) 130 0 : #define FD_PACK_END_SLOT_REASON_LEADER_SWITCH (3) 131 : 132 : struct fd_done_packing { 133 : ulong microblocks_in_slot; 134 : 135 : fd_pack_limits_usage_t limits_usage[ 1 ]; 136 : fd_pack_limits_t limits[ 1 ]; 137 : 138 : ulong block_results [ FD_METRICS_COUNTER_PACK_TRANSACTION_SCHEDULE_CNT ]; 139 : ulong end_block_results[ FD_METRICS_COUNTER_PACK_TRANSACTION_SCHEDULE_CNT ]; 140 : 141 : fd_pack_smallest_t pending_smallest[ 1 ]; 142 : fd_pack_smallest_t pending_votes_smallest[ 1 ]; 143 : 144 : int end_slot_reason; 145 : }; 146 : typedef struct fd_done_packing fd_done_packing_t; 147 : 148 : struct fd_microblock_execle_trailer { 149 : /* An opaque pointer to the bank to use when executing and committing 150 : transactions. The lifetime of the bank is owned by the PoH tile, 151 : which guarantees it is valid while pack or bank tiles might be 152 : using it. */ 153 : void const * bank; 154 : 155 : /* In full Firedancer we just pass an index of the bank in a pool of 156 : banks. The lifetime is fully managed by the replay tile, which has 157 : given us a refcount while we are leader for this bank. bank value 158 : above will be NULL. */ 159 : ulong bank_idx; 160 : 161 : /* The sequentially increasing index of the microblock, across all 162 : execles. This is used by PoH to ensure microblocks get committed 163 : in the same order they are executed. */ 164 : ulong microblock_idx; 165 : uint pack_idx; 166 : 167 : /* A sequentially increasing index of the first transaction in the 168 : microblock, across all slots ever processed by pack. This is used 169 : by monitoring tools that maintain an ordered history of 170 : transactions. */ 171 : ulong pack_txn_idx; 172 : 173 : /* If the microblock is a bundle, with a set of potentially 174 : conflicting transactions that should be executed in order, and 175 : all either commit or fail atomically. */ 176 : int is_bundle; 177 : }; 178 : typedef struct fd_microblock_execle_trailer fd_microblock_execle_trailer_t; 179 : 180 : typedef struct __attribute__((packed)) { 181 : ulong tick_duration_ns; 182 : ulong hashcnt_per_tick; 183 : ulong ticks_per_slot; 184 : ulong tick_height; 185 : uchar last_entry_hash[32]; 186 : } fd_poh_init_msg_t; 187 : 188 : #endif /* HEADER_fd_src_disco_tiles_h */