LCOV - code coverage report
Current view: top level - flamenco/runtime/program - fd_native_cpi.c (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 47 0.0 %
Date: 2025-08-05 05:04:49 Functions: 0 2 0.0 %

          Line data    Source code
       1             : #include "fd_native_cpi.h"
       2             : #include "../fd_borrowed_account.h"
       3             : #include "../fd_executor.h"
       4             : #include "../../vm/syscall/fd_vm_syscall.h"
       5             : #include "../../../util/bits/fd_uwide.h"
       6             : 
       7             : int
       8             : fd_native_cpi_native_invoke( fd_exec_instr_ctx_t *             ctx,
       9             :                              fd_pubkey_t const *               native_program_id,
      10             :                              uchar *                           instr_data,
      11             :                              ulong                             instr_data_len,
      12             :                              fd_vm_rust_account_meta_t const * acct_metas,
      13             :                              ulong                             acct_metas_len,
      14             :                              fd_pubkey_t const *               signers,
      15           0 :                              ulong                             signers_cnt ) {
      16             :   /* Set up the instr info */
      17           0 :   fd_instr_info_t instr_info[ 1 ];
      18           0 :   fd_instruction_account_t instruction_accounts[ FD_INSTR_ACCT_MAX ];
      19           0 :   ulong instruction_accounts_cnt;
      20             : 
      21             :   /* fd_vm_prepare_instruction will handle missing/invalid account case */
      22           0 :   instr_info->program_id = UCHAR_MAX;
      23           0 :   int program_id = fd_exec_txn_ctx_find_index_of_account( ctx->txn_ctx, native_program_id );
      24           0 :   if( FD_LIKELY( program_id!=-1 ) ) {
      25           0 :     instr_info->program_id = (uchar)program_id;
      26           0 :   }
      27             : 
      28           0 :   fd_pubkey_t instr_acct_keys[ FD_INSTR_ACCT_MAX ];
      29           0 :   uchar       acc_idx_seen[ FD_INSTR_ACCT_MAX ];
      30           0 :   memset( acc_idx_seen, 0, FD_INSTR_ACCT_MAX );
      31             : 
      32           0 :   instr_info->acct_cnt = (ushort)acct_metas_len;
      33           0 :   for( ushort j=0U; j<acct_metas_len; j++ ) {
      34           0 :     fd_vm_rust_account_meta_t const * acct_meta     = &acct_metas[j];
      35           0 :     fd_pubkey_t const *               acct_key      = fd_type_pun_const( acct_meta->pubkey );
      36           0 :     instr_acct_keys[j] = *acct_key;
      37             : 
      38           0 :     int idx_in_txn    = fd_exec_txn_ctx_find_index_of_account( ctx->txn_ctx, acct_key );
      39           0 :     int idx_in_caller = fd_exec_instr_ctx_find_idx_of_instr_account( ctx, acct_key );
      40             : 
      41           0 :     fd_instr_info_setup_instr_account( instr_info,
      42           0 :                                        acc_idx_seen,
      43           0 :                                        idx_in_txn!=-1 ? (ushort)idx_in_txn : USHORT_MAX,
      44           0 :                                        idx_in_caller!=-1 ? (ushort)idx_in_caller : USHORT_MAX,
      45           0 :                                        j,
      46           0 :                                        acct_meta->is_writable,
      47           0 :                                        acct_meta->is_signer );
      48           0 :   }
      49             : 
      50           0 :   instr_info->data    = instr_data;
      51           0 :   instr_info->data_sz = (ushort)instr_data_len;
      52             : 
      53             :   /* https://github.com/anza-xyz/agave/blob/v2.2.6/program-runtime/src/invoke_context.rs#L312-L313 */
      54           0 :   int exec_err = fd_vm_prepare_instruction( instr_info,
      55           0 :                                             ctx,
      56           0 :                                             native_program_id,
      57           0 :                                             instr_acct_keys,
      58           0 :                                             instruction_accounts,
      59           0 :                                             &instruction_accounts_cnt,
      60           0 :                                             signers,
      61           0 :                                             signers_cnt );
      62           0 :   if( FD_UNLIKELY( exec_err!=FD_EXECUTOR_INSTR_SUCCESS ) ) {
      63           0 :     return exec_err;
      64           0 :   }
      65             : 
      66             :   /* https://github.com/anza-xyz/agave/blob/v2.2.6/program-runtime/src/invoke_context.rs#L315-L321 */
      67           0 :   return fd_execute_instr( ctx->txn_ctx, instr_info );
      68           0 : }
      69             : 
      70             : void
      71             : fd_native_cpi_create_account_meta( fd_pubkey_t const * key, uchar is_signer,
      72           0 :                                    uchar is_writable, fd_vm_rust_account_meta_t * meta ) {
      73           0 :   meta->is_signer = is_signer;
      74           0 :   meta->is_writable = is_writable;
      75           0 :   fd_memcpy( meta->pubkey, key->key, sizeof(fd_pubkey_t) );
      76           0 : }

Generated by: LCOV version 1.14