From f1d3c93f661a578af00448a0514a6a76873bcbcf Mon Sep 17 00:00:00 2001 From: Charles Li Date: Fri, 6 Dec 2024 15:18:21 +0000 Subject: [PATCH] fix(ledger): blockstore import --- src/app/ledger/main.c | 5 ----- src/flamenco/runtime/fd_blockstore.c | 4 ++-- src/flamenco/runtime/fd_blockstore.h | 4 ++-- src/flamenco/runtime/fd_rocksdb.c | 14 +++++++++++++- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/app/ledger/main.c b/src/app/ledger/main.c index fda1eafcff..cf8ebba632 100644 --- a/src/app/ledger/main.c +++ b/src/app/ledger/main.c @@ -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 ); diff --git a/src/flamenco/runtime/fd_blockstore.c b/src/flamenco/runtime/fd_blockstore.c index 940289ab2c..153047bf16 100644 --- a/src/flamenco/runtime/fd_blockstore.c +++ b/src/flamenco/runtime/fd_blockstore.c @@ -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; @@ -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 ); diff --git a/src/flamenco/runtime/fd_blockstore.h b/src/flamenco/runtime/fd_blockstore.h index ffd35a34be..bcc7d05526 100644 --- a/src/flamenco/runtime/fd_blockstore.h +++ b/src/flamenco/runtime/fd_blockstore.h @@ -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) */ diff --git a/src/flamenco/runtime/fd_rocksdb.c b/src/flamenco/runtime/fd_rocksdb.c index 46b7acd9d6..aa9d912997 100644 --- a/src/flamenco/runtime/fd_rocksdb.c +++ b/src/flamenco/runtime/fd_rocksdb.c @@ -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);