Skip to content

Commit c30ea13

Browse files
committed
backtest: link merkle root with parent
1 parent b2f2f3d commit c30ea13

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

src/disco/store/fd_store.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ static const fd_hash_t hash_null = { 0 };
1010
void *
1111
fd_store_new( void * shmem, ulong fec_max, ulong part_cnt ) {
1212

13-
if( FD_UNLIKELY( part_cnt == 0UL ) ) {
14-
FD_LOG_ERR(( "partition count must be greater than 0, should match the number of writers/shred tiles" ));
13+
if( FD_UNLIKELY( part_cnt==0UL ) ) {
14+
FD_LOG_WARNING(( "partition count must be greater than 0, should match the number of writers/shred tiles" ));
1515
return NULL;
1616
}
1717

@@ -143,7 +143,7 @@ fd_store_insert( fd_store_t * store,
143143
fd_store_fec_t * fec = fd_store_pool_acquire( &pool, NULL, BLOCKING, &err );
144144

145145
if( FD_UNLIKELY( err == FD_POOL_ERR_EMPTY ) ) { FD_LOG_WARNING(( "store full %s", fd_store_pool_strerror( err ) )); return NULL; } /* FIXME: eviction? max bound guaranteed for worst-case? */
146-
if( FD_UNLIKELY( err == FD_POOL_ERR_CORRUPT ) ) { FD_LOG_ERR (( "store corrupt %s", fd_store_pool_strerror( err ) )); return NULL; }
146+
if( FD_UNLIKELY( err == FD_POOL_ERR_CORRUPT ) ) { FD_LOG_WARNING(( "store corrupt %s", fd_store_pool_strerror( err ) )); return NULL; }
147147
FD_TEST( fec );
148148

149149
fec->key.mr = *merkle_root;
@@ -217,7 +217,11 @@ fd_store_publish( fd_store_t * store,
217217
child = fd_store_pool_ele( &pool, child->sibling ); /* right-sibling */
218218
}
219219
fd_store_fec_t * next = fd_store_pool_ele( &pool, head->next ); /* pophead */
220-
fd_store_pool_release( &pool, head, BLOCKING ); /* release */
220+
int err = fd_store_pool_release( &pool, head, BLOCKING ); /* release */
221+
if( FD_UNLIKELY( err != FD_POOL_SUCCESS ) ) {
222+
FD_LOG_WARNING(( "failed to release fec %s", fd_store_pool_strerror( err ) ));
223+
return NULL;
224+
}
221225
head = next; /* advance */
222226
}
223227
newr->parent = null; /* unlink old root */

src/discof/backtest/fd_backtest_tile.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ typedef struct {
102102
fd_store_t * store;
103103
fd_tower_t * tower;
104104
fd_shred_t const * curr;
105+
fd_hash_t prev_mr;
105106

106107
/* is_ready is used to determine if the backtest tile should send
107108
more fec sets to the replay tile. is_ready==1 if more fec sets
@@ -323,6 +324,7 @@ unprivileged_init( fd_topo_t * topo,
323324
ctx->slot_cnt = 0UL;
324325

325326
ctx->curr = NULL;
327+
ctx->prev_mr = (fd_hash_t){0};
326328

327329
ctx->is_ready = 1;
328330

@@ -391,6 +393,19 @@ after_credit_rocksdb( ctx_t * ctx,
391393
if( FD_UNLIKELY( !curr || curr->fec_set_idx != prev->fec_set_idx || curr->slot != prev->slot ) ) break;
392394
}
393395
FD_TEST( prev );
396+
397+
/* Link the merkle roots here; as this step usually occurs in repair */
398+
fd_store_exacq ( ctx->store );
399+
fd_store_link( ctx->store, &mr, &ctx->prev_mr );
400+
fd_store_exrel( ctx->store );
401+
402+
/* Instead of using the shred->chained_mr, there's a known issue with
403+
fd where it might produce a bad chained mr for the first FEC set in
404+
a slot of it's leader window. So best to just track the previous
405+
merkle root directly. */
406+
407+
ctx->prev_mr = mr;
408+
394409
fd_fec_out_t out = {
395410
.err = FD_FEC_CHAINER_SUCCESS,
396411
.merkle_root = mr,

0 commit comments

Comments
 (0)