LCOV - code coverage report
Current view: top level - flamenco/runtime/sysvar - fd_sysvar_clock.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 1 0.0 %
Date: 2025-10-27 04:40:00 Functions: 0 0 -

          Line data    Source code
       1             : #ifndef HEADER_fd_src_flamenco_runtime_sysvar_fd_sysvar_clock_h
       2             : #define HEADER_fd_src_flamenco_runtime_sysvar_fd_sysvar_clock_h
       3             : 
       4             : /* The clock sysvar provides an approximate measure of network time. */
       5             : 
       6             : #include "../../types/fd_types.h"
       7             : #include "../../accdb/fd_accdb_user.h"
       8             : 
       9             : /* https://github.com/solana-labs/solana/blob/8f2c8b8388a495d2728909e30460aa40dcc5d733/sdk/program/src/clock.rs#L10 */
      10             : #define FD_SYSVAR_CLOCK_DEFAULT_TICKS_PER_SECOND ( 160UL )
      11           0 : #define FD_SYSVAR_CLOCK_DEFAULT_HASHES_PER_TICK  (12500UL)
      12             : 
      13             : /* FD_SYSVAR_CLOCK_STAKE_WEIGHTS_MAX specifies the max number of stake
      14             :    weights processed in a clock update. */
      15             : 
      16             : #define FD_SYSVAR_CLOCK_STAKE_WEIGHTS_MAX (10240UL)
      17             : 
      18             : FD_PROTOTYPES_BEGIN
      19             : 
      20             : /* ts_est_ele_t is a temporary struct used for sorting vote accounts by
      21             :    last vote timestamp for clock sysvar calculation. */
      22             : struct ts_est_ele {
      23             :   long    timestamp;
      24             :   uint128 stake; /* should really be fine as ulong, but we match Agave */
      25             : };
      26             : typedef struct ts_est_ele ts_est_ele_t;
      27             : 
      28             : /* The clock sysvar provides an approximate measure of network time. */
      29             : 
      30             : /* fd_sysvar_clock_init initializes the sysvar account to genesis state. */
      31             : 
      32             : void
      33             : fd_sysvar_clock_init( fd_bank_t *               bank,
      34             :                       fd_accdb_user_t *         accdb,
      35             :                       fd_funk_txn_xid_t const * xid,
      36             :                       fd_capture_ctx_t *        capture_ctx );
      37             : 
      38             : /* fd_sysvar_clock_update updates the clock sysvar account.  Runs
      39             :    fd_calculate_stake_weighted_timestamp under the hood.  Should be
      40             :    called at the start of every slot before execution commences.  Takes
      41             :    in a pointer to the parent_epoch, where *parent_epoch is the epoch of
      42             :    the parent slot.  parent_epoch = NULL is used for genesis bootup.
      43             :    Crashes the process with FD_LOG_ERR on failure. */
      44             : 
      45             : void
      46             : fd_sysvar_clock_update( fd_bank_t *               bank,
      47             :                         fd_accdb_user_t *         accdb,
      48             :                         fd_funk_txn_xid_t const * xid,
      49             :                         fd_capture_ctx_t *        capture_ctx,
      50             :                         fd_runtime_stack_t *      runtime_stack,
      51             :                         ulong const *             parent_epoch );
      52             : 
      53             : /* Writes the current value of the clock sysvar to funk. */
      54             : 
      55             : void
      56             : fd_sysvar_clock_write( fd_bank_t *               bank,
      57             :                        fd_accdb_user_t *         accdb,
      58             :                        fd_funk_txn_xid_t const * xid,
      59             :                        fd_capture_ctx_t *        capture_ctx,
      60             :                        fd_sol_sysvar_clock_t *   clock );
      61             : 
      62             : /* fd_sysvar_clock_read reads the current value of the rent sysvar from
      63             :    funk. If the account doesn't exist in funk or if the account
      64             :    has zero lamports, this function returns NULL. */
      65             : 
      66             : fd_sol_sysvar_clock_t *
      67             : fd_sysvar_clock_read( fd_funk_t *               funk,
      68             :                       fd_funk_txn_xid_t const * xid,
      69             :                       fd_sol_sysvar_clock_t *   clock );
      70             : 
      71             : FD_PROTOTYPES_END
      72             : 
      73             : #endif /* HEADER_fd_src_flamenco_runtime_sysvar_fd_sysvar_clock_h */

Generated by: LCOV version 1.14