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: 12 12 100.0 %
Date: 2024-11-13 11:58:15 Functions: 9 77 11.7 %

          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             :   fd_valloc_t     valloc;
      29             : 
      30             :   /* Most instructions log the base58 program id multiple times, so it's
      31             :      convenient to compute it once and reuse it. */
      32             :   char program_id_base58[ FD_BASE58_ENCODED_32_SZ ];
      33             : 
      34             :   fd_instr_info_t const * instr;
      35             : };
      36             : 
      37        4407 : #define FD_EXEC_INSTR_CTX_ALIGN     (alignof(fd_exec_instr_ctx_t))
      38        8814 : #define FD_EXEC_INSTR_CTX_FOOTPRINT (sizeof (fd_exec_instr_ctx_t))
      39        4407 : #define FD_EXEC_INSTR_CTX_MAGIC (0x18964FC6EDAAC5A8UL) /* random */
      40             : 
      41             : FD_PROTOTYPES_BEGIN
      42             : 
      43             : /* Constructors */
      44             : 
      45             : void *
      46             : fd_exec_instr_ctx_new( void * mem );
      47             : 
      48             : fd_exec_instr_ctx_t *
      49             : fd_exec_instr_ctx_join( void * mem );
      50             : 
      51             : void *
      52             : fd_exec_instr_ctx_leave( fd_exec_instr_ctx_t * ctx );
      53             : 
      54             : void *
      55             : fd_exec_instr_ctx_delete( void * mem );
      56             : 
      57             : /* Helpers for borrowing instruction accounts */
      58             : 
      59             : static inline int
      60             : fd_instr_borrowed_account_view_idx( fd_exec_instr_ctx_t const * ctx,
      61             :                                     ulong                       idx,
      62      113217 :                                     fd_borrowed_account_t **    account ) {
      63      113217 :   if( FD_UNLIKELY( idx >= ctx->instr->acct_cnt ) ) {
      64          18 :     return FD_ACC_MGR_ERR_UNKNOWN_ACCOUNT;
      65          18 :   }
      66             : 
      67      113199 :   fd_borrowed_account_t * instr_account = ctx->instr->borrowed_accounts[idx];
      68      113199 :   FD_TEST( instr_account->const_meta != NULL );
      69      113199 :   *account = instr_account;
      70      113199 :   return FD_ACC_MGR_SUCCESS;
      71      113199 : }
      72             : 
      73             : int
      74             : fd_instr_borrowed_account_view( fd_exec_instr_ctx_t *    ctx,
      75             :                                 fd_pubkey_t const *      pubkey,
      76             :                                 fd_borrowed_account_t ** account );
      77             : 
      78             : int
      79             : fd_instr_borrowed_account_modify_idx( fd_exec_instr_ctx_t const * ctx,
      80             :                                       ulong                       idx,
      81             :                                       ulong                       min_data_sz,
      82             :                                       fd_borrowed_account_t **    account );
      83             : 
      84             : int
      85             : fd_instr_borrowed_account_modify( fd_exec_instr_ctx_t *    ctx,
      86             :                                   fd_pubkey_t const *      pubkey,
      87             :                                   ulong                    min_data_sz,
      88             :                                   fd_borrowed_account_t ** account );
      89             : 
      90             : FD_PROTOTYPES_END
      91             : 
      92             : #endif /* HEADER_fd_src_flamenco_runtime_context_fd_exec_instr_ctx_h */

Generated by: LCOV version 1.14