Skip to content

Commit

Permalink
snapshot: break out snapshot load into functions
Browse files Browse the repository at this point in the history
  • Loading branch information
ibhatt-jumptrading committed Jan 10, 2025
1 parent 033574f commit a439935
Show file tree
Hide file tree
Showing 16 changed files with 328 additions and 153 deletions.
4 changes: 2 additions & 2 deletions src/app/fdctl/run/tiles/fd_replay.c
Original file line number Diff line number Diff line change
Expand Up @@ -1827,7 +1827,7 @@ read_snapshot( void * _ctx,
/* Funk already has a snapshot loaded */
fd_runtime_recover_banks( ctx->slot_ctx, 0, 1 );
} else {
fd_snapshot_load( snapshot, ctx->slot_ctx, ctx->tpool, false, false, FD_SNAPSHOT_TYPE_FULL );
fd_snapshot_load_all( snapshot, ctx->slot_ctx, ctx->tpool, false, false, FD_SNAPSHOT_TYPE_FULL );
}

/* Load incremental */
Expand All @@ -1842,7 +1842,7 @@ read_snapshot( void * _ctx,
}

if( strlen( incremental ) > 0 ) {
fd_snapshot_load( incremental, ctx->slot_ctx, ctx->tpool, false, false, FD_SNAPSHOT_TYPE_INCREMENTAL );
fd_snapshot_load_all( incremental, ctx->slot_ctx, ctx->tpool, false, false, FD_SNAPSHOT_TYPE_INCREMENTAL );
}

if( ctx->replay_plugin_out_mem ) {
Expand Down
16 changes: 8 additions & 8 deletions src/app/ledger/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1101,11 +1101,11 @@ ingest( fd_ledger_args_t * args ) {

/* Load in snapshot(s) */
if( args->snapshot ) {
fd_snapshot_load( args->snapshot, slot_ctx, args->tpool, args->verify_acc_hash, args->check_acc_hash , FD_SNAPSHOT_TYPE_FULL );
fd_snapshot_load_all( args->snapshot, slot_ctx, args->tpool, args->verify_acc_hash, args->check_acc_hash , FD_SNAPSHOT_TYPE_FULL );
FD_LOG_NOTICE(( "imported %lu records from snapshot", fd_funk_rec_cnt( fd_funk_rec_map( funk, fd_funk_wksp( funk ) ) ) ));
}
if( args->incremental ) {
fd_snapshot_load( args->incremental, slot_ctx, args->tpool, args->verify_acc_hash, args->check_acc_hash, FD_SNAPSHOT_TYPE_INCREMENTAL );
fd_snapshot_load_all( args->incremental, slot_ctx, args->tpool, args->verify_acc_hash, args->check_acc_hash, FD_SNAPSHOT_TYPE_INCREMENTAL );
FD_LOG_NOTICE(( "imported %lu records from incremental snapshot", fd_funk_rec_cnt( fd_funk_rec_map( funk, fd_funk_wksp( funk ) ) ) ));
}

Expand Down Expand Up @@ -1247,11 +1247,11 @@ replay( fd_ledger_args_t * args ) {
if( !rec_cnt ) {
/* Load in snapshot(s) */
if( args->snapshot ) {
fd_snapshot_load( args->snapshot, args->slot_ctx, args->tpool, args->verify_acc_hash, args->check_acc_hash, FD_SNAPSHOT_TYPE_FULL );
fd_snapshot_load_all( args->snapshot, args->slot_ctx, args->tpool, args->verify_acc_hash, args->check_acc_hash, FD_SNAPSHOT_TYPE_FULL );
FD_LOG_NOTICE(( "imported %lu records from snapshot", fd_funk_rec_cnt( fd_funk_rec_map( funk, fd_funk_wksp( funk ) ) ) ));
}
if( args->incremental ) {
fd_snapshot_load( args->incremental, args->slot_ctx, args->tpool, args->verify_acc_hash, args->check_acc_hash, FD_SNAPSHOT_TYPE_INCREMENTAL );
fd_snapshot_load_all( args->incremental, args->slot_ctx, args->tpool, args->verify_acc_hash, args->check_acc_hash, FD_SNAPSHOT_TYPE_INCREMENTAL );
FD_LOG_NOTICE(( "imported %lu records from snapshot", fd_funk_rec_cnt( fd_funk_rec_map( funk, fd_funk_wksp( funk ) ) ) ));
}
if( args->genesis ) {
Expand Down Expand Up @@ -1306,11 +1306,11 @@ prune( fd_ledger_args_t * args ) {
if( !rec_cnt ) {
/* Load in snapshot(s) */
if( args->snapshot ) {
fd_snapshot_load( args->snapshot, args->slot_ctx, args->tpool, args->verify_acc_hash, args->check_acc_hash, FD_SNAPSHOT_TYPE_FULL );
fd_snapshot_load_all( args->snapshot, args->slot_ctx, args->tpool, args->verify_acc_hash, args->check_acc_hash, FD_SNAPSHOT_TYPE_FULL );
FD_LOG_NOTICE(( "imported %lu records from snapshot", fd_funk_rec_cnt( fd_funk_rec_map( funk, fd_funk_wksp( funk ) ) ) ));
}
if( args->incremental ) {
fd_snapshot_load( args->incremental, args->slot_ctx, args->tpool, args->verify_acc_hash, args->check_acc_hash, FD_SNAPSHOT_TYPE_INCREMENTAL );
fd_snapshot_load_all( args->incremental, args->slot_ctx, args->tpool, args->verify_acc_hash, args->check_acc_hash, FD_SNAPSHOT_TYPE_INCREMENTAL );
FD_LOG_NOTICE(( "imported %lu records from snapshot", fd_funk_rec_cnt( fd_funk_rec_map( funk, fd_funk_wksp( funk ) ) ) ));
}
}
Expand Down Expand Up @@ -1415,11 +1415,11 @@ prune( fd_ledger_args_t * args ) {

/* Load in snapshot(s) */
if( args->snapshot ) {
fd_snapshot_load( args->snapshot, args->slot_ctx, args->tpool, 0, 0, FD_SNAPSHOT_TYPE_FULL );
fd_snapshot_load_all( args->snapshot, args->slot_ctx, args->tpool, 0, 0, FD_SNAPSHOT_TYPE_FULL );
FD_LOG_NOTICE(( "reload: imported %lu records from snapshot", fd_funk_rec_cnt( fd_funk_rec_map( funk, fd_funk_wksp( funk ) ) ) ));
}
if( args->incremental ) {
fd_snapshot_load( args->incremental, args->slot_ctx, args->tpool, 0, 0, FD_SNAPSHOT_TYPE_INCREMENTAL );
fd_snapshot_load_all( args->incremental, args->slot_ctx, args->tpool, 0, 0, FD_SNAPSHOT_TYPE_INCREMENTAL );
FD_LOG_NOTICE(( "reload: imported %lu records from snapshot", fd_funk_rec_cnt( fd_funk_rec_map( funk, fd_funk_wksp( funk ) ) ) ));
}

Expand Down
2 changes: 1 addition & 1 deletion src/disco/consensus/test_consensus.c
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ main( void ) {
// FD_TEST( epoch_bank );
// FD_TEST( fd_slot_to_epoch( &epoch_bank->epoch_schedule, i, NULL ) ==
// fd_slot_to_epoch( &epoch_bank->epoch_schedule, j, NULL ) );
// fd_snapshot_load( incremental_snapshot, snapshot_slot_ctx, 1, 1, FD_SNAPSHOT_TYPE_INCREMENTAL );
// fd_snapshot_load_all( incremental_snapshot, snapshot_slot_ctx, 1, 1, FD_SNAPSHOT_TYPE_INCREMENTAL );
// }

// ulong snapshot_slot = snapshot_slot_ctx->slot_bank.slot;
Expand Down
Loading

0 comments on commit a439935

Please sign in to comment.