Skip to content

Commit 3d5bae0

Browse files
committed
gossip: publish update messages for crds originating from us
1 parent 41fe03d commit 3d5bae0

File tree

10 files changed

+36
-22
lines changed

10 files changed

+36
-22
lines changed

src/app/firedancer/topology.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ fd_topo_initialize( config_t * config ) {
593593
fd_topob_tile_in ( topo, "shred", i, "metric_in", "net_shred", j, FD_TOPOB_UNRELIABLE, FD_TOPOB_POLLED ); /* No reliable consumers of networking fragments, may be dropped or overrun */
594594
FOR(shred_tile_cnt) fd_topob_tile_in ( topo, "shred", i, "metric_in", "poh_shred", 0UL, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
595595
FOR(shred_tile_cnt) fd_topob_tile_in ( topo, "shred", i, "metric_in", "stake_out", 0UL, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
596-
FOR(shred_tile_cnt) fd_topob_tile_in ( topo, "shred", 0UL, "metric_in", "gossip_out", 0UL, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
596+
FOR(shred_tile_cnt) fd_topob_tile_in ( topo, "shred", i, "metric_in", "gossip_out", 0UL, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
597597

598598
FOR(shred_tile_cnt) fd_topob_tile_out( topo, "shred", i, "shred_repair", i );
599599
FOR(shred_tile_cnt) fd_topob_tile_out( topo, "shred", i, "shred_net", i );
@@ -628,8 +628,9 @@ fd_topo_initialize( config_t * config ) {
628628
FOR(gossvf_tile_cnt) fd_topob_tile_in ( topo, "gossvf", i, "metric_in", "gossip_out", 0UL, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
629629
FOR(gossvf_tile_cnt) fd_topob_tile_in ( topo, "gossvf", i, "metric_in", "gossip_gossv", 0UL, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
630630
FOR(gossvf_tile_cnt) fd_topob_tile_in ( topo, "gossvf", i, "metric_in", "ipecho_out", 0UL, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
631+
FOR(gossvf_tile_cnt) fd_topob_tile_in ( topo, "gossvf", i, "metric_in", "stake_out", 0UL, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
631632
632-
/**/ fd_topob_tile_in ( topo, "gossip", 0UL, "metric_in", "stake_out", 0UL, FD_TOPOB_UNRELIABLE, FD_TOPOB_POLLED );
633+
/**/ fd_topob_tile_in ( topo, "gossip", 0UL, "metric_in", "stake_out", 0UL, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
633634
/**/ fd_topob_tile_out( topo, "gossip", 0UL, "gossip_out", 0UL );
634635
/**/ fd_topob_tile_out( topo, "gossip", 0UL, "gossip_net", 0UL );
635636
/**/ fd_topob_tile_in ( topo, "sign", 0UL, "metric_in", "gossip_sign", 0UL, FD_TOPOB_UNRELIABLE, FD_TOPOB_POLLED );

src/app/shared/fd_tile_unit_test.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ fd_topo_run_tile_t dummy_tile_resolv = { .name = "resolv" };
7171
fd_topo_run_tile_t dummy_tile_poh = { .name = "poh" };
7272
fd_topo_run_tile_t dummy_tile_bank = { .name = "bank" };
7373
fd_topo_run_tile_t dummy_tile_store = { .name = "store" };
74+
fd_topo_run_tile_t dummy_tile_gossvf = { .name = "gossvf" };
7475
fd_topo_run_tile_t dummy_tile_gossip = { .name = "gossip" };
7576
fd_topo_run_tile_t dummy_tile_repair = { .name = "repair" };
7677
fd_topo_run_tile_t dummy_tile_send = { .name = "send" };
@@ -111,6 +112,7 @@ fd_topo_run_tile_t * TILES[] = {
111112
&dummy_tile_poh,
112113
&dummy_tile_bank,
113114
&dummy_tile_store,
115+
&dummy_tile_gossvf,
114116
&dummy_tile_gossip,
115117
&dummy_tile_repair,
116118
&dummy_tile_send,

src/disco/verify/test_verify_tile.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ mock_topo_create( void ) {
6767

6868
mock_link_create( topo, "quic_verify" );
6969
mock_link_create( topo, "bundle_verif" );
70-
mock_link_create( topo, "gossip_verif" );
70+
mock_link_create( topo, "gossip_out" );
7171
mock_link_create( topo, "send_txns" );
7272

7373
/* Declare link ins in opposite order than IN_KIND_* to check for in
@@ -77,7 +77,7 @@ mock_topo_create( void ) {
7777
#define IN_IDX_BUNDLE 2
7878
#define IN_IDX_QUIC 3
7979
fd_topob_tile_in( topo, "verify", 0UL, "wksp", "send_txns", 0UL, 0, 1 );
80-
fd_topob_tile_in( topo, "verify", 0UL, "wksp", "gossip_verif", 0UL, 0, 1 );
80+
fd_topob_tile_in( topo, "verify", 0UL, "wksp", "gossip_out", 0UL, 0, 1 );
8181
fd_topob_tile_in( topo, "verify", 0UL, "wksp", "bundle_verif", 0UL, 0, 1 );
8282
fd_topob_tile_in( topo, "verify", 0UL, "wksp", "quic_verify", 0UL, 0, 1 );
8383

src/discof/gossip/fd_gossvf_tile.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -303,9 +303,11 @@ during_frag( fd_gossvf_tile_ctx_t * ctx,
303303
fd_memcpy( ctx->payload, payload, ctx->payload_sz );
304304
break;
305305
}
306-
case IN_KIND_REPLAY:
307-
fd_memcpy( ctx->stake.msg_buf, fd_chunk_to_laddr_const( ctx->in[ in_idx ].mem, chunk ), sz );
306+
case IN_KIND_REPLAY: {
307+
fd_stake_weight_msg_t const * msg = (fd_stake_weight_msg_t const *)fd_chunk_to_laddr( ctx->in[ in_idx ].mem, chunk );
308+
fd_memcpy( ctx->stake.msg_buf, msg, FD_STAKE_CI_STAKE_MSG_HEADER_SZ+(msg->staked_cnt*FD_STAKE_CI_STAKE_MSG_RECORD_SZ) );
308309
break;
310+
}
309311
case IN_KIND_PINGS: {
310312
fd_memcpy( ctx->_ping_update, fd_chunk_to_laddr( ctx->in[ in_idx ].mem, chunk ), sz );
311313
break;
@@ -319,8 +321,8 @@ during_frag( fd_gossvf_tile_ctx_t * ctx,
319321
}
320322

321323
static inline void
322-
handle_stakes( fd_gossvf_tile_ctx_t * ctx,
323-
fd_stake_weight_msg_t const * msg ) {
324+
handle_stakes( fd_gossvf_tile_ctx_t * ctx,
325+
fd_stake_weight_msg_t const * msg ) {
324326
fd_stake_weight_t stake_weights[ MAX_STAKED_LEADERS ];
325327
ulong new_stakes_cnt = compute_id_weights_from_vote_weights( stake_weights, msg->weights, msg->staked_cnt );
326328

@@ -945,7 +947,7 @@ after_frag( fd_gossvf_tile_ctx_t * ctx,
945947
case IN_KIND_SHRED_VERSION: break;
946948
case IN_KIND_PINGS: handle_ping_update( ctx, ctx->_ping_update ); break;
947949
case IN_KIND_GOSSIP: handle_peer_update( ctx, ctx->_gossip_update ); break;
948-
case IN_KIND_REPLAY: /* TODO ... implement stakes */ break;
950+
case IN_KIND_REPLAY: handle_stakes( ctx, (fd_stake_weight_msg_t const *) ctx->stake.msg_buf ); break;
949951
case IN_KIND_NET: {
950952
int result = handle_net( ctx, tsorig, stem );
951953
ctx->metrics.message_rx[ result ]++;

src/flamenco/gossip/Local.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ $(call run-unit-test,test_bloom)
1313
$(call make-unit-test,test_active_set,test_active_set,fd_flamenco fd_ballet fd_util)
1414
$(call run-unit-test,test_active_set)
1515

16-
$(call make-unit-test,test_ping_tracker,test_ping_tracker,fd_flamenco fd_ballet fd_util)
17-
$(call run-unit-test,test_ping_tracker)
16+
# $(call make-unit-test,test_ping_tracker,test_ping_tracker,fd_flamenco fd_ballet fd_util)
17+
# $(call run-unit-test,test_ping_tracker)
1818

1919
ifdef FD_HAS_HOSTED
2020
$(call make-fuzz-test,fuzz_gossip_msg_parse,fuzz_gossip_msg_parse,fd_flamenco fd_ballet fd_util)

src/flamenco/gossip/crds/fd_crds.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,7 @@ remove_contact_info( fd_crds_t * crds,
544544
fd_crds_entry_t * ci,
545545
long now,
546546
fd_stem_context_t * stem ) {
547+
if( FD_UNLIKELY( !stem ) ) return;
547548
fd_gossip_update_message_t * msg = fd_gossip_out_get_chunk( crds->gossip_update );
548549
msg->tag = FD_GOSSIP_UPDATE_TAG_CONTACT_INFO_REMOVE;
549550
msg->wallclock_nanos = now;
@@ -908,7 +909,7 @@ publish_update_msg( fd_crds_t * crds,
908909
uchar const * payload,
909910
long now,
910911
fd_stem_context_t * stem ) {
911-
if( FD_UNLIKELY( !crds->gossip_update ) ) return;
912+
if( FD_UNLIKELY( !stem ) ) return;
912913
if( FD_LIKELY( entry->key.tag!=FD_GOSSIP_VALUE_CONTACT_INFO &&
913914
entry->key.tag!=FD_GOSSIP_VALUE_LOWEST_SLOT &&
914915
entry->key.tag!=FD_GOSSIP_VALUE_VOTE &&
@@ -1092,7 +1093,7 @@ fd_crds_insert( fd_crds_t * crds,
10921093
crds->metrics->peer_visible_stake += candidate->stake;
10931094
}
10941095

1095-
if( FD_LIKELY( !is_from_me ) ) publish_update_msg( crds, candidate, candidate_view, payload, now, stem );
1096+
publish_update_msg( crds, candidate, candidate_view, payload, now, stem );
10961097
return candidate;
10971098
}
10981099

src/flamenco/gossip/fd_gossip_private.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ FD_STATIC_ASSERT( FD_GOSSIP_SNAPSHOT_HASHES_MAX_INCREMENTAL==25UL,
6868
"FD_GOSSIP_SNAPSHOT_HASHES_MAX_INCREMENTAL must be 25" );
6969

7070

71-
#define FD_GOSSIP_UPDATE_SZ_CONTACT_INFO (offsetof(fd_gossip_update_message_t, contact_info) + sizeof(fd_contact_info_t) + sizeof(ulong))
72-
#define FD_GOSSIP_UPDATE_SZ_CONTACT_INFO_REMOVE (offsetof(fd_gossip_update_message_t, contact_info) + sizeof(ulong))
73-
#define FD_GOSSIP_UPDATE_SZ_LOWEST_SLOT (offsetof(fd_gossip_update_message_t, lowest_slot) + sizeof(ulong))
74-
#define FD_GOSSIP_UPDATE_SZ_VOTE (offsetof(fd_gossip_update_message_t, vote) + sizeof(fd_gossip_vote_t))
75-
#define FD_GOSSIP_UPDATE_SZ_DUPLICATE_SHRED (offsetof(fd_gossip_update_message_t, duplicate_shred) + sizeof(fd_gossip_duplicate_shred_t))
76-
#define FD_GOSSIP_UPDATE_SZ_SNAPSHOT_HASHES (offsetof(fd_gossip_update_message_t, snapshot_hashes) + sizeof(fd_gossip_snapshot_hashes_t))
71+
#define FD_GOSSIP_UPDATE_SZ_CONTACT_INFO (49UL + sizeof(ulong) + sizeof(fd_contact_info_t))
72+
#define FD_GOSSIP_UPDATE_SZ_CONTACT_INFO_REMOVE (49UL + sizeof(ulong))
73+
#define FD_GOSSIP_UPDATE_SZ_LOWEST_SLOT (49UL + sizeof(ulong))
74+
#define FD_GOSSIP_UPDATE_SZ_VOTE (49UL + sizeof(fd_gossip_vote_t))
75+
#define FD_GOSSIP_UPDATE_SZ_DUPLICATE_SHRED (49UL + sizeof(fd_gossip_duplicate_shred_t))
76+
#define FD_GOSSIP_UPDATE_SZ_SNAPSHOT_HASHES (49UL + sizeof(fd_gossip_snapshot_hashes_t))
7777

7878
struct fd_gossip_view_ipaddr {
7979
uchar is_ip6;

src/flamenco/gossip/test_active_set.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,6 @@ main( int argc,
7474

7575
test_get_stake_bucket();
7676
test_push_active_set();
77+
78+
FD_LOG_NOTICE(( "pass" ));
7779
}

src/flamenco/gossip/test_bloom.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include "../../util/fd_util.h"
12
#include "fd_bloom.h"
23

34
#include <stdlib.h>
@@ -34,13 +35,13 @@ test_filters( void ) {
3435

3536
void
3637
test_add_contains( void ) {
37-
void * bytes = aligned_alloc( fd_bloom_align(), fd_bloom_footprint( 0.1, 100 ) );
38+
void * bytes = aligned_alloc( fd_bloom_align(), fd_bloom_footprint( 0.1, 100*8 ) );
3839
FD_TEST( bytes );
3940

4041
fd_rng_t _rng[1]; fd_rng_t * rng = fd_rng_join( fd_rng_new( _rng, 0U, 0UL ) );
4142
FD_TEST( rng );
4243

43-
fd_bloom_t * bloom = fd_bloom_join( fd_bloom_new( bytes, rng, 0.1, 100 ) );
44+
fd_bloom_t * bloom = fd_bloom_join( fd_bloom_new( bytes, rng, 0.1, 100*8 ) );
4445
FD_TEST( bloom );
4546

4647
fd_bloom_initialize( bloom, 100UL );

src/flamenco/gossip/test_crds_utils.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
#include "crds/fd_crds.h"
22

3+
#include <stdlib.h>
4+
5+
/* Mock gossip out context for testing */
6+
static fd_gossip_out_ctx_t test_gossip_out_ctx = {0};
7+
38
fd_crds_t *
49
create_test_crds_with_ci( fd_rng_t * rng, ulong num_peers ) {
510
ulong ele_max = 1024UL;
@@ -8,7 +13,7 @@ create_test_crds_with_ci( fd_rng_t * rng, ulong num_peers ) {
813
void * crds_mem = aligned_alloc( fd_crds_align(), fd_crds_footprint( ele_max, purged_max ) );
914
FD_TEST( crds_mem );
1015

11-
fd_crds_t * crds = fd_crds_join( fd_crds_new( crds_mem, rng, ele_max, purged_max, NULL, NULL ) );
16+
fd_crds_t * crds = fd_crds_join( fd_crds_new( crds_mem, rng, ele_max, purged_max, &test_gossip_out_ctx ) );
1217
FD_TEST( crds );
1318

1419
/* Insert test contact info entries */

0 commit comments

Comments
 (0)