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

          Line data    Source code
       1             : #ifndef HEADER_fd_src_app_fdctl_run_tiles_fd_send_tile_h
       2             : #define HEADER_fd_src_app_fdctl_run_tiles_fd_send_tile_h
       3             : 
       4             : /* Sender tile signs and sends transactions to the current leader.
       5             :    Currently only supports transactions which require one signature.
       6             :    Designed with voting as primary use case. Signing those votes will
       7             :    eventually move to a separate consensus tile.*/
       8             : #define _GNU_SOURCE
       9             : 
      10             : #include "../../disco/metrics/fd_metrics.h"
      11             : #include "../../disco/topo/fd_topo.h"
      12             : #include "generated/fd_send_tile_seccomp.h"
      13             : 
      14             : #include "../../util/fd_util.h"
      15             : #include "../../util/net/fd_net_headers.h"
      16             : 
      17             : #include "../../disco/stem/fd_stem.h"
      18             : 
      19             : #include "../../disco/fd_disco.h"
      20             : #include "../../disco/pack/fd_microblock.h"
      21             : 
      22             : #include "../../disco/keyguard/fd_keyload.h"
      23             : #include "../../disco/keyguard/fd_keyguard_client.h"
      24             : #include "../../disco/keyguard/fd_keyguard.h"
      25             : 
      26             : #include "../../flamenco/leaders/fd_multi_epoch_leaders.h"
      27             : #include "../../flamenco/leaders/fd_leaders.h"
      28             : #include "../../flamenco/gossip/fd_gossip.h"
      29             : 
      30             : #include "../../waltz/quic/fd_quic.h"
      31             : #include "../../disco/net/fd_net_tile.h"
      32             : 
      33             : #define IN_KIND_SIGN   (0UL)
      34           0 : #define IN_KIND_GOSSIP (1UL)
      35           0 : #define IN_KIND_STAKE  (2UL)
      36           0 : #define IN_KIND_TOWER  (3UL)
      37           0 : #define IN_KIND_NET    (4UL)
      38             : 
      39             : /* Send votes to leaders for next SEND_TO_LEADER_CNT slots */
      40           0 : #define SEND_TO_LEADER_CNT 4UL
      41             : 
      42           0 : #define QUIC_IDLE_TIMEOUT_NS (2e9)  /* 2 seconds */
      43           0 : #define QUIC_ACK_DELAY_NS    (25e6) /* 25ms */
      44             : 
      45             : struct fd_send_link_in {
      46             :   fd_wksp_t *  mem;
      47             :   ulong        chunk0;
      48             :   ulong        wmark;
      49             :   ulong        kind;
      50             :   void      *  dcache;
      51             : };
      52             : typedef struct fd_send_link_in fd_send_link_in_t;
      53             : 
      54             : struct fd_send_link_out {
      55             :   ulong            idx;
      56             :   fd_frag_meta_t * mcache;
      57             :   ulong *          sync;
      58             :   ulong            depth;
      59             : 
      60             :   fd_wksp_t * mem;
      61             :   ulong       chunk0;
      62             :   ulong       wmark;
      63             :   ulong       chunk;
      64             : };
      65             : typedef struct fd_send_link_out fd_send_link_out_t;
      66             : struct fd_send_conn_entry {
      67             :   fd_pubkey_t      pubkey;
      68             :   uint             hash;
      69             :   fd_quic_conn_t * conn;
      70             :   long             last_ci_ticks;
      71             :   uint             ip4_addr;
      72             :   ushort           udp_port;
      73             : };
      74             : typedef struct fd_send_conn_entry fd_send_conn_entry_t;
      75             : 
      76             : 
      77             : struct fd_send_tile_ctx {
      78             :   fd_pubkey_t identity_key[ 1 ];
      79             :   fd_pubkey_t vote_acct_addr[ 1 ];
      80             : 
      81             :   fd_multi_epoch_leaders_t * mleaders;
      82             : 
      83             :   fd_shred_dest_wire_t       contact_buf[ MAX_STAKED_LEADERS ];
      84             :   ulong                      contact_cnt;
      85             : 
      86             :   uchar txn_buf[ sizeof(fd_txn_p_t) ] __attribute__((aligned(alignof(fd_txn_p_t))));
      87             : 
      88             :   uint                  src_ip_addr;
      89             :   ushort                src_port;
      90             :   fd_ip4_udp_hdrs_t     packet_hdr[1];
      91             : 
      92             :   #define fd_send_MAX_IN_LINK_CNT 32UL
      93             :   fd_send_link_in_t in_links[ fd_send_MAX_IN_LINK_CNT ];
      94             : 
      95             :   fd_send_link_out_t gossip_verify_out[1];
      96             :   fd_send_link_out_t net_out         [1];
      97             : 
      98             :   fd_keyguard_client_t keyguard_client[ 1 ];
      99             : 
     100             :   fd_quic_t * quic;
     101             :   fd_aio_t    quic_tx_aio[1];
     102             : 
     103             : # define ED25519_PRIV_KEY_SZ (32)
     104           0 : # define ED25519_PUB_KEY_SZ  (32)
     105             :   uchar            tls_priv_key[ ED25519_PRIV_KEY_SZ ];
     106             :   uchar            tls_pub_key [ ED25519_PUB_KEY_SZ  ];
     107             :   fd_sha512_t      sha512[1]; /* used for signing */
     108             : 
     109             :   uchar quic_buf[ FD_NET_MTU ];
     110             : 
     111             :   fd_net_rx_bounds_t net_in_bounds;
     112             : 
     113             :   // Connection map for outgoing QUIC connections using fd_map
     114             :   fd_send_conn_entry_t * conn_map;
     115             : 
     116             :   fd_stem_context_t * stem;
     117             :   long                now;
     118             : 
     119             :   struct {
     120             :     ulong leader_not_found;        /* Number of times slot leader not found when voting. */
     121             :     ulong contact_stale;           /* Number of reconnects skipped due to stale contact info */
     122             :     ulong quic_conn_create_failed; /* QUIC connection creation failed */
     123             : 
     124             :     /* Handling of new contact info */
     125             :     ulong new_contact_info[FD_METRICS_ENUM_NEW_CONTACT_OUTCOME_CNT];
     126             : 
     127             :     /* Outcome of trying to send data over quic */
     128             :     ulong quic_send_result_cnt[FD_METRICS_ENUM_TXN_QUIC_SEND_RESULT_CNT];
     129             : 
     130             :   } metrics;
     131             : 
     132             :   uchar __attribute__((aligned(FD_MULTI_EPOCH_LEADERS_ALIGN))) mleaders_mem[ FD_MULTI_EPOCH_LEADERS_FOOTPRINT ];
     133             : 
     134             : };
     135             : typedef struct fd_send_tile_ctx fd_send_tile_ctx_t;
     136             : 
     137             : 
     138             : /* A few larger functions to wrap QUIC interactions */
     139             : 
     140             : /* quic_connect initiates a quic connection. It uses the contact info
     141             :    stored in entry, and points the conn and entry to each other. Returns
     142             :    a handle to the new connection, and NULL if creating it failed */
     143             : fd_quic_conn_t *
     144             : quic_connect( fd_send_tile_ctx_t   * ctx,
     145             :               fd_send_conn_entry_t * entry );
     146             : 
     147             : /* quic_send sends a payload to 'pubkey' via quic. Requires an already
     148             :    established connection to 'pubkey'. */
     149             : void
     150             : quic_send( fd_send_tile_ctx_t  *  ctx,
     151             :            fd_pubkey_t const   *  pubkey,
     152             :            uchar const         *  payload,
     153             :            ulong                  payload_sz );
     154             : 
     155             : #endif

Generated by: LCOV version 1.14