1717#include "../../discof/reasm/fd_reasm.h"
1818#include "../../disco/keyguard/fd_keyload.h"
1919#include "../../util/pod/fd_pod.h"
20+ #include "../../flamenco/accdb/fd_accdb_admin.h"
21+ #include "../../flamenco/accdb/fd_accdb_user.h"
2022#include "../../flamenco/rewards/fd_rewards.h"
2123#include "../../flamenco/leaders/fd_multi_epoch_leaders.h"
2224#include "../../flamenco/progcache/fd_progcache_admin.h"
@@ -135,7 +137,8 @@ struct fd_replay_tile {
135137 /* tx_metadata_storage enables the log collector if enabled */
136138 int tx_metadata_storage ;
137139
138- fd_funk_t funk [1 ];
140+ fd_accdb_admin_t accdb_admin [1 ];
141+ fd_accdb_user_t accdb [1 ];
139142 fd_progcache_admin_t progcache_admin [1 ];
140143
141144 fd_txncache_t * txncache ;
@@ -612,7 +615,7 @@ buffer_vote_towers( fd_replay_tile_t * ctx,
612615 if ( FD_UNLIKELY ( vote_state -> stake == 0 ) ) continue ; /* skip unstaked vote accounts */
613616 fd_pubkey_t const * vote_account_pubkey = & vote_state -> vote_account ;
614617 if ( FD_UNLIKELY ( ctx -> vote_tower_out_len >= (FD_REPLAY_TOWER_VOTE_ACC_MAX - 1UL ) ) ) FD_LOG_ERR (( "vote_tower_out_len too large" ));
615- if ( FD_UNLIKELY ( fd_replay_out_vote_tower_from_funk ( ctx -> funk ,
618+ if ( FD_UNLIKELY ( fd_replay_out_vote_tower_from_funk ( ctx -> accdb -> funk ,
616619 xid ,
617620 vote_account_pubkey ,
618621 vote_state -> stake ,
@@ -693,7 +696,7 @@ replay_block_start( fd_replay_tile_t * ctx,
693696
694697 fd_funk_txn_xid_t xid = { .ul = { slot , bank_idx } };
695698 fd_funk_txn_xid_t parent_xid = { .ul = { parent_slot , parent_bank_idx } };
696- fd_funk_txn_prepare ( ctx -> funk , & parent_xid , & xid );
699+ fd_accdb_attach_child ( ctx -> accdb_admin , & parent_xid , & xid );
697700 fd_progcache_txn_attach_child ( ctx -> progcache_admin , & parent_xid , & xid );
698701
699702 /* Update any required runtime state and handle any potential epoch
@@ -726,14 +729,14 @@ replay_block_start( fd_replay_tile_t * ctx,
726729 fd_runtime_block_pre_execute_process_new_epoch (
727730 ctx -> banks ,
728731 bank ,
729- ctx -> funk ,
732+ ctx -> accdb -> funk ,
730733 & xid ,
731734 ctx -> capture_ctx ,
732735 ctx -> runtime_spad ,
733736 & is_epoch_boundary );
734737 if ( FD_UNLIKELY ( is_epoch_boundary ) ) publish_stake_weights ( ctx , stem , bank , 1 );
735738
736- FD_TEST ( !fd_runtime_block_execute_prepare ( bank , ctx -> funk , & xid , ctx -> capture_ctx , ctx -> runtime_spad ) );
739+ FD_TEST ( !fd_runtime_block_execute_prepare ( bank , ctx -> accdb -> funk , & xid , ctx -> capture_ctx , ctx -> runtime_spad ) );
737740 return bank ;
738741}
739742
@@ -826,7 +829,7 @@ replay_block_finalize( fd_replay_tile_t * ctx,
826829 fd_bank_shred_cnt_set ( bank , fd_sched_get_shred_cnt ( ctx -> sched , bank -> idx ) );
827830
828831 /* Do hashing and other end-of-block processing. */
829- fd_runtime_block_execute_finalize ( bank , ctx -> funk , & xid , ctx -> capture_ctx , 1 );
832+ fd_runtime_block_execute_finalize ( bank , ctx -> accdb -> funk , & xid , ctx -> capture_ctx , 1 );
830833
831834 /* Mark the bank as frozen. */
832835 fd_banks_mark_bank_frozen ( ctx -> banks , bank );
@@ -879,7 +882,7 @@ replay_block_finalize( fd_replay_tile_t * ctx,
879882 /* If enabled, dump the block to a file and reset the dumping
880883 context state */
881884 if ( FD_UNLIKELY ( ctx -> capture_ctx && ctx -> capture_ctx -> dump_block_to_pb ) ) {
882- fd_dump_block_to_protobuf ( ctx -> block_dump_ctx , ctx -> banks , bank , ctx -> funk , ctx -> capture_ctx );
885+ fd_dump_block_to_protobuf ( ctx -> block_dump_ctx , ctx -> banks , bank , ctx -> accdb -> funk , ctx -> capture_ctx );
883886 fd_block_dump_context_reset ( ctx -> block_dump_ctx );
884887 }
885888}
@@ -928,7 +931,7 @@ prepare_leader_bank( fd_replay_tile_t * ctx,
928931 /* prepare the funk transaction for the leader bank */
929932 fd_funk_txn_xid_t xid = { .ul = { slot , ctx -> leader_bank -> idx } };
930933 fd_funk_txn_xid_t parent_xid = { .ul = { parent_slot , parent_bank_idx } };
931- fd_funk_txn_prepare ( ctx -> funk , & parent_xid , & xid );
934+ fd_accdb_attach_child ( ctx -> accdb_admin , & parent_xid , & xid );
932935 fd_progcache_txn_attach_child ( ctx -> progcache_admin , & parent_xid , & xid );
933936
934937 fd_bank_execution_fees_set ( ctx -> leader_bank , 0UL );
@@ -953,14 +956,14 @@ prepare_leader_bank( fd_replay_tile_t * ctx,
953956 fd_runtime_block_pre_execute_process_new_epoch (
954957 ctx -> banks ,
955958 ctx -> leader_bank ,
956- ctx -> funk ,
959+ ctx -> accdb -> funk ,
957960 & xid ,
958961 ctx -> capture_ctx ,
959962 ctx -> runtime_spad ,
960963 & is_epoch_boundary );
961964 if ( FD_UNLIKELY ( is_epoch_boundary ) ) publish_stake_weights ( ctx , stem , ctx -> leader_bank , 1 );
962965
963- FD_TEST ( !fd_runtime_block_execute_prepare ( ctx -> leader_bank , ctx -> funk , & xid , ctx -> capture_ctx , ctx -> runtime_spad ) );
966+ FD_TEST ( !fd_runtime_block_execute_prepare ( ctx -> leader_bank , ctx -> accdb -> funk , & xid , ctx -> capture_ctx , ctx -> runtime_spad ) );
964967
965968 /* Now that a bank has been created for the leader slot, increment the
966969 reference count until we are done with the leader slot. */
@@ -987,13 +990,13 @@ fini_leader_bank( fd_replay_tile_t * ctx,
987990 ulong curr_slot = fd_bank_slot_get ( ctx -> leader_bank );
988991
989992 /* Do hashing and other end-of-block processing */
990- fd_funk_txn_map_t * txn_map = fd_funk_txn_map ( ctx -> funk );
993+ fd_funk_txn_map_t * txn_map = fd_funk_txn_map ( ctx -> accdb -> funk );
991994 if ( FD_UNLIKELY ( !txn_map -> map ) ) {
992995 FD_LOG_ERR (( "Could not find valid funk transaction map" ));
993996 }
994997 fd_funk_txn_xid_t xid = { .ul = { curr_slot , ctx -> leader_bank -> idx } };
995998
996- fd_runtime_block_execute_finalize ( ctx -> leader_bank , ctx -> funk , & xid , ctx -> capture_ctx , 0 );
999+ fd_runtime_block_execute_finalize ( ctx -> leader_bank , ctx -> accdb -> funk , & xid , ctx -> capture_ctx , 0 );
9971000
9981001 fd_hash_t const * bank_hash = fd_bank_bank_hash_query ( ctx -> leader_bank );
9991002 FD_TEST ( bank_hash );
@@ -1093,16 +1096,17 @@ init_funk( fd_replay_tile_t * ctx,
10931096 ulong bank_slot ) {
10941097 /* Ensure that the loaded bank root corresponds to the account
10951098 database's root. */
1096- if ( FD_UNLIKELY ( !ctx -> funk -> shmem ) ) {
1099+ fd_funk_t * funk = ctx -> accdb_admin -> funk ;
1100+ if ( FD_UNLIKELY ( !funk -> shmem ) ) {
10971101 FD_LOG_CRIT (( "failed to initialize account database: replay tile is not joined to database shared memory objects" ));
10981102 }
1099- fd_funk_txn_xid_t const * accdb_pub = fd_funk_last_publish ( ctx -> funk );
1103+ fd_funk_txn_xid_t const * accdb_pub = fd_funk_last_publish ( funk );
11001104 if ( FD_UNLIKELY ( accdb_pub -> ul [0 ]!= bank_slot ) ) {
11011105 FD_LOG_CRIT (( "failed to initialize account database: accdb is at slot %lu, but chain state is at slot %lu\n"
11021106 "This is a bug in startup components." ,
11031107 accdb_pub -> ul [0 ], bank_slot ));
11041108 }
1105- if ( FD_UNLIKELY ( fd_funk_last_publish_is_frozen ( ctx -> funk ) ) ) {
1109+ if ( FD_UNLIKELY ( fd_funk_last_publish_is_frozen ( funk ) ) ) {
11061110 FD_LOG_CRIT (( "failed to initialize account database: accdb fork graph is not clean.\n"
11071111 "The account database should only contain state for the root slot at this point,\n"
11081112 "but there are incomplete database transactions leftover.\n"
@@ -1116,8 +1120,8 @@ init_funk( fd_replay_tile_t * ctx,
11161120 FD_LOG_CRIT (( "failed to initialize account database: replay tile is not joined to program cache" ));
11171121 }
11181122 fd_progcache_clear ( ctx -> progcache_admin );
1119- fd_progcache_txn_attach_child ( ctx -> progcache_admin , fd_funk_root ( ctx -> progcache_admin -> funk ), fd_funk_last_publish ( ctx -> funk ) );
1120- fd_progcache_txn_advance_root ( ctx -> progcache_admin , fd_funk_last_publish ( ctx -> funk ) );
1123+ fd_progcache_txn_attach_child ( ctx -> progcache_admin , fd_funk_root ( ctx -> progcache_admin -> funk ), fd_funk_last_publish ( ctx -> accdb -> funk ) );
1124+ fd_progcache_txn_advance_root ( ctx -> progcache_admin , fd_funk_last_publish ( ctx -> accdb -> funk ) );
11211125}
11221126
11231127static void
@@ -1137,12 +1141,12 @@ init_after_snapshot( fd_replay_tile_t * ctx ) {
11371141
11381142 fd_stake_delegations_t * root_delegations = fd_banks_stake_delegations_root_query ( ctx -> banks );
11391143
1140- fd_stake_delegations_refresh ( root_delegations , ctx -> funk , & xid );
1144+ fd_stake_delegations_refresh ( root_delegations , ctx -> accdb -> funk , & xid );
11411145
11421146 /* After both snapshots have been loaded in, we can determine if we should
11431147 start distributing rewards. */
11441148
1145- fd_rewards_recalculate_partitioned_rewards ( ctx -> banks , bank , ctx -> funk , & xid , ctx -> vote_state_credits , ctx -> capture_ctx );
1149+ fd_rewards_recalculate_partitioned_rewards ( ctx -> banks , bank , ctx -> accdb -> funk , & xid , ctx -> vote_state_credits , ctx -> capture_ctx );
11461150
11471151 ulong snapshot_slot = fd_bank_slot_get ( bank );
11481152 if ( FD_UNLIKELY ( !snapshot_slot ) ) {
@@ -1158,8 +1162,8 @@ init_after_snapshot( fd_replay_tile_t * ctx ) {
11581162 fd_sha256_hash ( poh -> hash , 32UL , poh -> hash );
11591163 }
11601164
1161- FD_TEST ( !fd_runtime_block_execute_prepare ( bank , ctx -> funk , & xid , ctx -> capture_ctx , ctx -> runtime_spad ) );
1162- fd_runtime_block_execute_finalize ( bank , ctx -> funk , & xid , ctx -> capture_ctx , 1 );
1165+ FD_TEST ( !fd_runtime_block_execute_prepare ( bank , ctx -> accdb -> funk , & xid , ctx -> capture_ctx , ctx -> runtime_spad ) );
1166+ fd_runtime_block_execute_finalize ( bank , ctx -> accdb -> funk , & xid , ctx -> capture_ctx , 1 );
11631167
11641168 snapshot_slot = 0UL ;
11651169 }
@@ -1352,7 +1356,7 @@ boot_genesis( fd_replay_tile_t * ctx,
13521356 FD_TEST ( bank );
13531357 fd_funk_txn_xid_t xid = { .ul = { 0UL , FD_REPLAY_BOOT_BANK_IDX } };
13541358
1355- fd_runtime_read_genesis ( ctx -> banks , bank , ctx -> funk , & xid , NULL , fd_type_pun_const ( genesis_hash ), fd_type_pun_const ( lthash ), genesis , ctx -> runtime_spad );
1359+ fd_runtime_read_genesis ( ctx -> banks , bank , ctx -> accdb -> funk , & xid , NULL , fd_type_pun_const ( genesis_hash ), fd_type_pun_const ( lthash ), genesis , ctx -> runtime_spad );
13561360
13571361 static const fd_txncache_fork_id_t txncache_root = { .val = USHORT_MAX };
13581362 bank -> txncache_fork_id = fd_txncache_attach_child ( ctx -> txncache , txncache_root );
@@ -1477,7 +1481,7 @@ on_snapshot_message( fd_replay_tile_t * ctx,
14771481
14781482 fd_funk_txn_xid_t xid = { .ul = { snapshot_slot , FD_REPLAY_BOOT_BANK_IDX } };
14791483
1480- fd_features_restore ( bank , ctx -> funk , & xid );
1484+ fd_features_restore ( bank , ctx -> accdb -> funk , & xid );
14811485
14821486 fd_runtime_update_leaders ( bank , ctx -> runtime_spad );
14831487
@@ -1733,8 +1737,8 @@ process_fec_set( fd_replay_tile_t * ctx,
17331737 sched_fec -> slot = reasm_fec -> slot ;
17341738 sched_fec -> parent_slot = reasm_fec -> slot - reasm_fec -> parent_off ;
17351739 sched_fec -> is_first_in_block = reasm_fec -> fec_set_idx == 0U ;
1736- fd_funk_txn_xid_copy ( sched_fec -> alut_ctx -> xid , fd_funk_last_publish ( ctx -> funk ) );
1737- sched_fec -> alut_ctx -> funk = ctx -> funk ;
1740+ fd_funk_txn_xid_copy ( sched_fec -> alut_ctx -> xid , fd_funk_last_publish ( ctx -> accdb -> funk ) );
1741+ sched_fec -> alut_ctx -> accdb [ 0 ] = ctx -> accdb [ 0 ] ;
17381742 sched_fec -> alut_ctx -> els = ctx -> published_root_slot ;
17391743 sched_fec -> alut_ctx -> runtime_spad = ctx -> runtime_spad ;
17401744
@@ -1753,7 +1757,7 @@ funk_publish( fd_replay_tile_t * ctx,
17531757 /* This is the standard case. Publish all transactions up to and
17541758 including the watermark. This will publish any in-prep ancestors
17551759 of root_txn as well. */
1756- if ( FD_UNLIKELY ( ! fd_funk_txn_publish ( ctx -> funk , & xid ) ) ) FD_LOG_CRIT (( "failed to root slot %lu: fd_funk_txn_publish(accdb) failed" , slot ) );
1760+ fd_accdb_advance_root ( ctx -> accdb_admin , & xid );
17571761 fd_progcache_txn_advance_root ( ctx -> progcache_admin , & xid );
17581762}
17591763
@@ -2383,10 +2387,9 @@ unprivileged_init( fd_topo_t * topo,
23832387 for ( ulong i = 0UL ; i < tile -> replay .enable_features_cnt ; i ++ ) one_off_features [ i ] = tile -> replay .enable_features [i ];
23842388 fd_features_enable_one_offs ( features , one_off_features , (uint )tile -> replay .enable_features_cnt , 0UL );
23852389
2386- FD_TEST ( fd_funk_join ( ctx -> funk , fd_topo_obj_laddr ( topo , tile -> replay .funk_obj_id ) ) );
2387- FD_TEST ( fd_progcache_admin_join (
2388- ctx -> progcache_admin ,
2389- fd_topo_obj_laddr ( topo , tile -> replay .progcache_obj_id ) ) );
2390+ FD_TEST ( fd_accdb_admin_join ( ctx -> accdb_admin , fd_topo_obj_laddr ( topo , tile -> replay .funk_obj_id ) ) );
2391+ FD_TEST ( fd_accdb_user_join ( ctx -> accdb , fd_topo_obj_laddr ( topo , tile -> replay .funk_obj_id ) ) );
2392+ FD_TEST ( fd_progcache_admin_join ( ctx -> progcache_admin , fd_topo_obj_laddr ( topo , tile -> replay .progcache_obj_id ) ) );
23902393
23912394 void * _txncache_shmem = fd_topo_obj_laddr ( topo , tile -> replay .txncache_obj_id );
23922395 fd_txncache_shmem_t * txncache_shmem = fd_txncache_shmem_join ( _txncache_shmem );
0 commit comments