77#include "../../flamenco/runtime/fd_runtime_public.h"
88#include "../../flamenco/runtime/fd_rocksdb.h"
99#include "../../flamenco/runtime/fd_txncache.h"
10+ #include "../../flamenco/runtime/fd_bank_mgr.h"
1011#include "../../flamenco/rewards/fd_rewards.h"
1112#include "../../ballet/base58/fd_base58.h"
1213#include "../../flamenco/runtime/context/fd_capture_ctx.h"
@@ -291,7 +292,7 @@ runtime_replay( fd_ledger_args_t * ledger_args ) {
291292
292293 fd_features_restore ( ledger_args -> slot_ctx , ledger_args -> runtime_spad );
293294
294- fd_runtime_update_leaders ( ledger_args -> slot_ctx , ledger_args -> slot_ctx -> slot_bank . slot , ledger_args -> runtime_spad );
295+ fd_runtime_update_leaders ( ledger_args -> slot_ctx , ledger_args -> slot_ctx -> slot , ledger_args -> runtime_spad );
295296
296297 fd_calculate_epoch_accounts_hash_values ( ledger_args -> slot_ctx );
297298
@@ -300,8 +301,8 @@ runtime_replay( fd_ledger_args_t * ledger_args ) {
300301 ulong slot_cnt = 0 ;
301302 fd_blockstore_t * blockstore = ledger_args -> slot_ctx -> blockstore ;
302303
303- ulong prev_slot = ledger_args -> slot_ctx -> slot_bank . slot ;
304- ulong start_slot = ledger_args -> slot_ctx -> slot_bank . slot + 1 ;
304+ ulong prev_slot = ledger_args -> slot_ctx -> slot ;
305+ ulong start_slot = ledger_args -> slot_ctx -> slot + 1 ;
305306
306307 ledger_args -> slot_ctx -> root_slot = prev_slot ;
307308
@@ -350,7 +351,6 @@ runtime_replay( fd_ledger_args_t * ledger_args ) {
350351 for ( ulong slot = start_slot ; slot <=ledger_args -> end_slot && !aborted ; ++ slot ) {
351352
352353 ledger_args -> slot_ctx -> slot_bank .prev_slot = prev_slot ;
353- ledger_args -> slot_ctx -> slot_bank .slot = slot ;
354354
355355 FD_LOG_DEBUG (( "reading slot %lu" , slot ));
356356
@@ -405,10 +405,18 @@ runtime_replay( fd_ledger_args_t * ledger_args ) {
405405 continue ;
406406 }
407407
408- ledger_args -> slot_ctx -> slot_bank .tick_height = ledger_args -> slot_ctx -> slot_bank .max_tick_height ;
409- if ( FD_UNLIKELY ( FD_RUNTIME_EXECUTE_SUCCESS != fd_runtime_compute_max_tick_height ( ledger_args -> epoch_ctx -> epoch_bank .ticks_per_slot , slot , & ledger_args -> slot_ctx -> slot_bank .max_tick_height ) ) ) {
410- FD_LOG_ERR (( "couldn't compute max tick height slot %lu ticks_per_slot %lu" , slot , ledger_args -> epoch_ctx -> epoch_bank .ticks_per_slot ));
408+ ulong * max_tick_height = fd_bank_mgr_max_tick_height_query ( ledger_args -> slot_ctx -> bank_mgr );
409+ ulong * ticks_per_slot = fd_bank_mgr_ticks_per_slot_query ( ledger_args -> slot_ctx -> bank_mgr );
410+ ulong * tick_height = fd_bank_mgr_tick_height_modify ( ledger_args -> slot_ctx -> bank_mgr );
411+ * tick_height = * max_tick_height ;
412+ fd_bank_mgr_tick_height_save ( ledger_args -> slot_ctx -> bank_mgr );
413+
414+ max_tick_height = fd_bank_mgr_max_tick_height_modify ( ledger_args -> slot_ctx -> bank_mgr );
415+
416+ if ( FD_UNLIKELY ( FD_RUNTIME_EXECUTE_SUCCESS != fd_runtime_compute_max_tick_height ( * ticks_per_slot , slot , max_tick_height ) ) ) {
417+ FD_LOG_ERR (( "couldn't compute max tick height slot %lu ticks_per_slot %lu" , slot , * ticks_per_slot ));
411418 }
419+ fd_bank_mgr_max_tick_height_save ( ledger_args -> slot_ctx -> bank_mgr );
412420
413421 if ( ledger_args -> slot_ctx -> root_slot %ledger_args -> snapshot_freq == 0UL && !ledger_args -> is_snapshotting ) {
414422
@@ -455,8 +463,9 @@ runtime_replay( fd_ledger_args_t * ledger_args ) {
455463 }
456464
457465 ulong blk_txn_cnt = 0UL ;
458- FD_LOG_NOTICE (( "Used memory in spad before slot=%lu %lu" , ledger_args -> slot_ctx -> slot_bank . slot , ledger_args -> runtime_spad -> mem_used ));
466+ FD_LOG_NOTICE (( "Used memory in spad before slot=%lu %lu" , slot , ledger_args -> runtime_spad -> mem_used ));
459467 FD_TEST ( fd_runtime_block_eval_tpool ( ledger_args -> slot_ctx ,
468+ slot ,
460469 blk ,
461470 ledger_args -> capture_ctx ,
462471 ledger_args -> tpool ,
@@ -471,11 +480,11 @@ runtime_replay( fd_ledger_args_t * ledger_args ) {
471480 fd_hash_t expected ;
472481 int err = fd_blockstore_block_hash_query ( blockstore , slot , & expected );
473482 if ( FD_UNLIKELY ( err ) ) FD_LOG_ERR ( ( "slot %lu is missing its hash" , slot ) );
474- else if ( FD_UNLIKELY ( 0 != memcmp ( ledger_args -> slot_ctx -> slot_bank . poh . hash , expected .hash , 32UL ) ) ) {
483+ else if ( FD_UNLIKELY ( 0 != memcmp ( fd_bank_mgr_poh_query ( ledger_args -> slot_ctx -> bank_mgr ) -> hash , expected .hash , sizeof ( fd_hash_t ) ) ) ) {
475484 char expected_hash [ FD_BASE58_ENCODED_32_SZ ];
476485 fd_acct_addr_cstr ( expected_hash , expected .hash );
477486 char poh_hash [ FD_BASE58_ENCODED_32_SZ ];
478- fd_acct_addr_cstr ( poh_hash , ledger_args -> slot_ctx -> slot_bank . poh . hash );
487+ fd_acct_addr_cstr ( poh_hash , fd_bank_mgr_poh_query ( ledger_args -> slot_ctx -> bank_mgr ) -> hash );
479488 FD_LOG_WARNING (( "PoH hash mismatch! slot=%lu expected=%s, got=%s" ,
480489 slot ,
481490 expected_hash ,
@@ -718,7 +727,7 @@ fd_ledger_main_setup( fd_ledger_args_t * args ) {
718727
719728 /* Finish other runtime setup steps */
720729 fd_features_restore ( args -> slot_ctx , args -> runtime_spad );
721- fd_runtime_update_leaders ( args -> slot_ctx , args -> slot_ctx -> slot_bank . slot , args -> runtime_spad );
730+ fd_runtime_update_leaders ( args -> slot_ctx , args -> slot_ctx -> slot , args -> runtime_spad );
722731 fd_calculate_epoch_accounts_hash_values ( args -> slot_ctx );
723732
724733 fd_exec_para_cb_ctx_t exec_para_ctx = {
@@ -1156,11 +1165,11 @@ ingest( fd_ledger_args_t * args ) {
11561165
11571166 /* At this point the account state has been ingested into funk. Intake rocksdb */
11581167 if ( args -> start_slot == 0 ) {
1159- args -> start_slot = slot_ctx -> slot_bank . slot + 1 ;
1168+ args -> start_slot = slot_ctx -> slot + 1 ;
11601169 }
11611170 fd_blockstore_t * blockstore = args -> blockstore ;
11621171 if ( blockstore ) {
1163- blockstore -> shmem -> lps = blockstore -> shmem -> hcs = blockstore -> shmem -> wmk = slot_ctx -> slot_bank . slot ;
1172+ blockstore -> shmem -> lps = blockstore -> shmem -> hcs = blockstore -> shmem -> wmk = slot_ctx -> slot ;
11641173 }
11651174
11661175 if ( args -> funk_only ) {
@@ -1169,8 +1178,8 @@ ingest( fd_ledger_args_t * args ) {
11691178 FD_LOG_NOTICE (( "using shredcap" ));
11701179 fd_shredcap_populate_blockstore ( args -> shredcap , blockstore , args -> start_slot , args -> end_slot );
11711180 } else if ( args -> rocksdb_list [ 0UL ] ) {
1172- if ( args -> end_slot >= slot_ctx -> slot_bank . slot + args -> slot_history_max ) {
1173- args -> end_slot = slot_ctx -> slot_bank . slot + args -> slot_history_max - 1 ;
1181+ if ( args -> end_slot >= slot_ctx -> slot + args -> slot_history_max ) {
1182+ args -> end_slot = slot_ctx -> slot + args -> slot_history_max - 1 ;
11741183 }
11751184 ingest_rocksdb ( args -> rocksdb_list [ 0UL ], args -> start_slot , args -> end_slot ,
11761185 blockstore , args -> copy_txn_status , args -> trash_hash , args -> valloc );
@@ -1269,24 +1278,31 @@ replay( fd_ledger_args_t * args ) {
12691278 fd_exec_epoch_ctx_bank_mem_clear ( args -> epoch_ctx );
12701279
12711280 /* TODO: This is very hacky, needs to be cleaned up */
1272- args -> epoch_ctx -> epoch_bank .cluster_version [0 ] = args -> cluster_version [0 ];
1273- args -> epoch_ctx -> epoch_bank .cluster_version [1 ] = args -> cluster_version [1 ];
1274- args -> epoch_ctx -> epoch_bank .cluster_version [2 ] = args -> cluster_version [2 ];
1281+
1282+ void * slot_ctx_mem = fd_spad_alloc_check ( spad , FD_EXEC_SLOT_CTX_ALIGN , FD_EXEC_SLOT_CTX_FOOTPRINT );
1283+ args -> slot_ctx = fd_exec_slot_ctx_join ( fd_exec_slot_ctx_new ( slot_ctx_mem , spad ) );
1284+ args -> slot_ctx -> epoch_ctx = args -> epoch_ctx ;
1285+ args -> slot_ctx -> funk = funk ;
1286+ args -> slot_ctx -> blockstore = args -> blockstore ;
1287+
1288+ FD_TEST ( args -> slot_ctx -> bank_mgr_mem );
1289+ args -> slot_ctx -> bank_mgr = fd_bank_mgr_join ( fd_bank_mgr_new ( args -> slot_ctx -> bank_mgr_mem ), funk , NULL );
1290+
1291+ fd_cluster_version_t * cluster_version = fd_bank_mgr_cluster_version_modify ( args -> slot_ctx -> bank_mgr );
1292+
1293+ cluster_version -> major = args -> cluster_version [0 ];
1294+ cluster_version -> minor = args -> cluster_version [1 ];
1295+ cluster_version -> patch = args -> cluster_version [2 ];
1296+ fd_bank_mgr_cluster_version_save ( args -> slot_ctx -> bank_mgr );
12751297
12761298 args -> epoch_ctx -> runtime_public = runtime_public ;
12771299
1278- fd_features_enable_cleaned_up ( & args -> epoch_ctx -> features , args -> epoch_ctx -> epoch_bank . cluster_version );
1300+ fd_features_enable_cleaned_up ( & args -> epoch_ctx -> features , cluster_version );
12791301 fd_features_enable_one_offs ( & args -> epoch_ctx -> features , args -> one_off_features , args -> one_off_features_cnt , 0UL );
12801302
12811303 // activate them
12821304 fd_memcpy ( & args -> epoch_ctx -> runtime_public -> features , & args -> epoch_ctx -> features , sizeof (fd_features_t ) );
12831305
1284- void * slot_ctx_mem = fd_spad_alloc_check ( spad , FD_EXEC_SLOT_CTX_ALIGN , FD_EXEC_SLOT_CTX_FOOTPRINT );
1285- args -> slot_ctx = fd_exec_slot_ctx_join ( fd_exec_slot_ctx_new ( slot_ctx_mem , spad ) );
1286- args -> slot_ctx -> epoch_ctx = args -> epoch_ctx ;
1287- args -> slot_ctx -> funk = funk ;
1288- args -> slot_ctx -> blockstore = args -> blockstore ;
1289-
12901306 void * status_cache_mem = fd_spad_alloc_check ( spad ,
12911307 FD_TXNCACHE_ALIGN ,
12921308 fd_txncache_footprint ( FD_TXNCACHE_DEFAULT_MAX_ROOTED_SLOTS ,
@@ -1347,7 +1363,11 @@ replay( fd_ledger_args_t * args ) {
13471363
13481364 fd_ledger_main_setup ( args );
13491365
1350- fd_blockstore_init ( args -> blockstore , -1 , FD_BLOCKSTORE_ARCHIVE_MIN_SIZE , & args -> slot_ctx -> slot_bank );
1366+ fd_blockstore_init ( args -> blockstore ,
1367+ -1 ,
1368+ FD_BLOCKSTORE_ARCHIVE_MIN_SIZE ,
1369+ & args -> slot_ctx -> slot_bank ,
1370+ args -> slot_ctx -> slot );
13511371 fd_buf_shred_pool_reset ( args -> blockstore -> shred_pool , 0 );
13521372
13531373 FD_LOG_WARNING (( "setup done" ));
0 commit comments