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_keyswitch.h" 10 : #include "../../disco/gui/fd_gui_gossip_bw.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 : ulong gui_bw_seed; 42 : uint rng_seed; 43 : ulong rng_idx; 44 : uchar ping_seed[ 32 ]; 45 : 46 : fd_clock_tile_t clock[1]; 47 : 48 : int has_gui; 49 : fd_gui_gossip_bw_t * gui_bw; 50 : 51 : fd_gossip_in_ctx_t in[ 128UL ]; 52 : 53 : fd_gossip_out_ctx_t net_out[ 1 ]; 54 : fd_gossip_out_ctx_t update_out[ FD_GOSSIP_UPDATE_LINK_CNT ]; /* gossip_ciaddr, gossip_ciseen, gossip_vote, gossip_misc */ 55 : fd_gossip_out_ctx_t gossvf_out[ 1 ]; 56 : fd_gossip_out_ctx_t sign_out[ 1 ]; 57 : fd_gossip_out_ctx_t gui_out[ 1 ]; 58 : 59 : ulong sign_out_mtu; 60 : uchar sign_staged[ 64UL ]; 61 : 62 : fd_keyswitch_t * keyswitch; 63 : int is_halting_signing; 64 : int is_pending_set_identity; 65 : 66 : ushort net_id; 67 : fd_ip4_udp_hdrs_t net_out_hdr[ 1 ]; 68 : fd_rng_t rng[ 1 ]; 69 : 70 : 71 : /* FIXME: Support a larger bound. */ 72 : /* The condition for complete = 1 is 80% of the cluster has joined 73 : gossip. "joining gossip" is based on contact info CRDS values 74 : with a wallclock timestamp in the last 15 seconds. 75 : 76 : We keep a copy of the snapshot bank's votes states in an array here 77 : for quick look up. */ 78 : fd_vote_stake_weight_t wfs_stakes_scratch[ FD_RUNTIME_MAX_SNAPSHOT_VOTE_ACCOUNTS ]; 79 : fd_stake_weight_t wfs_stakes [ FD_RUNTIME_MAX_SNAPSHOT_VOTE_ACCOUNTS ]; 80 : ulong wfs_stakes_cnt; 81 : 82 : /* wfs_active is used to keep track of nodes we've already labeled as 83 : being active on gossip, so we don't double count their stake. */ 84 : uchar wfs_active[ FD_RUNTIME_MAX_SNAPSHOT_VOTE_ACCOUNTS ]; 85 : int wfs_state; 86 : 87 : /* Inputs to fd_wfs_mode (see fd_wfs.h), so gossip can tell MATCH 88 : from NOOP. wfs_boot_slot is ULONG_MAX until the first manifest. */ 89 : ulong wfs_slot; 90 : ushort wfs_shred_version; 91 : int wfs_hash_is_zero; 92 : ulong wfs_boot_slot; 93 : 94 : struct { 95 : ulong online; 96 : ulong total; 97 : } wfs_stake, wfs_peers; 98 : 99 : /* Peer table saturation detection. We track the high-water mark 100 : of the peer count (staked + unstaked). When the count stops 101 : increasing for FD_GOSSIP_PEER_SAT_QUIET_NS and at least one 102 : peer is present, we publish PEER_SATURATED on gossip_ciaddr. */ 103 : ulong peer_sat_hwm; /* high-water mark of peer count */ 104 : long peer_sat_hwm_nanos; /* wallclock when HWM last increased */ 105 : int peer_sat_published; /* one-shot latch (0 -> 1) */ 106 : }; 107 : 108 : typedef struct fd_gossip_tile_ctx fd_gossip_tile_ctx_t; 109 : 110 : static inline ulong 111 : fd_gossvf_sig( uint addr, 112 : ushort port, 113 0 : ushort kind ) { 114 0 : return (ulong)addr | ((ulong)port<<32) | ((ulong)kind<<48); 115 0 : } 116 : 117 : static inline uint 118 0 : fd_gossvf_sig_addr( ulong sig ) { 119 0 : return (uint)(sig & 0xFFFFFFFFUL); 120 0 : } 121 : 122 : static inline ushort 123 0 : fd_gossvf_sig_port( ulong sig ) { 124 0 : return (ushort)(sig>>32); 125 0 : } 126 : 127 : static inline ushort 128 0 : fd_gossvf_sig_kind( ulong sig ) { 129 0 : return (ushort)(sig>>48); 130 0 : } 131 : 132 : struct fd_gossip_pingreq { 133 : fd_pubkey_t pubkey; 134 : }; 135 : 136 : typedef struct fd_gossip_pingreq fd_gossip_pingreq_t; 137 : 138 : struct fd_gossip_ping_update { 139 : fd_pubkey_t pubkey; 140 : fd_ip4_port_t gossip_addr; 141 : int remove; 142 : }; 143 : 144 : typedef struct fd_gossip_ping_update fd_gossip_ping_update_t; 145 : 146 : extern fd_topo_run_tile_t fd_tile_gossip; 147 : 148 : #endif /* HEADER_fd_src_discof_gossip_fd_gossip_tile_h */