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