LCOV - code coverage report
Current view: top level - flamenco/runtime/sysvar - fd_sysvar.c (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 11 11 100.0 %
Date: 2026-07-27 05:36:01 Functions: 2 2 100.0 %

          Line data    Source code
       1             : #include "fd_sysvar.h"
       2             : #include "../fd_system_ids.h"
       3             : #include "../fd_runtime.h"
       4             : #include "../fd_accdb_svm.h"
       5             : #include "fd_sysvar_rent.h"
       6             : 
       7             : /* https://github.com/anza-xyz/agave/blob/v3.1/runtime/src/bank.rs#L2025 */
       8             : 
       9             : void
      10             : fd_sysvar_account_update( fd_bank_t *         bank,
      11             :                           fd_accdb_t *        accdb,
      12             :                           fd_capture_ctx_t *  capture_ctx,
      13             :                           fd_pubkey_t const * address,
      14             :                           void const *        data,
      15        6024 :                           ulong               sz ) {
      16             :   /* Newly created sysvar accounts get at least 1 lamport and
      17             :      capitalization increases by that amount.  In Agave,
      18             :      adjust_sysvar_balance_for_rent() does max(rent_exempt_min,
      19             :      current_lamports), which in this case would yield 1 instead of 0. */
      20        6024 :   ulong min_bal = fd_ulong_max( fd_rent_exempt_minimum_balance( &bank->f.rent, sz ), 1UL );
      21        6024 :   fd_accdb_svm_write( bank, accdb, capture_ctx, address, &fd_sysvar_owner_id, data, sz, min_bal, 0 );
      22        6024 : }
      23             : 
      24             : int
      25             : fd_sysvar_instr_acct_check( fd_exec_instr_ctx_t const * ctx,
      26             :                             ulong                       idx,
      27          51 :                             fd_pubkey_t const *         addr_want ) {
      28          51 :   if( FD_UNLIKELY( idx>=ctx->instr->acct_cnt ) ) return FD_EXECUTOR_INSTR_ERR_MISSING_ACC;
      29             : 
      30          51 :   ushort idx_in_txn = ctx->instr->accounts[ idx ].index_in_transaction;
      31          51 :   uchar const * addr_have = ctx->txn_out->accounts.keys[ idx_in_txn ].uc;
      32          51 :   if( FD_UNLIKELY( memcmp( addr_have, addr_want, 32UL ) ) ) return FD_EXECUTOR_INSTR_ERR_INVALID_ARG;
      33             : 
      34          51 :   return FD_EXECUTOR_INSTR_SUCCESS;
      35          51 : }

Generated by: LCOV version 1.14