Skip to content

Commit f508e88

Browse files
committed
wip
1 parent 38b8f39 commit f508e88

File tree

2 files changed

+40
-7
lines changed

2 files changed

+40
-7
lines changed

src/discof/replay/fd_replay_tile.c

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
#include "../../flamenco/leaders/fd_multi_epoch_leaders.h"
2020
#include "../../disco/metrics/fd_metrics.h"
2121

22+
#include "../../flamenco/runtime/tests/fd_dump_pb.h"
23+
2224
#include <errno.h>
2325

2426
/* Replay concepts:
@@ -371,7 +373,6 @@ FD_FN_CONST static inline ulong
371373
scratch_align( void ) {
372374
return 128UL;
373375
}
374-
375376
FD_FN_PURE static inline ulong
376377
scratch_footprint( fd_topo_tile_t const * tile ) {
377378
ulong chain_cnt = fd_block_id_map_chain_cnt_est( tile->replay.max_live_slots );
@@ -789,6 +790,37 @@ replay_block_finalize( fd_replay_tile_t * ctx,
789790
}
790791

791792
fd_bank_hash_cmp_unlock( bank_hash_cmp );
793+
794+
/* Block dumping */
795+
if( FD_LIKELY( !ctx->capture_ctx->dump_block_to_pb ) ) return;
796+
797+
/* Get the bank for the parent slot */
798+
fd_bank_t * parent_bank = fd_banks_get_parent( ctx->banks, bank );
799+
if( FD_UNLIKELY( !parent_bank ) ) {
800+
FD_LOG_WARNING(( "Could not find parent bank for bank %lu", bank_idx ));
801+
return;
802+
}
803+
804+
/* Get the parent funk txn xid */
805+
ulong parent_slot = fd_bank_slot_get( parent_bank );
806+
fd_funk_txn_xid_t parent_xid = { .ul = { parent_slot, parent_slot } };
807+
fd_funk_txn_t * parent_txn = fd_funk_txn_query( &parent_xid, ctx->funk->txn_map );
808+
if( FD_UNLIKELY( !parent_txn ) ) {
809+
FD_LOG_WARNING(( "Could not find parent funk txn for bank %lu", bank_idx ));
810+
return;
811+
}
812+
813+
/* Fetch all transactions from the block
814+
TODO: Implement this */
815+
fd_block_id_ele_t * block_id_ele = &ctx->block_id_arr[ bank->parent_idx ];
816+
fd_hash_t * parent_merkle_root = &block_id_ele->block_id;
817+
fd_reasm_fec_t * parent_fec = fd_reasm_query( ctx->reasm, parent_merkle_root );
818+
FD_TEST( parent_fec ); // TODO: delete
819+
// fd_sched_block_t * block = block_pool_ele( ctx->sched, fec->bank_idx );
820+
821+
822+
/* Dump the block to pb */
823+
fd_dump_block_to_protobuf( ctx->banks, parent_bank, ctx->funk, &parent_xid, ctx->capture_ctx, ctx->runtime_spad );
792824
}
793825

794826
/**********************************************************************/

src/flamenco/runtime/tests/fd_dump_pb.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -951,12 +951,13 @@ fd_dump_block_to_protobuf( fd_banks_t * banks,
951951
fd_capture_ctx_t const * capture_ctx,
952952
fd_spad_t * spad,
953953
fd_exec_test_block_context_t * block_context_msg /* output */ ) {
954-
/* No spad frame because these allocations must persist beyond the lifetime of this function call */
955-
if( FD_UNLIKELY( capture_ctx==NULL ) ) {
956-
FD_LOG_WARNING(( "Capture context may not be NULL when dumping blocks." ));
957-
return;
958-
}
959-
create_block_context_protobuf_from_block( block_context_msg, banks, bank, funk, xid, spad );
954+
FD_SPAD_FRAME_BEGIN( spad ) {
955+
if( FD_UNLIKELY( capture_ctx==NULL ) ) {
956+
FD_LOG_WARNING(( "Capture context may not be NULL when dumping blocks." ));
957+
return;
958+
}
959+
create_block_context_protobuf_from_block( block_context_msg, banks, bank, funk, xid, spad );
960+
} FD_SPAD_FRAME_END;
960961
}
961962

962963
void

0 commit comments

Comments
 (0)