LCOV - code coverage report
Current view: top level - flamenco/runtime/context - fd_exec_instr_ctx.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 10 12 83.3 %
Date: 2025-01-08 12:08:44 Functions: 7 83 8.4 %

          Line data    Source code
       1             : #ifndef HEADER_fd_src_flamenco_runtime_context_fd_exec_instr_ctx_h
       2             : #define HEADER_fd_src_flamenco_runtime_context_fd_exec_instr_ctx_h
       3             : 
       4             : #include "../../fd_flamenco_base.h"
       5             : #include "../info/fd_instr_info.h"
       6             : #include "../fd_acc_mgr.h"
       7             : #include "../fd_executor_err.h"
       8             : 
       9             : /* fd_exec_instr_ctx_t is the context needed to execute a single
      10             :    instruction (program invocation). */
      11             : 
      12             : struct __attribute__((aligned(8UL))) fd_exec_instr_ctx {
      13             :   ulong magic; /* ==FD_EXEC_INSTR_CTX_MAGIC */
      14             : 
      15             :   fd_exec_epoch_ctx_t const * epoch_ctx;
      16             :   fd_exec_slot_ctx_t const *  slot_ctx; /* TODO: needs to be made const to be thread safe. */
      17             :   fd_exec_txn_ctx_t *         txn_ctx;  /* The transaction context for this instruction */
      18             : 
      19             :   fd_exec_instr_ctx_t const * parent;
      20             : 
      21             :   uint depth;      /* starts at 0 */
      22             :   uint index;      /* number of preceding instructions with same parent */
      23             :   uint child_cnt;  /* number of child instructions */
      24             :   uint instr_err;  /* TODO: this is kind of redundant wrt instr_exec */
      25             : 
      26             :   fd_funk_txn_t * funk_txn;
      27             :   fd_acc_mgr_t *  acc_mgr;
      28             : 
      29             :   /* Most instructions log the base58 program id multiple times, so it's
      30             :      convenient to compute it once and reuse it. */
      31             :   char program_id_base58[ FD_BASE58_ENCODED_32_SZ ];
      32             : 
      33             :   fd_instr_info_t const * instr;
      34             : };
      35             : 
      36        7665 : #define FD_EXEC_INSTR_CTX_ALIGN     (alignof(fd_exec_instr_ctx_t))
      37       15330 : #define FD_EXEC_INSTR_CTX_FOOTPRINT (sizeof (fd_exec_instr_ctx_t))
      38        7665 : #define FD_EXEC_INSTR_CTX_MAGIC (0x18964FC6EDAAC5A8UL) /* random */
      39             : 
      40             : FD_PROTOTYPES_BEGIN
      41             : 
      42             : /* Constructors */
      43             : 
      44             : void *
      45             : fd_exec_instr_ctx_new( void * mem );
      46             : 
      47             : fd_exec_instr_ctx_t *
      48             : fd_exec_instr_ctx_join( void * mem );
      49             : 
      50             : void *
      51             : fd_exec_instr_ctx_leave( fd_exec_instr_ctx_t * ctx );
      52             : 
      53             : void *
      54             : fd_exec_instr_ctx_delete( void * mem );
      55             : 
      56             : /* Helpers for borrowing instruction accounts */
      57             : 
      58             : static inline int
      59             : fd_instr_borrowed_account_view_idx( fd_exec_instr_ctx_t const * ctx,
      60             :                                     ulong                       idx,
      61       89685 :                                     fd_borrowed_account_t **    account ) {
      62       89685 :   if( FD_UNLIKELY( idx >= ctx->instr->acct_cnt ) ) {
      63           0 :     return FD_ACC_MGR_ERR_UNKNOWN_ACCOUNT;
      64           0 :   }
      65             : 
      66       89685 :   fd_borrowed_account_t * instr_account = ctx->instr->borrowed_accounts[idx];
      67       89685 :   FD_TEST( instr_account->const_meta != NULL );
      68       89685 :   *account = instr_account;
      69       89685 :   return FD_ACC_MGR_SUCCESS;
      70       89685 : }
      71             : 
      72             : int
      73             : fd_instr_borrowed_account_view( fd_exec_instr_ctx_t *    ctx,
      74             :                                 fd_pubkey_t const *      pubkey,
      75             :                                 fd_borrowed_account_t ** account );
      76             : 
      77             : int
      78             : fd_instr_borrowed_account_modify_idx( fd_exec_instr_ctx_t const * ctx,
      79             :                                       ulong                       idx,
      80             :                                       ulong                       min_data_sz,
      81             :                                       fd_borrowed_account_t **    account );
      82             : 
      83             : int
      84             : fd_instr_borrowed_account_modify( fd_exec_instr_ctx_t *    ctx,
      85             :                                   fd_pubkey_t const *      pubkey,
      86             :                                   ulong                    min_data_sz,
      87             :                                   fd_borrowed_account_t ** account );
      88             : 
      89             : FD_PROTOTYPES_END
      90             : 
      91             : #endif /* HEADER_fd_src_flamenco_runtime_context_fd_exec_instr_ctx_h */

Generated by: LCOV version 1.14