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

Generated by: LCOV version 1.14