LCOV - code coverage report
Current view: top level - ballet/txn - fd_txn_v1.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 16 16 100.0 %
Date: 2026-08-14 04:54:57 Functions: 1 161 0.6 %

          Line data    Source code
       1             : #ifndef HEADER_fd_src_ballet_txn_fd_txn_v1_h
       2             : #define HEADER_fd_src_ballet_txn_fd_txn_v1_h
       3             : 
       4             : #include "../fd_ballet_base.h"
       5             : 
       6             : /* FD_TXN_V1_DEFAULT_HEAP_SZ: V1 transactions that do not explicitly
       7             :    set their requested heap size using the config mask
       8             :    use a default 32 KiB requested heap size as per SIMD 385. */
       9          12 : #define FD_TXN_V1_DEFAULT_HEAP_SZ (32UL*1024UL)
      10             : 
      11             : /* Max/min bounds and the allowed granularity for the requested heap
      12             :    size as per SIMD 385. */
      13             : #define FD_TXN_V1_MIN_HEAP_SZ      (32UL *1024UL)
      14             : #define FD_TXN_V1_MAX_HEAP_SZ      (256UL*1024UL)
      15             : #define FD_TXN_V1_HEAP_GRANULARITY (1024UL)
      16             : 
      17             : FD_PROTOTYPES_BEGIN
      18             : 
      19             : /* fd_txn_parse_v1_config decodes the four compute-budget fields
      20             :    V1 transactions specify using the given config mask and config
      21             :    values.
      22             : 
      23             :    config_mask is the transaction config mask. Only bits 0-4 will be
      24             :    set.
      25             : 
      26             :    config_values is a pointer to the start of the config values
      27             :    region.  This contains only the config values that the config mask
      28             :    indicates are present, packed in little-endian, in ascending bit
      29             :    order.
      30             : 
      31             :    The results of the parsing are written to the
      32             :    out_priority_fee_lamports, out_compute_unit_limit,
      33             :    out_loaded_accounts_data_sz_limit and out_heap_size fields.  If a
      34             :    field is not specified by the config mask the defaults as per
      35             :    SIMD 385 are used.
      36             : 
      37             :    https://github.com/anza-xyz/agave/blob/v4.2.0-beta.1/runtime-transaction/src/runtime_transaction/transaction_view.rs#L98-L107 */
      38             : static inline void
      39             : fd_txn_parse_v1_config( uint           config_mask,
      40             :                         uchar const *  config_values,
      41             :                         ulong *        out_priority_fee_lamports,
      42             :                         ulong *        out_compute_unit_limit,
      43             :                         ulong *        out_loaded_accounts_data_sz_limit,
      44          12 :                         ulong *        out_heap_size ) {
      45             : 
      46             :   /* Default values as per SIMD 385 */
      47          12 :   ulong priority_fee = 0UL;
      48          12 :   ulong cu_limit     = 0UL;
      49          12 :   ulong lads_limit   = 0UL;
      50          12 :   ulong heap         = FD_TXN_V1_DEFAULT_HEAP_SZ;
      51             : 
      52          12 :   uchar const * v = config_values;
      53             :   /* Priority fee is a ulong, the rest are uint */
      54          12 :   if(  config_mask    & 1U ) { priority_fee = FD_LOAD( ulong, v ); v += 8UL; }
      55          12 :   if( (config_mask>>2)& 1U ) { cu_limit     = FD_LOAD( uint,  v ); v += 4UL; }
      56          12 :   if( (config_mask>>3)& 1U ) { lads_limit   = FD_LOAD( uint,  v ); v += 4UL; }
      57          12 :   if( (config_mask>>4)& 1U ) { heap         = FD_LOAD( uint,  v );           }
      58             : 
      59          12 :   *out_priority_fee_lamports         = priority_fee;
      60          12 :   *out_compute_unit_limit            = cu_limit;
      61          12 :   *out_loaded_accounts_data_sz_limit = lads_limit;
      62          12 :   *out_heap_size                     = heap;
      63          12 : }
      64             : 
      65             : FD_PROTOTYPES_END
      66             : 
      67             : #endif /* HEADER_fd_src_ballet_txn_fd_txn_v1_h */

Generated by: LCOV version 1.14