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

Generated by: LCOV version 1.14