Line data Source code
1 : #ifndef HEADER_fd_src_flamenco_runtime_context_fd_capture_ctx_h 2 : #define HEADER_fd_src_flamenco_runtime_context_fd_capture_ctx_h 3 : 4 : #include "../../capture/fd_solcap_writer.h" 5 : #include "../fd_runtime_const.h" 6 : 7 : /* fd_capture_ctx_account_update_msg_t is the message sent from 8 : exec tile to replay tile that notifies the solcap writer that an 9 : account update has occurred. */ 10 : 11 : struct __attribute__((packed)) fd_capture_ctx_account_update_msg { 12 : fd_pubkey_t pubkey; 13 : fd_solana_account_meta_t info; 14 : ulong data_sz; 15 : fd_hash_t hash; 16 : ulong bank_idx; 17 : /* Account data follows immediately after this struct */ 18 : }; 19 : typedef struct fd_capture_ctx_account_update_msg fd_capture_ctx_account_update_msg_t; 20 0 : #define FD_CAPTURE_CTX_ACCOUNT_UPDATE_MSG_FOOTPRINT (FD_RUNTIME_ACC_SZ_MAX + sizeof(fd_capture_ctx_account_update_msg_t)) 21 : 22 : /* Maximum number of accounts that can be updated in a single transaction */ 23 : #define FD_CAPTURE_CTX_MAX_ACCOUNT_UPDATES (128UL) 24 : #define FD_CAPTURE_CTX_ACCOUNT_UPDATE_BUFFER_SZ (FD_CAPTURE_CTX_MAX_ACCOUNT_UPDATES * FD_CAPTURE_CTX_ACCOUNT_UPDATE_MSG_FOOTPRINT) 25 0 : #define FD_CAPTURE_CTX_ACCOUNT_UPDATE_BUFFER_ALIGN (8UL) 26 : 27 : /* Context needed to do solcap capture during execution of transactions */ 28 : struct fd_capture_ctx { 29 : ulong magic; /* ==FD_CAPTURE_CTX_MAGIC */ 30 : 31 : /* Solcap */ 32 : ulong solcap_start_slot; 33 : int trace_dirfd; 34 : int trace_mode; 35 : fd_solcap_writer_t * capture; 36 : int capture_txns; /* Capturing txns can add significant time */ 37 : 38 : /* Checkpointing */ 39 : ulong checkpt_freq; /* Must be a rooted slot */ 40 : char const * checkpt_path; /* Wksp checkpoint format */ 41 : char const * checkpt_archive; /* Funk archive format */ 42 : 43 : /*======== PROTOBUF ========*/ 44 : char const * dump_proto_output_dir; 45 : char const * dump_proto_sig_filter; 46 : ulong dump_proto_start_slot; 47 : 48 : /* Instruction Capture */ 49 : int dump_instr_to_pb; 50 : 51 : /* Transaction Capture */ 52 : int dump_txn_to_pb; 53 : 54 : /* Block Capture */ 55 : int dump_block_to_pb; 56 : 57 : /* Syscall Capture */ 58 : int dump_syscall_to_pb; 59 : 60 : /* ELF Capture */ 61 : int dump_elf_to_pb; 62 : 63 : /* Account update buffer, account updates to be sent over the exec_replay link are buffered here 64 : to avoid passing stem down into the runtime. 65 : 66 : FIXME: write directly into the dcache to avoid the memory copy and allocation 67 : TODO: remove this when solcap v2 is here. */ 68 : uchar * account_updates_buffer; 69 : uchar * account_updates_buffer_ptr; 70 : ulong account_updates_len; 71 : }; 72 : typedef struct fd_capture_ctx fd_capture_ctx_t; 73 : 74 : static inline ulong 75 0 : fd_capture_ctx_align( void ) { 76 0 : return fd_ulong_max( alignof(fd_capture_ctx_t), 77 0 : fd_ulong_max( fd_solcap_writer_align(), FD_CAPTURE_CTX_ACCOUNT_UPDATE_BUFFER_ALIGN )); 78 0 : } 79 : 80 : static inline ulong 81 0 : fd_capture_ctx_footprint( void ) { 82 0 : ulong l = FD_LAYOUT_INIT; 83 0 : l = FD_LAYOUT_APPEND( l, fd_capture_ctx_align(), sizeof(fd_capture_ctx_t) ); 84 0 : l = FD_LAYOUT_APPEND( l, fd_solcap_writer_align(), fd_solcap_writer_footprint() ); 85 0 : l = FD_LAYOUT_APPEND( l, 8UL, FD_CAPTURE_CTX_ACCOUNT_UPDATE_BUFFER_SZ ); 86 0 : return FD_LAYOUT_FINI( l, fd_capture_ctx_align() ); 87 0 : } 88 : 89 0 : #define FD_CAPTURE_CTX_MAGIC (0x193ECD2A6C395195UL) /* random */ 90 : 91 : FD_PROTOTYPES_BEGIN 92 : 93 : void * 94 : fd_capture_ctx_new( void * mem ); 95 : 96 : fd_capture_ctx_t * 97 : fd_capture_ctx_join( void * mem ); 98 : 99 : void * 100 : fd_capture_ctx_leave( fd_capture_ctx_t * ctx ); 101 : 102 : void * 103 : fd_capture_ctx_delete( void * mem ); 104 : 105 : /* Temporary locks to protect the blockstore txn_map. See comment in 106 : fd_runtime_write_transaction_status. */ 107 : void 108 : fd_capture_ctx_txn_status_start_read( void ); 109 : 110 : void 111 : fd_capture_ctx_txn_status_end_read( void ); 112 : 113 : void 114 : fd_capture_ctx_txn_status_start_write( void ); 115 : 116 : void 117 : fd_capture_ctx_txn_status_end_write( void ); 118 : 119 : FD_PROTOTYPES_END 120 : 121 : #endif /* HEADER_fd_src_flamenco_runtime_context_fd_capture_ctx_h */