LCOV - code coverage report
Current view: top level - flamenco/runtime/sysvar - fd_sysvar_rent1.c (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 8 8 100.0 %
Date: 2026-08-25 04:35:19 Functions: 1 1 100.0 %

          Line data    Source code
       1             : #include "fd_sysvar_rent.h"
       2             : #include "../../types/fd_cast.h"
       3             : 
       4             : /* https://github.com/anza-xyz/solana-sdk/blob/rent%40v4.2.1/rent/src/lib.rs#L86 */
       5       54273 : #define ACCOUNT_STORAGE_OVERHEAD (128UL)
       6             : 
       7             : /* Bit patterns of 1.0 and 2.0, the two exemption thresholds computed in
       8             :    integer arithmetic.
       9             :    https://github.com/anza-xyz/solana-sdk/blob/rent%40v4.2.1/rent/src/lib.rs#L59-L66 */
      10             : 
      11             : #define EXEMPTION_THRESHOLD_1_BITS (0x3ff0000000000000UL)
      12             : #define EXEMPTION_THRESHOLD_2_BITS (0x4000000000000000UL)
      13             : 
      14             : ulong
      15             : fd_rent_exempt_minimum_balance( fd_rent_t const * rent,
      16       54273 :                                 ulong             data_len ) {
      17       54273 :   ulong bytes = data_len + ACCOUNT_STORAGE_OVERHEAD;
      18             : 
      19             :   /* For thresholds 1.0 and 2.0 the product is exact in integer
      20             :      arithmetic, whereas the double round trip below rounds it once it
      21             :      exceeds 2^53.  The threshold is matched bit-for-bit, as upstream
      22             :      compares the raw 8 bytes.
      23             :      https://github.com/anza-xyz/solana-sdk/blob/rent%40v4.2.1/rent/src/lib.rs#L136-L162 */
      24             : 
      25       54273 :   ulong threshold_bits = fd_dblbits( rent->exemption_threshold );
      26       54273 :   if( FD_LIKELY( threshold_bits==EXEMPTION_THRESHOLD_1_BITS ) ) return       bytes * rent->lamports_per_uint8_year;
      27       53337 :   if( FD_LIKELY( threshold_bits==EXEMPTION_THRESHOLD_2_BITS ) ) return 2UL * bytes * rent->lamports_per_uint8_year;
      28             : 
      29          57 :   return fd_rust_cast_double_to_ulong( (double)( bytes * rent->lamports_per_uint8_year ) * rent->exemption_threshold );
      30       53337 : }

Generated by: LCOV version 1.14