Line data Source code
1 : #ifndef HEADER_fd_src_ballet_pack_fd_microblock_h 2 : #define HEADER_fd_src_ballet_pack_fd_microblock_h 3 : 4 : #include "../txn/fd_txn.h" 5 : 6 : /* in bytes. Defined this way to use the size field of mcache. This 7 : only includes the transaction payload and the fd_txn_t portions of 8 : the microblock, as all the other portions (hash, etc) are generated 9 : by PoH later. */ 10 819723 : #define MAX_MICROBLOCK_SZ USHORT_MAX 11 : 12 : struct fd_entry_batch_meta { 13 : /* How many skipped slots we are building on top of. If there were no 14 : skipped slots, (aka: this is slot 10, and the reset slot is slot 9, 15 : then the value should be 1). */ 16 : ulong parent_offset; 17 : 18 : /* Tick in the slot indexed from [0, ticks_per_slot]. For ticks, 19 : which are sent ever 12,500 hashes, this will be 1 for the first 20 : tick, then 2, ... up to and including tick 64 for the last one. 21 : 22 : For microblocks, it will be 0 for microblocks that are sent before 23 : the first tick, etc, up to and including 63. The range of allowed 24 : reference ticks is thus [0, 64], but can only be 0 for a microblock 25 : and can only be 64 for the last tick (when block_complete is true). */ 26 : ulong reference_tick; 27 : 28 : /* Whether this is the last microblock in the slot or not. The last 29 : microblock will always be an empty tick with no transactions in 30 : it. */ 31 : int block_complete; 32 : }; 33 : typedef struct fd_entry_batch_meta fd_entry_batch_meta_t; 34 : 35 : struct fd_entry_batch_header { 36 : /* Number of hashes since the last entry batch that was published, 37 : in (0, hashes_per_tick]. Will be hashes_per_tick if and only 38 : if there were no microblocks sent between two empty ticks of the 39 : PoH. */ 40 : ulong hashcnt_delta; 41 : 42 : /* The proof of history stamped hash of the entry batch. */ 43 : uchar hash[32UL]; 44 : 45 : /* Number of hashes in the entry batch. Will be 0 for a tick, 46 : and (0, MAX_TXN_PER_MICROBLOCK] for a microblock. */ 47 : ulong txn_cnt; 48 : }; 49 : typedef struct fd_entry_batch_header fd_entry_batch_header_t; 50 : 51 : struct __attribute__((aligned(64))) fd_txn_p { 52 : uchar payload[FD_TPU_MTU]; 53 : ulong payload_sz; 54 : union { 55 : struct { 56 : uint non_execution_cus; 57 : uint requested_execution_cus; 58 : } pack_cu; /* Populated by pack. Bank reads these to populate the other struct of the union. */ 59 : struct { 60 : uint rebated_cus; /* requested_execution_cus-real execution CUs. Pack reads this for CU rebating. */ 61 : uint actual_consumed_cus; /* non_execution_cus+real execution CUs. PoH reads this for block CU counting. */ 62 : } bank_cu; /* Populated by bank. */ 63 : ulong blockhash_slot; /* Slot provided by resolv tile when txn arrives at the pack tile. Used when txn is in extra storage in pack. */ 64 : }; 65 : uint flags; /* Populated by pack, bank. A combination of the bitfields FD_TXN_P_FLAGS_* defined above */ 66 : /* union { 67 : This would be ideal but doesn't work because of the flexible array member 68 : uchar _[FD_TXN_MAX_SZ]; 69 : fd_txn_t txn; 70 : }; */ 71 : /* Access with TXN macro below */ 72 : uchar _[FD_TXN_MAX_SZ] __attribute__((aligned(alignof(fd_txn_t)))); 73 : }; 74 : typedef struct fd_txn_p fd_txn_p_t; 75 : 76 67055010 : #define TXN(txn_p) ((fd_txn_t *)( (txn_p)->_ )) 77 : 78 : /* fd_txn_e_t: An fd_txn_p_t with expanded address lookup tables */ 79 : struct __attribute__((aligned(64))) fd_txn_e { 80 : fd_txn_p_t txnp[1]; 81 : fd_acct_addr_t alt_accts[FD_TXN_ACCT_ADDR_MAX]; /* The used account is in the fd_txn_t*/ 82 : }; 83 : typedef struct fd_txn_e fd_txn_e_t; 84 : 85 819723 : #define MAX_TXN_PER_MICROBLOCK ((MAX_MICROBLOCK_SZ-sizeof(fd_entry_batch_meta_t))/sizeof(fd_txn_p_t)) 86 : 87 : /* FD_POH_SHRED_MTU is the size of the raw transaction portion of the 88 : largest microblock the pack tile will produce, plus the 48B of 89 : microblock header (hash and 2 ulongs) plus the fd_entry_batch_meta_t 90 : metadata. */ 91 0 : #define FD_POH_SHRED_MTU (sizeof(fd_entry_batch_meta_t) + sizeof(fd_entry_batch_header_t) + FD_TPU_MTU * MAX_TXN_PER_MICROBLOCK) 92 : 93 : FD_STATIC_ASSERT( FD_POH_SHRED_MTU<=USHORT_MAX, poh_shred_mtu ); 94 : 95 : #endif /*HEADER_fd_src_ballet_pack_fd_microblock_h*/