From 6e1432bdaa85adab7ec51aab78767178b9582f9c Mon Sep 17 00:00:00 2001 From: ibhatt-jumptrading Date: Tue, 14 May 2024 20:14:02 +0000 Subject: [PATCH] finish --- src/app/ledger/main.c | 13 +++++++++++-- src/disco/tvu/fd_tvu.c | 6 +++--- src/flamenco/runtime/fd_executor.c | 6 +++--- src/flamenco/runtime/fd_runtime.c | 10 ++++++---- src/flamenco/runtime/fd_runtime.h | 1 + 5 files changed, 24 insertions(+), 12 deletions(-) diff --git a/src/app/ledger/main.c b/src/app/ledger/main.c index 35c62bce48..98c5e8c2a7 100644 --- a/src/app/ledger/main.c +++ b/src/app/ledger/main.c @@ -72,6 +72,7 @@ static void usage( char const * progname ) { fprintf( stderr, " --capture-txns capture transactions\n" ); fprintf( stderr, " --checkpt-path path to checkpoint\n" ); /* Capture context tool for runtime checkpoints */ fprintf( stderr, " --checkpt-freq checkpoint frequency\n" ); + fprintf( stderr, " --checkpt-mismatch checkpoint on mismatch at last rooted slot\n" ); fprintf( stderr, " --allocator allocator to use\n" ); fprintf( stderr, " --dump-insn-to-pb dump instructions to pb\n" ); /* Capture ctx tool for insn dumping*/ fprintf( stderr, " --dump-insn-sig-filter dump instructions signature filter\n" ); @@ -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; @@ -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; } @@ -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; } @@ -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; @@ -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 ); @@ -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; diff --git a/src/disco/tvu/fd_tvu.c b/src/disco/tvu/fd_tvu.c index 2f2931fc55..5ce35cc5f4 100644 --- a/src/disco/tvu/fd_tvu.c +++ b/src/disco/tvu/fd_tvu.c @@ -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; @@ -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" ); diff --git a/src/flamenco/runtime/fd_executor.c b/src/flamenco/runtime/fd_executor.c index dfed6f83d9..b596f4d335 100644 --- a/src/flamenco/runtime/fd_executor.c +++ b/src/flamenco/runtime/fd_executor.c @@ -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 diff --git a/src/flamenco/runtime/fd_runtime.c b/src/flamenco/runtime/fd_runtime.c index ca69577e66..418bfa79f0 100644 --- a/src/flamenco/runtime/fd_runtime.c +++ b/src/flamenco/runtime/fd_runtime.c @@ -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 ); } } diff --git a/src/flamenco/runtime/fd_runtime.h b/src/flamenco/runtime/fd_runtime.h index 8d71cee40f..f6d21ea149 100644 --- a/src/flamenco/runtime/fd_runtime.h +++ b/src/flamenco/runtime/fd_runtime.h @@ -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;