LCOV - code coverage report
Current view: top level - discof/txsend - fd_txsend_tile.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 2 0.0 %
Date: 2026-06-29 05:51:35 Functions: 0 0 -

          Line data    Source code
       1             : #ifndef HEADER_fd_src_discof_txsend_fd_txsend_tile_h
       2             : #define HEADER_fd_src_discof_txsend_fd_txsend_tile_h
       3             : 
       4             : #include "../../waltz/quic/fd_quic.h"
       5             : #include "../../flamenco/progcache/fd_progcache_xid.h"
       6             : #include "../../flamenco/leaders/fd_multi_epoch_leaders.h"
       7             : #include "../../flamenco/gossip/fd_gossip_message.h"
       8             : #include "../../disco/stem/fd_stem.h"
       9             : #include "../../disco/net/fd_net_tile.h"
      10             : #include "../../disco/keyguard/fd_keyguard_client.h"
      11             : #include "../../disco/keyguard/fd_keyswitch.h"
      12             : #include "../../util/net/fd_net_headers.h"
      13             : 
      14             : struct fd_txsend_in {
      15             :   fd_wksp_t * mem;
      16             :   ulong       chunk0;
      17             :   ulong       wmark;
      18             :   ulong       mtu;
      19             : };
      20             : 
      21             : typedef struct fd_txsend_in fd_txsend_in_t;
      22             : 
      23             : struct fd_txsend_out {
      24             :   ulong       idx;
      25             :   fd_wksp_t * mem;
      26             :   ulong       chunk0;
      27             :   ulong       wmark;
      28             :   ulong       chunk;
      29             : };
      30             : 
      31             : typedef struct fd_txsend_out fd_txsend_out_t;
      32             : 
      33             : /* QUIC conn table state management
      34             : 
      35             :    fd_quic_conn_t objects are managed by fd_quic_t.
      36             :    peer_map holds pointers to quic_conns (up to 2 conns per peer).
      37             :    The lifetime of these must be synchronized with quic_conn state.
      38             : 
      39             :    This implies the following:
      40             :    - fd_quic must inform txsend via a conn_final callback before freeing
      41             :      a conn object
      42             :    - in rare cases, txsend may see conn alloc failures even if peer_map
      43             :      has free conn slots
      44             : 
      45             :    The following procedure closes a conn:
      46             :    - call fd_quic_conn_close (enqueues an immediate conn close)
      47             :    - deregister the conn from the table
      48             :    - call fd_quic_service (sends out CONN_CLOSE packet, conn_final
      49             :      callback, frees conn) */
      50             : 
      51             : struct txsend_conn {
      52             :   uint             quic_ip_addr;
      53             :   ushort           quic_port;
      54             :   fd_quic_conn_t * quic_conn;
      55             :   long             quic_last_connected;
      56             : };
      57             : typedef struct txsend_conn txsend_conn_t;
      58             : 
      59             : struct peer_entry {
      60             :   /* Key */
      61             :   fd_pubkey_t pubkey;
      62             : 
      63             :   /* State */
      64             :   txsend_conn_t quic_conns[ 2UL ];
      65             :   uint   udp_ip_addrs[ 2UL ];
      66             :   ushort udp_ports[ 2UL ];
      67             :   int    tombstoned;
      68             : 
      69             :   struct {
      70             :     ulong next;
      71             :   } map;
      72             : };
      73             : 
      74             : typedef struct peer_entry peer_entry_t;
      75             : 
      76             : #define MAP_NAME               peer_map
      77             : #define MAP_KEY                pubkey
      78             : #define MAP_ELE_T              peer_entry_t
      79             : #define MAP_KEY_T              fd_pubkey_t
      80             : #define MAP_NEXT               map.next
      81           0 : #define MAP_KEY_EQ(k0,k1)      fd_pubkey_eq( k0, k1 )
      82           0 : #define MAP_KEY_HASH(key,seed) fd_progcache_rec_key_hash1( (key)->uc, (seed) )
      83             : #define MAP_IMPL_STYLE         1
      84             : #include "../../util/tmpl/fd_map_chain.c"
      85             : 
      86             : struct quic_entry {
      87             :   fd_quic_conn_t * conn;
      88             :   fd_pubkey_t      pubkey;
      89             : };
      90             : 
      91             : typedef struct quic_entry quic_entry_t;
      92             : 
      93             : /* txsend tile data structure
      94             : 
      95             :    notable data structures:
      96             :    - the quic instance manages quic_conns
      97             :    - the conns array is a list of pointers to quic_conns, kept in sync
      98             :      with quic instance
      99             :    - the peers table is replicated from gossip ContactInfo updates
     100             :    - the peer_map hashmap maps pubkey to peers[i] entry; drift is
     101             :      tolerated
     102             :    - peers[i] contains pointers to quic_conn */
     103             : 
     104             : struct fd_txsend_tile {
     105             :   fd_quic_t * quic;
     106             : 
     107             :   ulong leader_schedules;
     108             :   fd_multi_epoch_leaders_t * mleaders;
     109             : 
     110             :   ulong seed;
     111             :   peer_map_t * peer_map;
     112             : 
     113             :   peer_entry_t peers[ FD_CONTACT_INFO_TABLE_SIZE ];
     114             : 
     115             :   ulong conns_len;
     116             :   quic_entry_t conns[ 128UL ];
     117             : 
     118             :   ulong voted_slot;
     119             : 
     120             :   fd_stem_context_t * stem;
     121             : 
     122             :   ulong chunk;
     123             :   uchar quic_buf[ FD_NET_MTU ];
     124             : 
     125             :   uint               src_ip_addr;
     126             :   ushort             src_port;
     127             :   fd_ip4_udp_hdrs_t  packet_hdr[1]; /* template, but will be modified directly */
     128             :   ushort             net_id;
     129             : 
     130             :   fd_aio_t    quic_tx_aio[1];
     131             : 
     132             :   int in_kind[ 32UL ];
     133             :   fd_txsend_in_t in[ 32UL ];
     134             :   fd_net_rx_bounds_t net_in_bounds[ 64UL ];
     135             : 
     136             :   fd_txsend_out_t txsend_out[1];
     137             :   fd_txsend_out_t net_out[1];
     138             : 
     139             :   fd_keyswitch_t * keyswitch;
     140             :   ulong tower_in_expect_seq;
     141             :   int   halt_net_frags;
     142             : 
     143             :   fd_pubkey_t identity_key[1];
     144             :   fd_keyguard_client_t keyguard_client[1];
     145             : 
     146             :   uchar __attribute__((aligned(FD_MULTI_EPOCH_LEADERS_ALIGN))) mleaders_mem[ FD_MULTI_EPOCH_LEADERS_FOOTPRINT ];
     147             : };
     148             : 
     149             : typedef struct fd_txsend_tile fd_txsend_tile_t;
     150             : 
     151             : #endif /* HEADER_fd_src_discof_txsend_fd_txsend_tile_h */

Generated by: LCOV version 1.14