Skip to content

Commit

Permalink
fix(store,tower): turbine too far ahead, shred insert root check, log
Browse files Browse the repository at this point in the history
cleanup
  • Loading branch information
lidatong committed Jul 31, 2024
1 parent ac9ac41 commit 55093eb
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 17 deletions.
11 changes: 3 additions & 8 deletions src/app/fdctl/run/tiles/fd_replay.c
Original file line number Diff line number Diff line change
Expand Up @@ -804,23 +804,18 @@ after_frag( void * _ctx,
FD_LOG_INFO(( "NOT publishing mblk to poh - slot: %lu, parent_slot: %lu, flags: %lx", ctx->curr_slot, ctx->parent_slot, ctx->flags ));
}

fd_ghost_slot_print( ctx->ghost, child->slot, 12 );
// fd_ghost_print( ctx->ghost );
fd_tower_print( ctx->tower );
fd_fork_t const * vote_fork = fd_tower_vote_fork_select( ctx->tower,
ctx->forks,
ctx->acc_mgr,
ctx->ghost );

// fd_ghost_print( ctx->ghost );
fd_ghost_slot_print( ctx->ghost, child->slot, 8 );
fd_tower_print( ctx->tower );

FD_LOG_NOTICE( ( "\n\n[Fork Selection]\n"
"# of vote accounts: %lu\n"
"reset fork: %lu\n"
"vote fork: %lu\n"
"best fork: %lu\n",
fd_tower_vote_accs_cnt( ctx->tower->vote_accs ),
!!reset_fork ? reset_fork->slot : 0,
!!vote_fork ? vote_fork->slot : 0,
fd_ghost_head( ctx->ghost )->slot ) );

ulong poh_slot = fd_fseq_query( ctx->poh_slot );
Expand Down
18 changes: 15 additions & 3 deletions src/app/fdctl/run/tiles/fd_store_int.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,17 +207,29 @@ after_frag( void * _ctx,

if( FD_UNLIKELY( in_idx==SHRED_IN_IDX ) ) {
for( ulong i = 0; i < ctx->s34_buffer->shred_cnt; i++ ) {
fd_shred_t * shred = &ctx->s34_buffer->pkts[i].shred;

if( FD_UNLIKELY( (long)(ctx->store->pending_slots->end - shred->slot) > (long)FD_PENDING_MAX ) ) {
FD_LOG_WARNING(("received shred %lu that would overrun pending queue. skipping.", shred->slot));
continue;
}

if( FD_UNLIKELY( (long)(ctx->store->curr_turbine_slot - shred->slot) > 100 ) ) {
FD_LOG_WARNING(("received shred with slot %lu that would overrun pending queue. skipping.", shred->slot));
continue;
}

// TODO: improve return value of api to not use < OK
if( fd_store_shred_insert( ctx->store, &ctx->s34_buffer->pkts[i].shred ) < FD_BLOCKSTORE_OK ) {
if( fd_store_shred_insert( ctx->store, shred ) < FD_BLOCKSTORE_OK ) {
FD_LOG_ERR(( "failed inserting to blockstore" ));
} else if ( ctx->shred_cap_ctx.is_archive ) {
uchar shred_cap_flag = FD_SHRED_CAP_FLAG_MARK_TURBINE(0);
if ( fd_shred_cap_archive(&ctx->shred_cap_ctx, &ctx->s34_buffer->pkts[i].shred, shred_cap_flag) < FD_SHRED_CAP_OK ) {
if ( fd_shred_cap_archive(&ctx->shred_cap_ctx, shred, shred_cap_flag) < FD_SHRED_CAP_OK ) {
FD_LOG_ERR(( "failed at archiving turbine shred to file" ));
}
}

fd_store_shred_update_with_shred_from_turbine( ctx->store, &ctx->s34_buffer->pkts[i].shred );
fd_store_shred_update_with_shred_from_turbine( ctx->store, shred );
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/choreo/tower/fd_tower.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,10 @@ fd_tower_lockout_check( fd_tower_t const * tower,

int lockout_check = top_vote->slot < ghost->root->slot ||
fd_ghost_is_descendant( ghost, fork->slot, top_vote->slot );
FD_LOG_NOTICE(( "[fd_tower_lockout_check] ok? %d. top: %lu. switch: %lu.",
FD_LOG_NOTICE(( "[fd_tower_lockout_check] ok? %d. top: (slot: %lu, conf: %lu). switch: %lu.",
lockout_check,
top_vote->slot,
top_vote->conf,
fork->slot ));
return lockout_check;
}
Expand Down
4 changes: 2 additions & 2 deletions src/choreo/tower/fd_tower.h
Original file line number Diff line number Diff line change
Expand Up @@ -400,8 +400,8 @@ fd_tower_print( fd_tower_t const * tower );
/* Vote state API */

/* fd_tower_vote_state_cmp compares tower with vote_state. Conceptually
this is our comparing our local view of our tower with the cluster's
view (which may be out of sync). Returns -1 if the vote_state is
this is comparing our local view of our tower with the cluster's view
(which may be out of sync). Returns -1 if the vote_state is
newer, 0 if they're in sync and 1 if the local view is newer.
Assumes both tower and vote_state are valid ie. there is a root and
there is at least one vote (verifies this with handholding enabled).
Expand Down
8 changes: 6 additions & 2 deletions src/disco/store/fd_store.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,15 +184,19 @@ fd_store_slot_prepare( fd_store_t * store,
int
fd_store_shred_insert( fd_store_t * store,
fd_shred_t const * shred ) {

fd_blockstore_t * blockstore = store->blockstore;

if (shred->slot < blockstore->root) {
return FD_BLOCKSTORE_OK;
}
uchar shred_type = fd_shred_type( shred->variant );
if( shred_type != FD_SHRED_TYPE_LEGACY_DATA
&& shred_type != FD_SHRED_TYPE_MERKLE_DATA
&& shred_type != FD_SHRED_TYPE_MERKLE_DATA_CHAINED ) {
return FD_BLOCKSTORE_OK;
}

fd_blockstore_t * blockstore = store->blockstore;

fd_blockstore_start_write( blockstore );
/* TODO remove this check when we can handle duplicate shreds and blocks */
if( fd_blockstore_block_query( blockstore, shred->slot ) != NULL ) {
Expand Down
2 changes: 1 addition & 1 deletion src/flamenco/runtime/program/fd_bpf_program_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ fd_bpf_create_bpf_program_cache_entry( fd_exec_slot_ctx_t * slot_ctx,

fd_sbpf_elf_info_t elf_info;
if( fd_sbpf_elf_peek( &elf_info, program_data, program_data_len, false ) == NULL ) {
FD_LOG_WARNING(( "fd_sbpf_elf_peek() failed: %s", fd_sbpf_strerror() ));
FD_LOG_DEBUG(( "fd_sbpf_elf_peek() failed: %s", fd_sbpf_strerror() ));
return FD_EXECUTOR_INSTR_ERR_INVALID_ACC_DATA;
}

Expand Down

0 comments on commit 55093eb

Please sign in to comment.