Skip to content

Commit

Permalink
finish
Browse files Browse the repository at this point in the history
  • Loading branch information
ibhatt-jumptrading committed May 14, 2024
1 parent 08289a0 commit 6e1432b
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 12 deletions.
13 changes: 11 additions & 2 deletions src/app/ledger/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ static void usage( char const * progname ) {
fprintf( stderr, " --capture-txns <int> capture transactions\n" );
fprintf( stderr, " --checkpt-path <checkpoint path> path to checkpoint\n" ); /* Capture context tool for runtime checkpoints */
fprintf( stderr, " --checkpt-freq <ulong> checkpoint frequency\n" );
fprintf( stderr, " --checkpt-mismatch <int> checkpoint on mismatch at last rooted slot\n" );
fprintf( stderr, " --allocator <allocator> allocator to use\n" );
fprintf( stderr, " --dump-insn-to-pb <int> dump instructions to pb\n" ); /* Capture ctx tool for insn dumping*/
fprintf( stderr, " --dump-insn-sig-filter <insn sig filter> dump instructions signature filter\n" );
Expand Down Expand Up @@ -113,6 +114,7 @@ struct fd_ledger_args {
int capture_txns;
char const * checkpt_path; /* runtime checkpoints */
ulong checkpt_freq;
int checkpt_mismatch;
ulong on_demand_block_history;
int dump_insn_to_pb;
char const * dump_insn_sig_filter;
Expand Down Expand Up @@ -264,7 +266,9 @@ runtime_replay( fd_runtime_ctx_t * state, fd_runtime_args_t * args ) {
expected->hash,
state->slot_ctx->slot_bank.poh.hash ));
if( state->abort_on_mismatch ) {
fd_runtime_checkpt( state->capture_ctx, state->slot_ctx, ULONG_MAX );
if( args->checkpt_mismatch ) {
fd_runtime_checkpt( state->capture_ctx, state->slot_ctx, ULONG_MAX );
}
fd_blockstore_end_read( blockstore );
return 1;
}
Expand All @@ -281,7 +285,9 @@ runtime_replay( fd_runtime_ctx_t * state, fd_runtime_args_t * args ) {
expected->hash,
state->slot_ctx->slot_bank.banks_hash.hash ));
if( state->abort_on_mismatch ) {
fd_runtime_checkpt( state->capture_ctx, state->slot_ctx, ULONG_MAX );
if( args->checkpt_mismatch ) {
fd_runtime_checkpt( state->capture_ctx, state->slot_ctx, ULONG_MAX );
}
fd_blockstore_end_read( blockstore );
return 1;
}
Expand Down Expand Up @@ -833,6 +839,7 @@ replay( fd_ledger_args_t * args ) {
runtime_args.capture_fpath = args->capture_fpath;
runtime_args.capture_txns = args->capture_txns;
runtime_args.checkpt_path = args->checkpt_path;
runtime_args.checkpt_mismatch = args->checkpt_mismatch;
runtime_args.checkpt_freq = args->checkpt_freq;
runtime_args.copy_txn_status = args->copy_txn_status;
runtime_args.on_demand_block_ingest = args->on_demand_block_ingest;
Expand Down Expand Up @@ -1222,6 +1229,7 @@ initial_setup( int argc, char ** argv, fd_ledger_args_t * args ) {
int capture_txns = fd_env_strip_cmdline_int ( &argc, &argv, "--capture-txns", NULL, 1 );
char const * checkpt_path = fd_env_strip_cmdline_cstr ( &argc, &argv, "--checkpt-path", NULL, NULL );
ulong checkpt_freq = fd_env_strip_cmdline_ulong( &argc, &argv, "--checkpt-freq", NULL, ULONG_MAX );
int checkpt_mismatch = fd_env_strip_cmdline_int ( &argc, &argv, "--checkpt-mismatch", NULL, 0 );
char const * allocator = fd_env_strip_cmdline_cstr ( &argc, &argv, "--allocator", NULL, "wksp" );
int abort_on_mismatch = fd_env_strip_cmdline_int ( &argc, &argv, "--abort-on-mismatch", NULL, 1 );
int on_demand_block_ingest = fd_env_strip_cmdline_int ( &argc, &argv, "--on-demand-block-ingest", NULL, 0 );
Expand Down Expand Up @@ -1324,6 +1332,7 @@ initial_setup( int argc, char ** argv, fd_ledger_args_t * args ) {
args->capture_txns = capture_txns;
args->checkpt_path = checkpt_path;
args->checkpt_freq = checkpt_freq;
args->checkpt_mismatch = checkpt_mismatch;
args->allocator = allocator;
args->abort_on_mismatch = abort_on_mismatch;
args->on_demand_block_ingest = on_demand_block_ingest;
Expand Down
6 changes: 3 additions & 3 deletions src/disco/tvu/fd_tvu.c
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ void capture_ctx_setup( fd_runtime_ctx_t * runtime_ctx, fd_runtime_args_t * args
runtime_ctx->capture_file = NULL;

int has_solcap = args->capture_fpath && args->capture_fpath[0] != '\0';
int has_checkpt_dump = args->checkpt_path && args->checkpt_path[0] != '\0' && args->checkpt_freq != 0;
int has_checkpt_dump = args->checkpt_path && args->checkpt_path[0] != '\0';
int has_prune = args->pruned_funk != NULL;
int has_dump_to_protobuf = args->dump_insn_to_pb;

Expand Down Expand Up @@ -1492,8 +1492,8 @@ fd_tvu_parse_args( fd_runtime_args_t * args, int argc, char ** argv ) {
args->retrace = fd_env_strip_cmdline_int( &argc, &argv, "--retrace", NULL, 0 );
args->abort_on_mismatch =
(uchar)fd_env_strip_cmdline_int( &argc, &argv, "--abort-on-mismatch", NULL, 0 );
args->checkpt_freq = fd_env_strip_cmdline_ulong( &argc, &argv, "--checkpt-freq", NULL, ULONG_MAX );
args->checkpt_path = fd_env_strip_cmdline_cstr( &argc, &argv, "--checkpt-path", NULL, NULL );
args->checkpt_freq = fd_env_strip_cmdline_ulong( &argc, &argv, "--checkpt-freq", NULL, ULONG_MAX );
args->checkpt_path = fd_env_strip_cmdline_cstr( &argc, &argv, "--checkpt-path", NULL, NULL );
args->dump_insn_to_pb = fd_env_strip_cmdline_int( &argc, &argv, "--dump-insn-to-pb", NULL, 0 );
args->dump_insn_sig_filter = fd_env_strip_cmdline_cstr( &argc, &argv, "--dump-insn-sig-filter", NULL, NULL );
args->dump_insn_output_dir = fd_env_strip_cmdline_cstr( &argc, &argv, "--dump-insn-output-dir", NULL, "protobuf_tests_from_executed_instr" );
Expand Down
6 changes: 3 additions & 3 deletions src/flamenco/runtime/fd_executor.c
Original file line number Diff line number Diff line change
Expand Up @@ -1115,9 +1115,9 @@ fd_execute_txn( fd_exec_txn_ctx_t * txn_ctx ) {
}

int exec_result = fd_execute_instr( txn_ctx, &instrs[i] );
if ( 254462504 == txn_ctx->slot_ctx->slot_bank.slot ) {
exec_result = -1;
}
//if ( 254462504 == txn_ctx->slot_ctx->slot_bank.slot ) {
// exec_result = -1;
//}

if( exec_result != FD_EXECUTOR_INSTR_SUCCESS ) {
#ifdef VLOG
Expand Down
10 changes: 6 additions & 4 deletions src/flamenco/runtime/fd_runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -2206,19 +2206,21 @@ fd_runtime_checkpt( fd_capture_ctx_t * capture_ctx,
if( !is_checkpt_freq && !is_abort_slot ) {
return;
}
FD_LOG_NOTICE(("checkpointing at slot=%lu", slot));

if( is_checkpt_freq ) {
if( !is_abort_slot ) {
FD_LOG_NOTICE(( "checkpointing at slot=%lu", slot ));
fd_funk_end_write( slot_ctx->acc_mgr->funk );
} else {
FD_LOG_NOTICE(( "checkpointing after mismatch" ));
}

unlink( capture_ctx->checkpt_path );
int err = fd_wksp_checkpt( fd_funk_wksp( slot_ctx->acc_mgr->funk ), capture_ctx->checkpt_path, 0666, 0, NULL );
if ( err ) {
FD_LOG_ERR(("backup failed: error %d", err));
FD_LOG_ERR(( "backup failed: error %d", err ));
}

if( is_checkpt_freq ) {
if( !is_abort_slot ) {
fd_funk_start_write( slot_ctx->acc_mgr->funk );
}
}
Expand Down
1 change: 1 addition & 0 deletions src/flamenco/runtime/fd_runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ struct fd_runtime_args {
ushort rpc_port;
ulong checkpt_freq;
char const * checkpt_path;
int checkpt_mismatch;
fd_funk_t * pruned_funk;
int dump_insn_to_pb;
char const * dump_insn_sig_filter;
Expand Down

0 comments on commit 6e1432b

Please sign in to comment.