LCOV - code coverage report
Current view: top level - disco - fd_txn_m.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 60 0.0 %
Date: 2026-11-26 02:16:43 Functions: 0 232 0.0 %

          Line data    Source code
       1             : #ifndef HEADER_fd_src_disco_fd_txn_m_h
       2             : #define HEADER_fd_src_disco_fd_txn_m_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             : /* Keep in sync with events/schema/events.proto:TxnProtocol */
      10           0 : #define FD_TXN_M_TPU_SOURCE_QUIC   (1UL)
      11           0 : #define FD_TXN_M_TPU_SOURCE_UDP    (2UL)
      12           0 : #define FD_TXN_M_TPU_SOURCE_GOSSIP (3UL)
      13           0 : #define FD_TXN_M_TPU_SOURCE_BUNDLE (4UL)
      14             : //#define FD_TXN_M_TPU_SOURCE_TXSEND (5UL) /* deprecated */
      15             : 
      16             : struct fd_txn_m {
      17             :   /* The block height of the computed slot that this transaction is
      18             :      referencing, aka. the block height of the reference_blockhash.  If
      19             :      it could not be determined, this will be the block height of the
      20             :      current slot. */
      21             :   ulong    reference_block_height;
      22             : 
      23             :   ushort   payload_sz;
      24             : 
      25             :   /* Can be computed from the txn_t but it's expensive to parse again,
      26             :      so we just store this redundantly. */
      27             :   ushort    txn_t_sz;
      28             : 
      29             :   /* Source tpu and IP address for this transaction.  Note that
      30             :      source_ipv4 is in big endian. */
      31             :   uint     source_ipv4;
      32             :   uchar    source_tpu;
      33             : 
      34             :   /* 7 bytes of padding here */
      35             : 
      36             :   /* Wallclock nanoseconds at which this transaction entered the
      37             :      validator. */
      38             :   long     first_seen_nanos;
      39             : 
      40             :   struct {
      41             :     /* If the transaction is part of a bundle, the bundle_id will be
      42             :        non-zero.  The bundle tile sets bundle_txn_cnt on every
      43             :        transaction in the bundle; pack reads it from the first one.
      44             : 
      45             :        The pack tile can accumulate transactions from a bundle until
      46             :        it has all of them, at which point the bundle is schedulable.
      47             : 
      48             :        Bundles will not arrive to pack interleaved with other bundles
      49             :        (although might be interleaved with other non-bundle
      50             :        transactions), so if pack sees the bundle_id change before
      51             :        collecting all the bundle_txn_cnt transactions, it should
      52             :        abandon the bundle, as one or more of the transactions failed
      53             :        to signature verify or resolve.
      54             : 
      55             :        The commission and commission_pubkey fields are provided by
      56             :        the block engine, and the validator will crank the tip payment
      57             :        program with these values, if it is not using them already.
      58             :        These fields are provided on every transaction in a bundle;
      59             :        pack uses the values from the first transaction. */
      60             :     ulong bundle_id;
      61             :     ulong bundle_txn_cnt;
      62             :     uchar commission;
      63             :     uchar commission_pubkey[ 32 ];
      64             : 
      65             :     /* alignof is 8, so 7 bytes of padding here */
      66             : 
      67             :   } block_engine;
      68             : 
      69             :   /* There are three additional fields at the end here, which are
      70             :      variable length and not included in the size of this struct. txn_t
      71             :      and alut are only found in frags after the verify step.
      72             :   uchar          payload[ ]
      73             :   fd_txn_t       txn_t[ ]
      74             :   fd_acct_addr_t alut[ ] */
      75             : };
      76             : 
      77             : typedef struct fd_txn_m fd_txn_m_t;
      78             : 
      79             : static FD_FN_CONST inline ulong
      80           0 : fd_txn_m_align( void ) {
      81           0 :   return alignof(fd_txn_m_t);
      82           0 : }
      83             : 
      84             : static inline ulong
      85             : fd_txn_m_footprint( ulong payload_sz,
      86             :                     ulong instr_cnt,
      87             :                     ulong addr_table_lookup_cnt,
      88           0 :                     ulong addr_table_adtl_cnt ) {
      89           0 :   ulong l = FD_LAYOUT_INIT;
      90           0 :   l = FD_LAYOUT_APPEND( l, alignof(fd_txn_m_t),     sizeof(fd_txn_m_t) );
      91           0 :   l = FD_LAYOUT_APPEND( l, 1UL,                     payload_sz );
      92           0 :   l = FD_LAYOUT_APPEND( l, fd_txn_align(),          fd_txn_footprint( instr_cnt, addr_table_lookup_cnt ) );
      93           0 :   l = FD_LAYOUT_APPEND( l, alignof(fd_acct_addr_t), addr_table_adtl_cnt*sizeof(fd_acct_addr_t) );
      94           0 :   return FD_LAYOUT_FINI( l, fd_txn_m_align() );
      95           0 : }
      96             : 
      97             : static inline uchar *
      98           0 : fd_txn_m_payload( fd_txn_m_t * txnm ) {
      99           0 :   return (uchar *)(txnm+1UL);
     100           0 : }
     101             : 
     102             : static inline uchar const *
     103           0 : fd_txn_m_payload_const( fd_txn_m_t const * txnm ) {
     104           0 :   return (uchar const *)(txnm+1UL);
     105           0 : }
     106             : 
     107             : static inline fd_txn_t *
     108           0 : fd_txn_m_txn_t( fd_txn_m_t * txnm ) {
     109           0 :   return (fd_txn_t *)fd_ulong_align_up( (ulong)(txnm+1UL) + txnm->payload_sz, alignof( fd_txn_t ) );
     110           0 : }
     111             : 
     112             : static inline fd_txn_t const *
     113           0 : fd_txn_m_txn_t_const( fd_txn_m_t const * txnm ) {
     114           0 :   return (fd_txn_t const *)fd_ulong_align_up( (ulong)(txnm+1UL) + txnm->payload_sz, alignof( fd_txn_t ) );
     115           0 : }
     116             : 
     117             : static inline fd_acct_addr_t *
     118           0 : fd_txn_m_alut( fd_txn_m_t * txnm ) {
     119           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 ) );
     120           0 : }
     121             : 
     122             : static inline ulong
     123             : fd_txn_m_realized_footprint( fd_txn_m_t const * txnm,
     124             :                              int                include_txn_t,
     125           0 :                              int                include_alut ) {
     126           0 :   if( FD_LIKELY( include_txn_t ) ) {
     127           0 :     ulong l = FD_LAYOUT_INIT;
     128           0 :     l = FD_LAYOUT_APPEND( l, alignof(fd_txn_m_t),     sizeof(fd_txn_m_t) );
     129           0 :     l = FD_LAYOUT_APPEND( l, 1UL,                     txnm->payload_sz );
     130           0 :     l = FD_LAYOUT_APPEND( l, fd_txn_align(),          fd_txn_footprint( fd_txn_m_txn_t_const( txnm )->instr_cnt, fd_txn_m_txn_t_const( txnm )->addr_table_lookup_cnt ) );
     131           0 :     l = FD_LAYOUT_APPEND( l, alignof(fd_acct_addr_t), fd_uchar_if(include_alut, fd_txn_m_txn_t_const( txnm )->addr_table_adtl_cnt, 0U)*sizeof(fd_acct_addr_t) );
     132             : 
     133             :     /* FD_LAYOUT_FINI is not included since the _realized_ footprint
     134             :        should not include the extra padding typically added after the
     135             :        last struct used to align the entire footprint. */
     136           0 :     return l;
     137           0 :   } else {
     138           0 :     ulong l = FD_LAYOUT_INIT;
     139           0 :     l = FD_LAYOUT_APPEND( l, alignof(fd_txn_m_t), sizeof(fd_txn_m_t) );
     140           0 :     l = FD_LAYOUT_APPEND( l, 1UL, txnm->payload_sz );
     141           0 :     return l;
     142           0 :   }
     143           0 : }
     144             : 
     145             : #define FD_TPU_RAW_MTU FD_ULONG_ALIGN_UP(                 \
     146             :                            sizeof(fd_txn_m_t)+FD_TPU_MTU, \
     147             :                            alignof(fd_txn_m_t) )
     148             : 
     149           0 : #define FD_TPU_PARSED_MTU FD_ULONG_ALIGN_UP(                    \
     150           0 :                               FD_ULONG_ALIGN_UP(                \
     151           0 :                                  sizeof(fd_txn_m_t)+FD_TPU_MTU, \
     152           0 :                                  alignof(fd_txn_t) )            \
     153           0 :                               +FD_TXN_MAX_SZ,                   \
     154           0 :                               alignof(fd_txn_m_t) )
     155             : 
     156           0 : #define FD_TPU_RESOLVED_MTU FD_ULONG_ALIGN_UP(                              \
     157           0 :                               FD_ULONG_ALIGN_UP(                            \
     158           0 :                                  FD_ULONG_ALIGN_UP(                         \
     159           0 :                                     sizeof(fd_txn_m_t)+FD_TPU_MTU,          \
     160           0 :                                     alignof(fd_txn_t) )                     \
     161           0 :                                  +FD_TXN_MAX_SZ,                            \
     162           0 :                                  alignof(fd_acct_addr_t) )                  \
     163           0 :                               +FD_TXN_ACCT_ADDR_MAX*sizeof(fd_acct_addr_t), \
     164           0 :                               alignof(fd_txn_m_t) )
     165             : 
     166             : #endif /* HEADER_fd_src_disco_fd_txn_m_h */

Generated by: LCOV version 1.14