diff --git a/src/app/ledger/main.c b/src/app/ledger/main.c index 9d24e38677..5423388136 100644 --- a/src/app/ledger/main.c +++ b/src/app/ledger/main.c @@ -885,8 +885,7 @@ ingest( fd_ledger_args_t * args ) { } fd_blockstore_t * blockstore = args->blockstore; if( blockstore ) { - blockstore->min = blockstore->max = blockstore->lps = - blockstore->hcs = blockstore->smr = slot_ctx->slot_bank.slot; + blockstore->lps = blockstore->hcs = blockstore->smr = slot_ctx->slot_bank.slot; } if( args->funk_only ) { diff --git a/src/disco/rpcserver/fd_rpc_service.c b/src/disco/rpcserver/fd_rpc_service.c index dbe24573dd..da65005575 100644 --- a/src/disco/rpcserver/fd_rpc_service.c +++ b/src/disco/rpcserver/fd_rpc_service.c @@ -583,8 +583,8 @@ method_getBlockProduction(struct json_values* values, fd_rpc_ctx_t * ctx) { fd_webserver_t * ws = &glob->ws; fd_blockstore_t * blockstore = glob->blockstore; FD_SCRATCH_SCOPE_BEGIN { - ulong startslot = blockstore->min; - ulong endslot = blockstore->max; + ulong startslot = blockstore->smr; + ulong endslot = blockstore->lps; fd_per_epoch_info_t const * ei = glob->stake_ci->epoch_info; startslot = fd_ulong_max( startslot, fd_ulong_min( ei[0].start_slot, ei[1].start_slot ) ); @@ -663,10 +663,10 @@ method_getBlocks(struct json_values* values, fd_rpc_ctx_t * ctx) { ulong endslotn = (endslot == NULL ? ULONG_MAX : (ulong)(*(long*)endslot)); fd_blockstore_t * blockstore = ctx->global->blockstore; - if (startslotn < blockstore->min) - startslotn = blockstore->min; - if (endslotn > blockstore->max) - endslotn = blockstore->max; + if (startslotn < blockstore->smr) /* FIXME query archival file */ + startslotn = blockstore->smr; + if (endslotn > blockstore->hcs) + endslotn = blockstore->hcs; fd_web_reply_sprintf(ws, "{\"jsonrpc\":\"2.0\",\"result\":["); uint cnt = 0; @@ -715,15 +715,15 @@ method_getBlocksWithLimit(struct json_values* values, fd_rpc_ctx_t * ctx) { ulong limitn = (ulong)(*(long*)limit); fd_blockstore_t * blockstore = ctx->global->blockstore; - if (startslotn < blockstore->min) - startslotn = blockstore->min; + if (startslotn < blockstore->smr) /* FIXME query archival file */ + startslotn = blockstore->smr; if (limitn > 500000) limitn = 500000; fd_web_reply_sprintf(ws, "{\"jsonrpc\":\"2.0\",\"result\":["); uint cnt = 0; uint skips = 0; - for ( ulong i = startslotn; i <= blockstore->max && cnt < limitn && skips < 100U; ++i ) { + for ( ulong i = startslotn; i <= blockstore->lps && cnt < limitn && skips < 100U; ++i ) { fd_block_map_t meta[1]; int ret = fd_blockstore_block_map_query_volatile(blockstore, ctx->global->blockstore_fd, i, meta); if (!ret) { @@ -882,7 +882,7 @@ method_getFirstAvailableBlock(struct json_values* values, fd_rpc_ctx_t * ctx) { fd_blockstore_t * blockstore = ctx->global->blockstore; fd_webserver_t * ws = &ctx->global->ws; fd_web_reply_sprintf(ws, "{\"jsonrpc\":\"2.0\",\"result\":%lu,\"id\":%s}" CRLF, - blockstore->min, ctx->call_id); + blockstore->smr, ctx->call_id); /* FIXME archival file */ return 0; } @@ -1111,7 +1111,7 @@ method_getMaxShredInsertSlot(struct json_values* values, fd_rpc_ctx_t * ctx) { fd_blockstore_t * blockstore = ctx->global->blockstore; fd_webserver_t * ws = &ctx->global->ws; fd_web_reply_sprintf(ws, "{\"jsonrpc\":\"2.0\",\"result\":%lu,\"id\":%s}" CRLF, - blockstore->max, ctx->call_id); + blockstore->smr, ctx->call_id); /* FIXME archival file */ return 0; } @@ -1826,7 +1826,7 @@ method_minimumLedgerSlot(struct json_values* values, fd_rpc_ctx_t * ctx) { fd_rpc_global_ctx_t * glob = ctx->global; fd_webserver_t * ws = &ctx->global->ws; fd_web_reply_sprintf(ws, "{\"jsonrpc\":\"2.0\",\"result\":%lu,\"id\":%s}" CRLF, - glob->blockstore->min, ctx->call_id); + glob->blockstore->smr, ctx->call_id); /* FIXME archival file */ return 0; } diff --git a/src/flamenco/runtime/fd_blockstore.c b/src/flamenco/runtime/fd_blockstore.c index d7e4926ffc..adb18d8c9e 100644 --- a/src/flamenco/runtime/fd_blockstore.c +++ b/src/flamenco/runtime/fd_blockstore.c @@ -60,8 +60,6 @@ fd_blockstore_new( void * shmem, blockstore->off = 0; - blockstore->min = FD_SLOT_NULL; - blockstore->max = FD_SLOT_NULL; blockstore->lps = FD_SLOT_NULL; blockstore->hcs = FD_SLOT_NULL; blockstore->smr = FD_SLOT_NULL; @@ -261,8 +259,6 @@ fd_blockstore_init( fd_blockstore_t * blockstore, int fd, fd_slot_bank_t const * ulong smr = slot_bank->slot; - blockstore->min = smr; - blockstore->max = smr; blockstore->lps = smr; blockstore->hcs = smr; blockstore->smr = smr; @@ -460,19 +456,11 @@ fd_blockstore_slot_remove( fd_blockstore_t * blockstore, ulong slot ) { fd_block_map_t * block_map_entry = fd_block_map_remove( fd_blockstore_block_map( blockstore ), &slot ); if( FD_UNLIKELY( !block_map_entry ) ) return; - /* Update min */ - while( blockstore->min < blockstore->max && - fd_blockstore_block_map_query( blockstore, blockstore->min ) == NULL ) { - blockstore->min++; - } - if( slot == blockstore->min ) { - blockstore->min = slot+1; - } - /* It is not safe to remove a replaying block. */ if( FD_UNLIKELY( fd_uchar_extract_bit( block_map_entry->flags, FD_BLOCK_FLAG_REPLAYING ) ) ) { FD_LOG_WARNING(( "[%s] slot %lu has replay in progress. not removing.", __func__, slot )); + return; } /* Unlink slot from its parent only if it is not published. */ @@ -770,13 +758,6 @@ deshred( fd_blockstore_t * blockstore, ulong slot ) { block_map_entry->flags = fd_uchar_clear_bit( block_map_entry->flags, FD_BLOCK_FLAG_SHREDDING ); block_map_entry->flags = fd_uchar_set_bit( block_map_entry->flags, FD_BLOCK_FLAG_COMPLETED ); - if( slot < blockstore->min ) { - blockstore->min = slot; - } - if( slot > blockstore->max ) { - blockstore->max = blockstore->hcs = slot; - } - return FD_BLOCKSTORE_OK; case FD_SHRED_EBATCH: case FD_SHRED_EPIPE: diff --git a/src/flamenco/runtime/fd_blockstore.h b/src/flamenco/runtime/fd_blockstore.h index ef838eb76d..ffd35a34be 100644 --- a/src/flamenco/runtime/fd_blockstore.h +++ b/src/flamenco/runtime/fd_blockstore.h @@ -320,19 +320,16 @@ struct __attribute__((aligned(FD_BLOCKSTORE_ALIGN))) fd_blockstore { /* Slot metadata */ - ulong min; /* minimum slot in the blockstore with a block. we retain - blocks prior to the smr to serve repair and RPC */ - ulong max; /* maximum slot in the blockstore with a block */ ulong lps; /* latest processed slot */ ulong hcs; /* highest confirmed slot */ ulong smr; /* supermajority root. DO NOT MODIFY DIRECTLY, instead use fd_blockstore_publish */ /* Config limits */ - ulong shred_max; /* max number of temporary shreds */ - ulong block_max; /* maximum # of blocks that can be saved in memory */ - ulong idx_max; /* maximum # of blocks that can be indexed */ - ulong txn_max; /* maximum # of transactions to index */ + ulong shred_max; /* maximum # of shreds that can be held in memory */ + ulong block_max; /* maximum # of blocks that can be held in memory */ + ulong idx_max; /* maximum # of blocks that can be indexed from the archival file */ + ulong txn_max; /* maximum # of transactions that can be indexed from blocks */ ulong alloc_max; /* maximum bytes that can be allocated */ /* Owned */ @@ -522,11 +519,6 @@ fd_blockstore_block_data_laddr( fd_blockstore_t * blockstore, fd_block_t * block return fd_wksp_laddr_fast( fd_blockstore_wksp( blockstore ), block->data_gaddr ); } -FD_FN_PURE static inline ulong -fd_blockstore_block_cnt( fd_blockstore_t * blockstore ) { - return blockstore->max - blockstore->min + 1; -} - /* Query blockstore for shred at slot, shred_idx. Returns a pointer to the shred or NULL if not in * blockstore. The returned pointer lifetime is until the shred is removed. Check return value for * error info. This API only works for shreds from incomplete blocks. diff --git a/src/flamenco/runtime/fd_rocksdb.c b/src/flamenco/runtime/fd_rocksdb.c index 240de3c2fb..780d7cbb9e 100644 --- a/src/flamenco/runtime/fd_rocksdb.c +++ b/src/flamenco/runtime/fd_rocksdb.c @@ -720,9 +720,10 @@ fd_rocksdb_import_block_blockstore( fd_rocksdb_t * db, FD_TEST( blk->txns_meta_gaddr + blk->txns_meta_sz == fd_wksp_gaddr_fast( wksp, cur_laddr ) ); } - if( slot > blockstore->max ) { - blockstore->max = blockstore->hcs = slot; - } + 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 ); }