LCOV - code coverage report
Current view: top level - discof/gossip - fd_gossip_tile.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 17 0.0 %
Date: 2026-07-09 05:37:44 Functions: 0 40 0.0 %

          Line data    Source code
       1             : #ifndef HEADER_fd_src_discof_gossip_fd_gossip_tile_h
       2             : #define HEADER_fd_src_discof_gossip_fd_gossip_tile_h
       3             : 
       4             : #include "../../disco/fd_disco_base.h"
       5             : #include "../../disco/topo/fd_topo.h"
       6             : #include "../../flamenco/gossip/fd_gossip.h"
       7             : #include "../../flamenco/runtime/fd_runtime_const.h"
       8             : #include "../../disco/keyguard/fd_keyguard_client.h"
       9             : #include "../../disco/keyguard/fd_keyswitch.h"
      10             : 
      11             : typedef struct {
      12             :   int         kind;
      13             :   fd_wksp_t * mem;
      14             :   ulong       chunk0;
      15             :   ulong       wmark;
      16             :   ulong       mtu;
      17             : } fd_gossip_in_ctx_t;
      18             : 
      19           0 : #define FD_GOSSIP_WFS_STATE_INIT    (1)
      20           0 : #define FD_GOSSIP_WFS_STATE_WAIT    (2)
      21           0 : #define FD_GOSSIP_WFS_STATE_PUBLISH (3)
      22           0 : #define FD_GOSSIP_WFS_STATE_DONE    (4)
      23             : 
      24           0 : #define FD_GOSSIP_GOSSVF_MTU (sizeof(fd_gossip_message_t) + FD_GOSSIP_MESSAGE_MAX_CRDS + FD_NET_MTU)
      25             : 
      26             : struct fd_gossip_tile_ctx {
      27             :   fd_gossip_t * gossip;
      28             : 
      29             :   fd_pubkey_t              identity_key[1]; /* Just the public key */
      30             :   fd_gossip_contact_info_t my_contact_info[1];
      31             : 
      32             :   fd_stem_context_t * stem;
      33             : 
      34             :   uchar gossvf_staged[ FD_GOSSIP_GOSSVF_MTU ] __attribute__((aligned(128)));
      35             : 
      36             :   uint  rng_seed;
      37             :   ulong rng_idx;
      38             : 
      39             :   double ticks_per_ns;
      40             :   long   last_wallclock;
      41             :   long   last_tickcount;
      42             : 
      43             :   fd_gossip_in_ctx_t in[ 128UL ];
      44             : 
      45             :   fd_gossip_out_ctx_t net_out[ 1 ];
      46             :   fd_gossip_out_ctx_t gossip_out[ 1 ];
      47             :   fd_gossip_out_ctx_t gossvf_out[ 1 ];
      48             :   fd_gossip_out_ctx_t sign_out[ 1 ];
      49             :   fd_gossip_out_ctx_t gossip_wfs[ 1 ];
      50             : 
      51             :   fd_keyguard_client_t keyguard_client[ 1 ];
      52             :   fd_keyswitch_t *     keyswitch;
      53             :   int                  is_halting_signing;
      54             :   int                  is_pending_set_identity;
      55             : 
      56             :   ushort            net_id;
      57             :   fd_ip4_udp_hdrs_t net_out_hdr[ 1 ];
      58             :   fd_rng_t          rng[ 1 ];
      59             : 
      60             : 
      61             :   /* FIXME: Support a larger bound. */
      62             :   /* The condition for complete = 1 is 80% of the cluster has joined
      63             :      gossip. "joining gossip" is based on contact info CRDS values
      64             :      with a wallclock timestamp in the last 15 seconds.
      65             : 
      66             :      We keep a copy of the snapshot bank's votes states in an array here
      67             :      for quick look up. */
      68             :   fd_vote_stake_weight_t wfs_stakes_scratch[ FD_VOTE_ACCOUNTS_MAX ];
      69             :   fd_stake_weight_t      wfs_stakes        [ FD_VOTE_ACCOUNTS_MAX ];
      70             :   ulong                  wfs_stakes_cnt;
      71             : 
      72             :   /* wfs_active is used to keep track of nodes we've already labeled as
      73             :      being active on gossip, so we don't double count their stake. */
      74             :   uchar             wfs_active[ FD_VOTE_ACCOUNTS_MAX ];
      75             :   int               wfs_state;
      76             : 
      77             :   struct {
      78             :     ulong online;
      79             :     ulong total;
      80             :   } wfs_stake, wfs_peers;
      81             : 
      82             :   /* Peer table saturation detection.  We track the high-water mark
      83             :      of the peer count (staked + unstaked).  When the count stops
      84             :      increasing for FD_GOSSIP_PEER_SAT_QUIET_NS and at least one
      85             :      peer is present, we publish PEER_SATURATED on gossip_out. */
      86             :   ulong peer_sat_hwm;        /* high-water mark of peer count       */
      87             :   long  peer_sat_hwm_nanos;  /* wallclock when HWM last increased   */
      88             :   int   peer_sat_published;  /* one-shot latch (0 -> 1)             */
      89             : };
      90             : 
      91             : typedef struct fd_gossip_tile_ctx fd_gossip_tile_ctx_t;
      92             : 
      93             : static inline ulong
      94             : fd_gossvf_sig( uint   addr,
      95             :                ushort port,
      96           0 :                ushort kind ) {
      97           0 :   return (ulong)addr | ((ulong)port<<32) | ((ulong)kind<<48);
      98           0 : }
      99             : 
     100             : static inline uint
     101           0 : fd_gossvf_sig_addr( ulong sig ) {
     102           0 :   return (uint)(sig & 0xFFFFFFFFUL);
     103           0 : }
     104             : 
     105             : static inline ushort
     106           0 : fd_gossvf_sig_port( ulong sig ) {
     107           0 :   return (ushort)(sig>>32);
     108           0 : }
     109             : 
     110             : static inline ushort
     111           0 : fd_gossvf_sig_kind( ulong sig ) {
     112           0 :   return (ushort)(sig>>48);
     113           0 : }
     114             : 
     115             : struct fd_gossip_pingreq {
     116             :   fd_pubkey_t pubkey;
     117             : };
     118             : 
     119             : typedef struct fd_gossip_pingreq fd_gossip_pingreq_t;
     120             : 
     121             : struct fd_gossip_ping_update {
     122             :   fd_pubkey_t   pubkey;
     123             :   fd_ip4_port_t gossip_addr;
     124             :   int           remove;
     125             : };
     126             : 
     127             : typedef struct fd_gossip_ping_update fd_gossip_ping_update_t;
     128             : 
     129             : extern fd_topo_run_tile_t fd_tile_gossip;
     130             : 
     131             : #endif /* HEADER_fd_src_discof_gossip_fd_gossip_tile_h */

Generated by: LCOV version 1.14