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

          Line data    Source code
       1             : #ifndef HEADER_fd_src_disco_fd_txn_m_t_h
       2             : #define HEADER_fd_src_disco_fd_txn_m_t_h
       3             : 
       4             : /* A fd_txn_m_t is a parsed meta transaction, containing not just the
       5             :    payload */
       6             : 
       7             : #include "../ballet/txn/fd_txn.h"
       8             : 
       9             : struct fd_txn_m {
      10             :   /* The computed slot that this transaction is referencing, aka. the
      11             :      slot number of the reference_blockhash.  If it could not be
      12             :      determined, this will be the current slot. */
      13             :   ulong    reference_slot;
      14             : 
      15             :   ushort   payload_sz;
      16             : 
      17             :   /* Can be computed from the txn_t but it's expensive to parse again,
      18             :      so we just store this redundantly. */
      19             :   ushort    txn_t_sz;
      20             : 
      21             :   /* 4 bytes of padding here */
      22             : 
      23             :   struct {
      24             :     /* If the transaction is part of a bundle, the bundle_id will be
      25             :        non-zero, and if this transaction is the first one in the
      26             :        bundle, bundle_txn_cnt will be non-zero.
      27             : 
      28             :        The pack tile can accumulate transactions from a bundle until
      29             :        it has all of them, at which point the bundle is schedulable.
      30             : 
      31             :        Bundles will not arrive to pack interleaved with other bundles
      32             :        (although might be interleaved with other non-bundle
      33             :        transactions), so if pack sees the bundle_id change before
      34             :        collecting all the bundle_txn_cnt transactions, it should
      35             :        abandon the bundle, as one or more of the transactions failed
      36             :        to signature verify or resolve.
      37             : 
      38             :        The commission and commission_pubkey fields are provided by
      39             :        the block engine, and the validator will crank the tip payment
      40             :        program with these values, if it is not using them already.
      41             :        These fields are only provided on the first transaction in a
      42             :        bundle. */
      43             :     ulong bundle_id;
      44             :     ulong bundle_txn_cnt;
      45             :     uchar commission;
      46             :     uchar commission_pubkey[ 32 ];
      47             :   } block_engine;
      48             : 
      49             :   /* alignof is 8, so 7 bytes of padding here */
      50             : 
      51             :   /* There are three additional fields at the end here, which are
      52             :      variable length and not included in the size of this struct.
      53             :   uchar          payload[ ]
      54             :   fd_txn_t       txn_t[ ]
      55             :   fd_acct_addr_t alut[ ] */
      56             : };
      57             : 
      58             : typedef struct fd_txn_m fd_txn_m_t;
      59             : 
      60             : static FD_FN_CONST inline ulong
      61           0 : fd_txn_m_align( void ) {
      62           0 :   return alignof( fd_txn_m_t );
      63           0 : }
      64             : 
      65             : static inline ulong
      66             : fd_txn_m_footprint( ulong payload_sz,
      67             :                     ulong instr_cnt,
      68             :                     ulong addr_table_lookup_cnt,
      69           0 :                     ulong addr_table_adtl_cnt ) {
      70           0 :   ulong l = FD_LAYOUT_INIT;
      71           0 :   l = FD_LAYOUT_APPEND( l, alignof(fd_txn_m_t),     sizeof(fd_txn_m_t) );
      72           0 :   l = FD_LAYOUT_APPEND( l, 1UL,                     payload_sz );
      73           0 :   l = FD_LAYOUT_APPEND( l, fd_txn_align(),          fd_txn_footprint( instr_cnt, addr_table_lookup_cnt ) );
      74           0 :   l = FD_LAYOUT_APPEND( l, alignof(fd_acct_addr_t), addr_table_adtl_cnt*sizeof(fd_acct_addr_t) );
      75           0 :   return FD_LAYOUT_FINI( l, fd_txn_m_align() );
      76           0 : }
      77             : 
      78             : static inline uchar *
      79           0 : fd_txn_m_payload( fd_txn_m_t * txnm ) {
      80           0 :   return (uchar *)(txnm+1UL);
      81           0 : }
      82             : 
      83             : static inline fd_txn_t *
      84           0 : fd_txn_m_txn_t( fd_txn_m_t * txnm ) {
      85           0 :   return (fd_txn_t *)fd_ulong_align_up( (ulong)(txnm+1UL) + txnm->payload_sz, alignof( fd_txn_t ) );
      86           0 : }
      87             : 
      88             : static inline fd_txn_t const *
      89           0 : fd_txn_m_txn_t_const( fd_txn_m_t const * txnm ) {
      90           0 :   return (fd_txn_t const *)fd_ulong_align_up( (ulong)(txnm+1UL) + txnm->payload_sz, alignof( fd_txn_t ) );
      91           0 : }
      92             : 
      93             : static inline fd_acct_addr_t *
      94           0 : fd_txn_m_alut( fd_txn_m_t * txnm ) {
      95           0 :   return (fd_acct_addr_t *)fd_ulong_align_up( fd_ulong_align_up( (ulong)(txnm+1UL) + txnm->payload_sz, alignof( fd_txn_t ) )+txnm->txn_t_sz, alignof( fd_acct_addr_t ) );
      96           0 : }
      97             : 
      98             : static inline ulong
      99             : fd_txn_m_realized_footprint( fd_txn_m_t const * txnm,
     100             :                              int                include_txn_t,
     101           0 :                              int                include_alut ) {
     102           0 :   if( FD_LIKELY( include_txn_t ) ) {
     103           0 :     return fd_txn_m_footprint( txnm->payload_sz,
     104           0 :                                fd_txn_m_txn_t_const( txnm )->instr_cnt,
     105           0 :                                fd_txn_m_txn_t_const( txnm )->addr_table_lookup_cnt,
     106           0 :                                include_alut ? fd_txn_m_txn_t_const( txnm )->addr_table_adtl_cnt : 0UL );
     107           0 :   } else {
     108           0 :     ulong l = FD_LAYOUT_INIT;
     109           0 :     l = FD_LAYOUT_APPEND( l, alignof(fd_txn_m_t), sizeof(fd_txn_m_t) );
     110           0 :     l = FD_LAYOUT_APPEND( l, 1UL,                 txnm->payload_sz   );
     111           0 :     return FD_LAYOUT_FINI( l, fd_txn_m_align() );
     112           0 :   }
     113           0 : }
     114             : 
     115             : #define FD_TPU_RAW_MTU FD_ULONG_ALIGN_UP(                 \
     116             :                            sizeof(fd_txn_m_t)+FD_TPU_MTU, \
     117             :                            alignof(fd_txn_m_t) )
     118             : 
     119           0 : #define FD_TPU_PARSED_MTU FD_ULONG_ALIGN_UP(                    \
     120           0 :                               FD_ULONG_ALIGN_UP(                \
     121           0 :                                  sizeof(fd_txn_m_t)+FD_TPU_MTU, \
     122           0 :                                  alignof(fd_txn_t) )            \
     123           0 :                               +FD_TXN_MAX_SZ,                   \
     124           0 :                               alignof(fd_txn_m_t) )
     125             : 
     126           0 : #define FD_TPU_RESOLVED_MTU FD_ULONG_ALIGN_UP(                     \
     127           0 :                               FD_ULONG_ALIGN_UP(                   \
     128           0 :                                  FD_ULONG_ALIGN_UP(                \
     129           0 :                                     sizeof(fd_txn_m_t)+FD_TPU_MTU, \
     130           0 :                                     alignof(fd_txn_t) )            \
     131           0 :                                  +FD_TXN_MAX_SZ,                   \
     132           0 :                                  alignof(fd_acct_addr_t) )         \
     133           0 :                               +256UL*sizeof(fd_acct_addr_t),       \
     134           0 :                               alignof(fd_txn_m_t) )
     135             : 
     136             : #endif /* HEADER_fd_src_disco_fd_txn_m_t_h */

Generated by: LCOV version 1.14