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

Generated by: LCOV version 1.14