Skip to content

Commit 0b3b2b3

Browse files
committed
fix(repair): repair tile not consuming root_out
1 parent 5443c61 commit 0b3b2b3

File tree

12 files changed

+86
-30
lines changed

12 files changed

+86
-30
lines changed

src/app/firedancer-dev/commands/backtest.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include "../../../disco/metrics/fd_metrics.h"
2424
#include "../../../util/pod/fd_pod_format.h"
2525
#include "../../../discof/replay/fd_replay_notif.h"
26-
#include "../../../discof/repair/fd_reasm.h"
26+
#include "../../../discof/reasm/fd_reasm.h"
2727
#include "../../../flamenco/runtime/fd_runtime_public.h" /* FD_RUNTIME_PUBLIC_ACCOUNT_UPDATE_MSG_MTU */
2828
#include "../main.h"
2929

src/app/firedancer/topology.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include "topology.h"
22

33
#include "../../choreo/fd_choreo_base.h"
4-
#include "../../discof/repair/fd_reasm.h"
4+
#include "../../discof/reasm/fd_reasm.h"
55
#include "../../discof/replay/fd_replay_notif.h"
66
#include "../../disco/net/fd_net_tile.h"
77
#include "../../disco/quic/fd_tpu.h"
@@ -668,6 +668,7 @@ fd_topo_initialize( config_t * config ) {
668668

669669
FOR(net_tile_cnt) fd_topob_tile_in( topo, "repair", 0UL, "metric_in", "net_repair", i, FD_TOPOB_UNRELIABLE, FD_TOPOB_POLLED ); /* No reliable consumers of networking fragments, may be dropped or overrun */
670670
/**/ fd_topob_tile_in( topo, "repair", 0UL, "metric_in", "gossip_repai", 0UL, FD_TOPOB_UNRELIABLE, FD_TOPOB_POLLED );
671+
/**/ fd_topob_tile_in( topo, "repair", 0UL, "metric_in", "root_out", 0UL, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
671672
/**/ fd_topob_tile_in( topo, "repair", 0UL, "metric_in", "stake_out", 0UL, FD_TOPOB_UNRELIABLE, FD_TOPOB_POLLED );
672673
fd_topob_tile_in( topo, "repair", 0UL, "metric_in", "snap_out", 0UL, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );
673674
FOR(shred_tile_cnt) fd_topob_tile_in( topo, "repair", 0UL, "metric_in", "shred_repair", i, FD_TOPOB_RELIABLE, FD_TOPOB_POLLED );

src/discof/backtest/fd_backtest_tile.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include "../../disco/store/fd_store.h"
99
#include "../../disco/topo/fd_topo.h"
1010
#include "../../discof/fd_discof.h"
11-
#include "../../discof/repair/fd_reasm.h"
11+
#include "../../discof/reasm/fd_reasm.h"
1212
#include "../../discof/replay/fd_replay_notif.h"
1313
#include "../../flamenco/runtime/fd_rocksdb.h"
1414
#include "../../util/pod/fd_pod_format.h"

src/discof/reasm/Local.mk

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
ifdef FD_HAS_INT128
2+
$(call add-objs,fd_reasm,fd_discof)
3+
ifdef FD_HAS_HOSTED
4+
$(call make-unit-test,test_reasm,test_reasm,fd_discof fd_flamenco fd_ballet fd_util)
5+
$(call run-unit-test,test_reasm)
6+
endif
7+
endif

src/discof/repair/fd_reasm.c renamed to src/discof/reasm/fd_reasm.c

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,13 +337,13 @@ fd_reasm_fec_t *
337337
fd_reasm_publish( fd_reasm_t * reasm, fd_hash_t const * merkle_root ) {
338338
# if FD_REASM_USE_HANDHOLDING
339339
if( FD_UNLIKELY( !pool_ele( reasm->pool, reasm->root ) ) ) { FD_LOG_WARNING(( "missing root" )); return NULL; }
340-
if( FD_UNLIKELY( !pool_ele( reasm->pool, reasm->root ) ) ) { FD_LOG_WARNING(( "merkle root %s not found", FD_BASE58_ENC_32_ALLOCA( merkle_root ) )); return NULL; }
340+
if( FD_UNLIKELY( !fd_reasm_query( reasm, merkle_root ) ) ) { FD_LOG_WARNING(( "merkle root %s not found", FD_BASE58_ENC_32_ALLOCA( merkle_root ) )); return NULL; }
341341
# endif
342342

343343
fd_reasm_fec_t * pool = reasm->pool;
344344
ulong null = pool_idx_null( pool );
345345
fd_reasm_fec_t * oldr = pool_ele( pool, reasm->root );
346-
fd_reasm_fec_t * newr = pool_ele( pool, reasm->root );
346+
fd_reasm_fec_t * newr = fd_reasm_query( reasm, merkle_root );
347347

348348
/* First, remove the previous root, and push it as the first element
349349
of the BFS queue. */
@@ -373,3 +373,36 @@ fd_reasm_publish( fd_reasm_t * reasm, fd_hash_t const * merkle_root ) {
373373
reasm->root = pool_idx( pool, newr ); /* replace with new root */
374374
return newr;
375375
}
376+
377+
#include <stdio.h>
378+
379+
static void
380+
print( fd_reasm_t const * reasm, fd_reasm_fec_t const * fec, int space, const char * prefix ) {
381+
fd_reasm_fec_t * pool = reasm->pool;
382+
383+
if( fec == NULL ) return;
384+
385+
if( space > 0 ) printf( "\n" );
386+
for( int i = 0; i < space; i++ ) printf( " " );
387+
printf( "%s%s", prefix, FD_BASE58_ENC_32_ALLOCA( &fec->key ) );
388+
389+
fd_reasm_fec_t const * curr = pool_ele_const( pool, fec->child );
390+
char new_prefix[1024]; /* FIXME size this correctly */
391+
while( curr ) {
392+
if( pool_ele_const( pool, curr->sibling ) ) {
393+
sprintf( new_prefix, "├── " ); /* branch indicating more siblings follow */
394+
print( reasm, curr, space + 4, new_prefix );
395+
} else {
396+
sprintf( new_prefix, "└── " ); /* end branch */
397+
print( reasm, curr, space + 4, new_prefix );
398+
}
399+
curr = pool_ele_const( pool, curr->sibling );
400+
}
401+
}
402+
403+
void
404+
fd_reasm_print( fd_reasm_t const * reasm ) {
405+
FD_LOG_NOTICE( ( "\n\n[reasm]" ) );
406+
print( reasm, pool_ele_const( reasm->pool, reasm->root ), 0, "" );
407+
printf( "\n\n" );
408+
}

src/discof/repair/fd_reasm.h renamed to src/discof/reasm/fd_reasm.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,8 @@ fd_reasm_leave( fd_reasm_t * reasm );
251251
void *
252252
fd_reasm_delete( void * reasm );
253253

254-
/* fd_reasm_{query,query_const} returns a pointer to the current root of
255-
of the reasm. Returns NULL if there is no root. */
254+
/* fd_reasm_root returns a pointer to the current root of of the reasm,
255+
NULL if there is no root. */
256256

257257
fd_reasm_fec_t *
258258
fd_reasm_root( fd_reasm_t * reasm );
@@ -262,8 +262,8 @@ fd_reasm_root( fd_reasm_t * reasm );
262262
ulong
263263
fd_reasm_slot0( fd_reasm_t * reasm );
264264

265-
/* fd_reasm_{query,query_const} queries the FEC set keyed by merkle.
266-
Returns a pointer to the fd_reasm_fec_t if found, NULL otherwise. */
265+
/* fd_reasm_query returns a pointer to the ele keyed by merkle_root if
266+
found, NULL otherwise. */
267267

268268
fd_reasm_fec_t *
269269
fd_reasm_query( fd_reasm_t * reasm, fd_hash_t const * merkle_root );
@@ -311,6 +311,9 @@ fd_reasm_insert( fd_reasm_t * reasm,
311311
fd_reasm_fec_t *
312312
fd_reasm_publish( fd_reasm_t * reasm, fd_hash_t const * merkle_root );
313313

314+
void
315+
fd_reasm_print( fd_reasm_t const * reasm );
316+
314317
FD_PROTOTYPES_END
315318

316319
#endif /* HEADER_fd_src_discof_repair_fd_reasm_h */

src/discof/repair/test_reasm.c renamed to src/discof/reasm/test_reasm.c

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,18 @@ test_insert( fd_wksp_t * wksp ) {
3232

3333
/* Receive (0, 64) -> (1, 32) -> (1, 0) -> (2, 0) -> (3, 64) -> (2, 32) -> (3, 32) -> (3, 0) */
3434

35-
fd_hash_t mrnull[1] = {{{ 0 }}};
36-
fd_hash_t mr0_64[1] = {{{ 1 }}};
37-
fd_hash_t mr1_00[1] = {{{ 2 }}};
38-
fd_hash_t mr1_32[1] = {{{ 3 }}};
39-
fd_hash_t mr2_00[1] = {{{ 4 }}};
40-
fd_hash_t mr2_32[1] = {{{ 5 }}};
41-
fd_hash_t mr3_00[1] = {{{ 6 }}};
42-
fd_hash_t mr3_32[1] = {{{ 7 }}};
43-
fd_hash_t mr3_64[1] = {{{ 8 }}};
44-
45-
fd_reasm_fec_t * f0_64 = fd_reasm_insert( reasm, mr0_64, mrnull, 0, 64, 1, 32, 1, 1 );
35+
fd_hash_t mr0_64[1] = {{{ 0 }}};
36+
fd_hash_t mr1_00[1] = {{{ 1 }}};
37+
fd_hash_t mr1_32[1] = {{{ 2 }}};
38+
fd_hash_t mr2_00[1] = {{{ 3 }}};
39+
fd_hash_t mr2_32[1] = {{{ 4 }}};
40+
fd_hash_t mr3_00[1] = {{{ 5 }}};
41+
fd_hash_t mr3_32[1] = {{{ 6 }}};
42+
fd_hash_t mr3_64[1] = {{{ 7 }}};
43+
44+
fd_reasm_init( reasm, mr0_64, 0 );
45+
fd_reasm_fec_t * f0_64 = fd_reasm_query( reasm, mr0_64 );
46+
FD_TEST( f0_64 );
4647
FD_TEST( frontier_ele_query( frontier, &f0_64->key, NULL, pool ) == f0_64 );
4748

4849
fd_reasm_fec_t * f1_32 = fd_reasm_insert( reasm, mr1_32, mr1_00, 1, 32, 1, 32, 1, 1 );
@@ -135,7 +136,7 @@ test_publish( fd_wksp_t * wksp ){
135136

136137
/* Set the root (snapshot slot). */
137138

138-
fd_reasm_insert( reasm, mr0, mr0, 0, 0, 0, 0, 1, 1 );
139+
fd_reasm_init( reasm, mr0, 0 );
139140

140141
/* Typical startup behavior, turbine orphan FECs added. */
141142

@@ -164,9 +165,12 @@ test_publish( fd_wksp_t * wksp ){
164165

165166
/* Publish. */
166167

168+
fd_reasm_fec_t * oldr = fd_reasm_root( reasm );
169+
FD_TEST( oldr );
167170
fd_reasm_publish( reasm, mr2 );
168-
fd_reasm_fec_t * root = pool_ele( reasm->pool, reasm->root );
169-
FD_TEST( 0==memcmp( root, mr2, sizeof(fd_hash_t) ) );
171+
fd_reasm_fec_t * newr = fd_reasm_root( reasm );
172+
FD_TEST( newr );
173+
FD_TEST( 0==memcmp( newr, mr2, sizeof(fd_hash_t) ) );
170174
FD_TEST( ancestry_ele_query( reasm->ancestry, mr2, NULL, reasm->pool ) != NULL );
171175
FD_TEST( frontier_ele_query( reasm->frontier, mr4, NULL, reasm->pool ) != NULL );
172176
FD_TEST( !fd_reasm_query( reasm, mr0 ) );

src/discof/repair/Local.mk

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
ifdef FD_HAS_INT128
2-
$(call add-objs,fd_reasm,fd_discof)
32
$(call add-objs,fd_repair_tile,fd_discof)
4-
$(call make-unit-test,test_reasm,test_reasm,fd_discof fd_flamenco fd_ballet fd_util)
53
endif

src/discof/repair/fd_repair_tile.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include "../../util/net/fd_net_headers.h"
1818

1919
#include "../forest/fd_forest.h"
20-
#include "fd_reasm.h"
20+
#include "../reasm/fd_reasm.h"
2121

2222
#define IN_KIND_CONTACT (0)
2323
#define IN_KIND_NET (1)
@@ -458,6 +458,10 @@ during_frag( fd_repair_tile_ctx_t * ctx,
458458
dcache_entry = fd_chunk_to_laddr_const( in_ctx->mem, chunk );
459459
dcache_entry_sz = sz * sizeof(fd_shred_dest_wire_t);
460460

461+
} else if( FD_UNLIKELY( in_kind==IN_KIND_ROOT ) ) {
462+
memcpy( ctx->root_block_id.uc, fd_chunk_to_laddr_const( in_ctx->mem, chunk ), sizeof(fd_hash_t) );
463+
return;
464+
461465
} else if( FD_UNLIKELY( in_kind==IN_KIND_STAKE ) ) {
462466
if( FD_UNLIKELY( chunk<in_ctx->chunk0 || chunk>in_ctx->wmark ) ) {
463467
FD_LOG_ERR(( "chunk %lu %lu corrupt, not in range [%lu,%lu]", chunk, sz, in_ctx->chunk0, in_ctx->wmark ));
@@ -513,7 +517,7 @@ static void
513517
after_frag( fd_repair_tile_ctx_t * ctx,
514518
ulong in_idx,
515519
ulong seq FD_PARAM_UNUSED,
516-
ulong sig FD_PARAM_UNUSED,
520+
ulong sig,
517521
ulong sz,
518522
ulong tsorig FD_PARAM_UNUSED,
519523
ulong tspub FD_PARAM_UNUSED,
@@ -672,9 +676,12 @@ after_credit( fd_repair_tile_ctx_t * ctx,
672676

673677
fd_reasm_fec_t * rfec = fd_reasm_next( ctx->reasm );
674678
if( FD_LIKELY( rfec ) ) {
675-
if( FD_LIKELY( ctx->store ) ) {
679+
680+
if( FD_LIKELY( ctx->store ) ) { /* some topologies don't run with store */
681+
676682
/* Linking only requires a shared lock because the fields that are
677683
modified are only read on publish which uses exclusive lock. */
684+
678685
long shacq_start, shacq_end, shrel_end;
679686

680687
FD_STORE_SHACQ_TIMED( ctx->store, shacq_start, shacq_end );

0 commit comments

Comments
 (0)