Skip to content

Commit

Permalink
fix(ledger): blockstore import
Browse files Browse the repository at this point in the history
  • Loading branch information
lidatong committed Dec 6, 2024
1 parent 05093dd commit f1d3c93
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
5 changes: 0 additions & 5 deletions src/app/ledger/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,6 @@ runtime_replay( fd_ledger_args_t * ledger_args ) {
if( FD_UNLIKELY( err ) ) {
FD_LOG_ERR(( "Failed to import block %lu", start_slot ));
}

/* Publish this block */
fd_blockstore_start_write( blockstore );
fd_blockstore_publish( blockstore, -1, slot );
fd_blockstore_end_write( blockstore );
}

fd_blockstore_start_read( blockstore );
Expand Down
4 changes: 2 additions & 2 deletions src/flamenco/runtime/fd_blockstore.c
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ deshred( fd_blockstore_t * blockstore, ulong slot ) {
micros[block->micros_cnt - 1].off );
memcpy( &block_map_entry->block_hash, last_micro->hash, sizeof( fd_hash_t ) );

block_map_entry->flags = fd_uchar_clear_bit( block_map_entry->flags, FD_BLOCK_FLAG_SHREDDING );
block_map_entry->flags = fd_uchar_clear_bit( block_map_entry->flags, FD_BLOCK_FLAG_RECEIVING );
block_map_entry->flags = fd_uchar_set_bit( block_map_entry->flags, FD_BLOCK_FLAG_COMPLETED );

return FD_BLOCKSTORE_OK;
Expand Down Expand Up @@ -889,7 +889,7 @@ fd_buf_shred_insert( fd_blockstore_t * blockstore, fd_shred_t const * shred ) {
block_map_entry->height = 0;
block_map_entry->block_hash = ( fd_hash_t ){ 0 };
block_map_entry->bank_hash = ( fd_hash_t ){ 0 };
block_map_entry->flags = fd_uchar_set_bit( 0, FD_BLOCK_FLAG_SHREDDING );
block_map_entry->flags = fd_uchar_set_bit( 0, FD_BLOCK_FLAG_RECEIVING );
block_map_entry->ts = 0;
block_map_entry->reference_tick = (uchar)( (int)shred->data.flags &
(int)FD_SHRED_DATA_REF_TICK_MASK );
Expand Down
4 changes: 2 additions & 2 deletions src/flamenco/runtime/fd_blockstore.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ typedef struct fd_block_txn fd_block_txn_t;
Other flags mainly provide useful metadata for read-only callers, eg.
RPC. */

#define FD_BLOCK_FLAG_SHREDDING 0 /* xxxxxxx1 still receiving shreds */
#define FD_BLOCK_FLAG_COMPLETED 1 /* xxxxxx1x received all shreds (DATA_COMPLETE) */
#define FD_BLOCK_FLAG_RECEIVING 0 /* xxxxxxx1 still receiving shreds */
#define FD_BLOCK_FLAG_COMPLETED 1 /* xxxxxx1x received the block ie. all shreds (SLOT_COMPLETE) */
#define FD_BLOCK_FLAG_REPLAYING 2 /* xxxxx1xx replay in progress (DO NOT REMOVE) */
#define FD_BLOCK_FLAG_PROCESSED 3 /* xxxx1xxx successfully replayed the block */
#define FD_BLOCK_FLAG_EQVOCSAFE 4 /* xxxx1xxx 52% of cluster has voted on this (slot, bank hash) */
Expand Down
14 changes: 13 additions & 1 deletion src/flamenco/runtime/fd_rocksdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -722,9 +722,21 @@ fd_rocksdb_import_block_blockstore( fd_rocksdb_t * db,

blockstore->lps = slot;
blockstore->hcs = slot;
blockstore->smr = slot;

if( FD_LIKELY( block_map_entry ) ) {
block_map_entry->flags = fd_uchar_set_bit( block_map_entry->flags, FD_BLOCK_FLAG_COMPLETED );
block_map_entry->flags =
fd_uchar_set_bit(
fd_uchar_set_bit(
fd_uchar_set_bit(
fd_uchar_set_bit(
fd_uchar_set_bit(
block_map_entry->flags,
FD_BLOCK_FLAG_COMPLETED ),
FD_BLOCK_FLAG_PROCESSED ),
FD_BLOCK_FLAG_EQVOCSAFE ),
FD_BLOCK_FLAG_CONFIRMED ),
FD_BLOCK_FLAG_FINALIZED );
}

fd_blockstore_end_write(blockstore);
Expand Down

0 comments on commit f1d3c93

Please sign in to comment.