LCOV - code coverage report
Current view: top level - flamenco/runtime - fd_cost_tracker.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 11 0.0 %
Date: 2025-03-20 12:08:36 Functions: 0 0 -

          Line data    Source code
       1             : #ifndef HEADER_fd_src_flamenco_runtime_fd_cost_tracker_h
       2             : #define HEADER_fd_src_flamenco_runtime_fd_cost_tracker_h
       3             : 
       4             : /* Combined logic from Agave's `cost_model.rs` and `cost_tracker.rs` for validating
       5             :    block limits, specifically during replay. */
       6             : 
       7             : #include "../vm/fd_vm_base.h"
       8             : #include "fd_system_ids.h"
       9             : #include "fd_executor.h"
      10             : #include "../../disco/pack/fd_pack.h"
      11             : #include "../../disco/pack/fd_pack_cost.h"
      12             : 
      13             : // https://github.com/anza-xyz/agave/blob/v2.2.0/cost-model/src/block_cost_limits.rs#L20
      14           0 : #define FD_WRITE_LOCK_UNITS ( 300UL )
      15             : 
      16             : // https://github.com/anza-xyz/agave/blob/v2.2.0/cost-model/src/block_cost_limits.rs#L42
      17             : #define FD_MAX_BLOCK_ACCOUNTS_DATA_SIZE_DELTA ( 100000000UL )
      18             : 
      19             : // https://github.com/anza-xyz/agave/blob/v2.2.0/cost-model/src/block_cost_limits.rs#L34
      20           0 : #define FD_MAX_WRITABLE_ACCOUNT_UNITS ( 12000000UL )
      21             : 
      22             : // https://github.com/anza-xyz/agave/blob/v2.2.0/cost-model/src/block_cost_limits.rs#L28
      23           0 : #define FD_MAX_BLOCK_UNITS ( 48000000UL )
      24             : 
      25             : // https://github.com/anza-xyz/agave/blob/v2.2.0/cost-model/src/block_cost_limits.rs#L29C11-L29C36
      26           0 : #define FD_MAX_BLOCK_UNITS_SIMD_0207 ( 50000000UL )
      27             : 
      28             : // https://github.com/anza-xyz/agave/blob/v2.2.0/cost-model/src/block_cost_limits.rs#L38
      29           0 : #define FD_MAX_VOTE_UNITS ( 36000000UL )
      30             : 
      31             : // https://github.com/anza-xyz/agave/blob/v2.2.0/cost-model/src/cost_tracker.rs#L15
      32           0 : #define FD_WRITABLE_ACCOUNTS_PER_BLOCK ( 4096UL )
      33             : 
      34             : /* https://github.com/anza-xyz/agave/blob/v2.2.0/cost-model/src/cost_tracker.rs#L18-L33 */
      35           0 : #define FD_COST_TRACKER_SUCCESS                                     ( 0 )
      36           0 : #define FD_COST_TRACKER_ERROR_WOULD_EXCEED_BLOCK_MAX_LIMIT          ( 1 )
      37           0 : #define FD_COST_TRACKER_ERROR_WOULD_EXCEED_VOTE_MAX_LIMIT           ( 2 )
      38           0 : #define FD_COST_TRACKER_ERROR_WOULD_EXCEED_ACCOUNT_MAX_LIMIT        ( 3 )
      39           0 : #define FD_COST_TRACKER_ERROR_WOULD_EXCEED_ACCOUNT_DATA_BLOCK_LIMIT ( 4 )
      40             : #define FD_COST_TRACKER_ERROR_WOULD_EXCEED_ACCOUNT_DATA_TOTAL_LIMIT ( 5 )
      41             : 
      42             : FD_PROTOTYPES_BEGIN
      43             : 
      44             : /* Initializes the cost tracker and allocates enough memory for the map */
      45             : void
      46             : fd_cost_tracker_init( fd_cost_tracker_t *        self,
      47             :                       fd_exec_slot_ctx_t const * slot_ctx,
      48             :                       fd_spad_t *                spad );
      49             : 
      50             : /* Modeled after `CostModel::calculate_cost_for_executed_transaction()`.
      51             :    Used to compute transaction cost information for executed transactions.
      52             : 
      53             :    https://github.com/anza-xyz/agave/blob/v2.2.0/cost-model/src/cost_model.rs#L69-L95 */
      54             : fd_transaction_cost_t
      55             : fd_calculate_cost_for_executed_transaction( fd_exec_txn_ctx_t const * txn_ctx,
      56             :                                             fd_spad_t *               spad );
      57             : 
      58             : /* Modeled after `CostTracker::try_add()`. Checks to see if the transaction cost
      59             :    would fit in this block. Returns an error on failure.
      60             : 
      61             :     https://github.com/anza-xyz/agave/blob/v2.2.0/cost-model/src/cost_tracker.rs#L163-L173 */
      62             : int
      63             : fd_cost_tracker_try_add( fd_cost_tracker_t *           self,
      64             :                          fd_exec_txn_ctx_t const *     txn_ctx,
      65             :                          fd_transaction_cost_t const * tx_cost );
      66             : 
      67             : FD_PROTOTYPES_END
      68             : 
      69             : #endif /* HEADER_fd_src_flamenco_runtime_fd_cost_tracker_h */

Generated by: LCOV version 1.14