Skip to content

WIP: changes to merge gossip2 branch #5154

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 21 commits into
base: mmcgee/gossip2
Choose a base branch
from

Conversation

ravyu-jump
Copy link
Contributor

  • setup type defs and fn defintions for parsing
  • parsers for ping and pong
  • progress
  • rx ping/pong, tx ping, ping/pong serializers, helper functions, coalesce ping and pong into one type

@ravyu-jump ravyu-jump changed the title WIP: gossip2 branch WIP: changes to merge gossip2 branch May 16, 2025
} version;

struct {
/* WARNING: in gossip contact info message,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not useful comment, fd_ip4_port_t is clearly host order

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fd_ip4_port_t is clearly host order

The fd_ip4_port_t type def has comments saying network order


struct fd_gossip_crds_vote {
ulong slot;
uchar vote_tower_index;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this already stored in the key? vote_index ?

Assumes both token and hash are the starting address of a 32byte region of
memory */
void
fd_ping_tracker_hash_ping_token( uchar * hash,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nits: would flip the argument order, and name out_hash, out args are usually last by convention

void
fd_ping_tracker_hash_ping_token( uchar * hash,
uchar const * token ) {
fd_sha256_t sha[1];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably needs a ping_tracker const * ping_tracker arg, and to use ping_tracker->sha

fd_gossip_tile_ctx_t * gossip_ctx = (fd_gossip_tile_ctx_t *)ctx;

ulong packet_sz = payload_sz + sizeof(fd_ip4_udp_hdrs_t);
gossip_ctx->net_out->chunk = fd_dcache_compact_next( gossip_ctx->net_out->chunk, packet_sz, gossip_ctx->net_out->chunk0, gossip_ctx->net_out->wmark );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do this at the end after fd_stem_publish (by convention, incase we return early etc)

/* TODO: ip4 net_id? */

/* Inject payload */
fd_memcpy( packet + sizeof(fd_ip4_udp_hdrs_t), payload, payload_sz );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not good. Payload should already be constructed in the right place.


/* Publish fragment */
ulong tspub = fd_frag_meta_ts_comp( fd_tickcount() );
ulong sig = fd_disco_netmux_sig( peer_address->addr, peer_address->port, peer_address->addr, DST_PROTO_OUTGOING, sizeof(fd_ip4_udp_hdrs_t) );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Last arg is ignored, should probably be set to 0.


FD_PROTOTYPES_BEGIN
long
fd_crds_value_wallclock( fd_crds_value_t const * value );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these functions needed? Looks like it's trivial to access the value

#include "fd_gossip_msg.h"
#include "fd_gossip_types.h"
void
fd_gossip_msg_init( fd_gossip_message_t * msg ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? Should never need to call this

@@ -121,6 +144,8 @@ fd_gossip_set_identity( fd_gossip_t * gossip,
periodically rotated, with one new peer entering and one old peer
leaving, based on stake weights.

now is the current time in nanoseconds.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dupe comment


/* For CRDS composites, this holds information about the CRDS values necessary
to perform an insertion into the CRDS and signature verification */
ulong crds_cnt; /* number of CRDS values in the message, if any */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a bit confused. Why are the CRDS lifted out from the union to the parent type here? A ping/pong does not have CRDS.


/* value data ... */
/* Pool fields. Not in use when pool element is acquired */
ulong pool_next;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ulong pool_next;
struct {
ulong next;
} pool;
ulong num_duplicates;

lookup_map_t * lookup_map;
evict_treap_t * evict_treap;
staked_expire_dlist_t * staked_expire_dlist;
unstaked_expire_dlist_t *unstaked_expire_dlist;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
unstaked_expire_dlist_t *unstaked_expire_dlist;
unstaked_expire_dlist_t * unstaked_expire_dlist;

fd_crds_acquire( fd_crds_t * crds ) {
if( FD_UNLIKELY( !crds_pool_free( crds->pool )==0UL ) ) {
evict_treap_fwd_iter_t head = evict_treap_fwd_iter_init( crds->evict_treap );
if( FD_UNLIKELY( crds_pool_free( crds->pool )==0UL ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if( FD_UNLIKELY( crds_pool_free( crds->pool )==0UL ) ) {
if( FD_UNLIKELY( !crds_pool_free( crds->pool ) ) ) {

if( FD_LIKELY( candidate->wallclock>value->wallclock ) ) return 1;
else if( FD_LIKELY( candidate->wallclock<value->wallclock ) ) return 0;
if( FD_UNLIKELY( cand_wc>val_wc ) ) return 1;
else if( FD_UNLIKELY( cand_wc<val_wc ) ) return 0;
else return !!candidate->hash.hash<value->hash.hash;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
else return !!candidate->hash.hash<value->hash.hash;
else return !!(candidate->hash.hash<value->hash.hash);

FD_FN_CONST ulong
fd_crds_align( void );

FD_FN_CONST ulong
fd_crds_footprint( ulong ele_max );
fd_crds_footprint( ulong ele_max, ulong purged_max );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fd_crds_footprint( ulong ele_max, ulong purged_max );
fd_crds_footprint( ulong ele_max,
ulong purged_max );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants