7
7
#include "../../flamenco/runtime/fd_runtime_public.h"
8
8
#include "../../flamenco/runtime/fd_rocksdb.h"
9
9
#include "../../flamenco/runtime/fd_txncache.h"
10
+ #include "../../flamenco/runtime/fd_bank_mgr.h"
10
11
#include "../../flamenco/rewards/fd_rewards.h"
11
12
#include "../../ballet/base58/fd_base58.h"
12
13
#include "../../flamenco/runtime/context/fd_capture_ctx.h"
@@ -291,7 +292,7 @@ runtime_replay( fd_ledger_args_t * ledger_args ) {
291
292
292
293
fd_features_restore ( ledger_args -> slot_ctx , ledger_args -> runtime_spad );
293
294
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 );
295
296
296
297
fd_calculate_epoch_accounts_hash_values ( ledger_args -> slot_ctx );
297
298
@@ -300,8 +301,8 @@ runtime_replay( fd_ledger_args_t * ledger_args ) {
300
301
ulong slot_cnt = 0 ;
301
302
fd_blockstore_t * blockstore = ledger_args -> slot_ctx -> blockstore ;
302
303
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 ;
305
306
306
307
ledger_args -> slot_ctx -> root_slot = prev_slot ;
307
308
@@ -350,7 +351,6 @@ runtime_replay( fd_ledger_args_t * ledger_args ) {
350
351
for ( ulong slot = start_slot ; slot <=ledger_args -> end_slot && !aborted ; ++ slot ) {
351
352
352
353
ledger_args -> slot_ctx -> slot_bank .prev_slot = prev_slot ;
353
- ledger_args -> slot_ctx -> slot_bank .slot = slot ;
354
354
355
355
FD_LOG_DEBUG (( "reading slot %lu" , slot ));
356
356
@@ -405,10 +405,18 @@ runtime_replay( fd_ledger_args_t * ledger_args ) {
405
405
continue ;
406
406
}
407
407
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 ));
411
418
}
419
+ fd_bank_mgr_max_tick_height_save ( ledger_args -> slot_ctx -> bank_mgr );
412
420
413
421
if ( ledger_args -> slot_ctx -> root_slot %ledger_args -> snapshot_freq == 0UL && !ledger_args -> is_snapshotting ) {
414
422
@@ -455,8 +463,9 @@ runtime_replay( fd_ledger_args_t * ledger_args ) {
455
463
}
456
464
457
465
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 ));
459
467
FD_TEST ( fd_runtime_block_eval_tpool ( ledger_args -> slot_ctx ,
468
+ slot ,
460
469
blk ,
461
470
ledger_args -> capture_ctx ,
462
471
ledger_args -> tpool ,
@@ -471,11 +480,11 @@ runtime_replay( fd_ledger_args_t * ledger_args ) {
471
480
fd_hash_t expected ;
472
481
int err = fd_blockstore_block_hash_query ( blockstore , slot , & expected );
473
482
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 ) ) ) ) {
475
484
char expected_hash [ FD_BASE58_ENCODED_32_SZ ];
476
485
fd_acct_addr_cstr ( expected_hash , expected .hash );
477
486
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 );
479
488
FD_LOG_WARNING (( "PoH hash mismatch! slot=%lu expected=%s, got=%s" ,
480
489
slot ,
481
490
expected_hash ,
@@ -718,7 +727,7 @@ fd_ledger_main_setup( fd_ledger_args_t * args ) {
718
727
719
728
/* Finish other runtime setup steps */
720
729
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 );
722
731
fd_calculate_epoch_accounts_hash_values ( args -> slot_ctx );
723
732
724
733
fd_exec_para_cb_ctx_t exec_para_ctx = {
@@ -1156,11 +1165,11 @@ ingest( fd_ledger_args_t * args ) {
1156
1165
1157
1166
/* At this point the account state has been ingested into funk. Intake rocksdb */
1158
1167
if ( args -> start_slot == 0 ) {
1159
- args -> start_slot = slot_ctx -> slot_bank . slot + 1 ;
1168
+ args -> start_slot = slot_ctx -> slot + 1 ;
1160
1169
}
1161
1170
fd_blockstore_t * blockstore = args -> blockstore ;
1162
1171
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 ;
1164
1173
}
1165
1174
1166
1175
if ( args -> funk_only ) {
@@ -1169,8 +1178,8 @@ ingest( fd_ledger_args_t * args ) {
1169
1178
FD_LOG_NOTICE (( "using shredcap" ));
1170
1179
fd_shredcap_populate_blockstore ( args -> shredcap , blockstore , args -> start_slot , args -> end_slot );
1171
1180
} 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 ;
1174
1183
}
1175
1184
ingest_rocksdb ( args -> rocksdb_list [ 0UL ], args -> start_slot , args -> end_slot ,
1176
1185
blockstore , args -> copy_txn_status , args -> trash_hash , args -> valloc );
@@ -1269,24 +1278,31 @@ replay( fd_ledger_args_t * args ) {
1269
1278
fd_exec_epoch_ctx_bank_mem_clear ( args -> epoch_ctx );
1270
1279
1271
1280
/* 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 );
1275
1297
1276
1298
args -> epoch_ctx -> runtime_public = runtime_public ;
1277
1299
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 );
1279
1301
fd_features_enable_one_offs ( & args -> epoch_ctx -> features , args -> one_off_features , args -> one_off_features_cnt , 0UL );
1280
1302
1281
1303
// activate them
1282
1304
fd_memcpy ( & args -> epoch_ctx -> runtime_public -> features , & args -> epoch_ctx -> features , sizeof (fd_features_t ) );
1283
1305
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
-
1290
1306
void * status_cache_mem = fd_spad_alloc_check ( spad ,
1291
1307
FD_TXNCACHE_ALIGN ,
1292
1308
fd_txncache_footprint ( FD_TXNCACHE_DEFAULT_MAX_ROOTED_SLOTS ,
@@ -1347,7 +1363,11 @@ replay( fd_ledger_args_t * args ) {
1347
1363
1348
1364
fd_ledger_main_setup ( args );
1349
1365
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 );
1351
1371
fd_buf_shred_pool_reset ( args -> blockstore -> shred_pool , 0 );
1352
1372
1353
1373
FD_LOG_WARNING (( "setup done" ));
0 commit comments