LCOV - code coverage report
Current view: top level - disco/pack - fd_microblock.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 3 3 100.0 %
Date: 2025-07-01 05:00:49 Functions: 0 0 -

          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 "../../ballet/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      819765 : #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             :   /* Chained merkle root needed by shred tile.  This is the merkle
      34             :      root of the last FEC set of the parent block (that's used as
      35             :      the chaining Merkle root for the first FEC set in the current
      36             :      block). */
      37             :   uchar parent_block_id[ 32 ];
      38             :   uchar parent_block_id_valid;
      39             : };
      40             : typedef struct fd_entry_batch_meta fd_entry_batch_meta_t;
      41             : 
      42             : struct fd_entry_batch_header {
      43             :   /* Number of hashes since the last entry batch that was published,
      44             :      in (0, hashes_per_tick].  Will be hashes_per_tick if and only
      45             :      if there were no microblocks sent between two empty ticks of the
      46             :      PoH. */
      47             :   ulong hashcnt_delta;
      48             : 
      49             :   /* The proof of history stamped hash of the entry batch. */
      50             :   uchar hash[32UL];
      51             : 
      52             :    /* Number of hashes in the entry batch.  Will be 0 for a tick,
      53             :       and (0, MAX_TXN_PER_MICROBLOCK] for a microblock. */
      54             :   ulong txn_cnt;
      55             : };
      56             : typedef struct fd_entry_batch_header fd_entry_batch_header_t;
      57             : 
      58             : struct __attribute__((aligned(64))) fd_txn_p {
      59             :   uchar payload[FD_TPU_MTU];
      60             :   ulong payload_sz;
      61             :   union {
      62             :    struct {
      63             :      uint non_execution_cus;
      64             :      uint requested_exec_plus_acct_data_cus;
      65             :    } pack_cu; /* Populated by pack. Bank reads these to populate the other struct of the union. */
      66             :    struct {
      67             :      uint rebated_cus; /* requested_exec_plus_acct_data_cus-actual used CUs. Pack reads this for CU rebating. */
      68             :      uint actual_consumed_cus; /* non_execution_cus+real execution CUs+real account data cus. PoH reads this for block CU counting. */
      69             :    } bank_cu; /* Populated by bank. */
      70             :    ulong blockhash_slot; /* Slot provided by resolv tile when txn arrives at the pack tile. Used when txn is in extra storage in pack. */
      71             :   };
      72             :   /* The time that the transaction arrived to the pack tile in ticks. Set by pack and intended to be read from a transaction on a pack->bank link. */
      73             :   long scheduler_arrival_time_nanos;
      74             :   /* Populated by pack, bank.  A combination of the bitfields
      75             :      FD_TXN_P_FLAGS_* defined above.  The bank sets the high byte with
      76             :      the transaction result code. */
      77             :   uint  flags;
      78             :   /* union {
      79             :     This would be ideal but doesn't work because of the flexible array member
      80             :     uchar _[FD_TXN_MAX_SZ];
      81             :     fd_txn_t txn;
      82             :   }; */
      83             :   /* Access with TXN macro below */
      84             :   uchar _[FD_TXN_MAX_SZ] __attribute__((aligned(alignof(fd_txn_t))));
      85             : };
      86             : typedef struct fd_txn_p fd_txn_p_t;
      87             : 
      88    94792277 : #define TXN(txn_p) ((fd_txn_t *)( (txn_p)->_ ))
      89             : 
      90             : /* fd_txn_e_t: An fd_txn_p_t with expanded address lookup tables */
      91             : struct __attribute__((aligned(64))) fd_txn_e {
      92             :    fd_txn_p_t     txnp[1];
      93             :    fd_acct_addr_t alt_accts[FD_TXN_ACCT_ADDR_MAX]; /* The used account is in the fd_txn_t*/
      94             : };
      95             : typedef struct fd_txn_e fd_txn_e_t;
      96             : 
      97      819765 : #define MAX_TXN_PER_MICROBLOCK ((MAX_MICROBLOCK_SZ-sizeof(fd_entry_batch_meta_t))/sizeof(fd_txn_p_t))
      98             : 
      99             : /* FD_POH_SHRED_MTU is the size of the raw transaction portion of the
     100             :    largest microblock the pack tile will produce, plus the 48B of
     101             :    microblock header (hash and 2 ulongs) plus the fd_entry_batch_meta_t
     102             :    metadata. */
     103             : #define FD_POH_SHRED_MTU (sizeof(fd_entry_batch_meta_t) + sizeof(fd_entry_batch_header_t) + FD_TPU_MTU * MAX_TXN_PER_MICROBLOCK)
     104             : 
     105             : FD_STATIC_ASSERT( FD_POH_SHRED_MTU<=USHORT_MAX, poh_shred_mtu );
     106             : 
     107             : #endif /*HEADER_fd_src_ballet_pack_fd_microblock_h*/

Generated by: LCOV version 1.14