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: 2026-09-17 04:28:31 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 "../../fd_flamenco_base.h"
       7             : #include "../../accdb/fd_accdb.h"
       8             : #include "fd_sysvar_base.h"
       9             : 
      10             : /* https://github.com/solana-labs/solana/blob/8f2c8b8388a495d2728909e30460aa40dcc5d733/sdk/program/src/clock.rs#L10 */
      11           0 : #define FD_SYSVAR_CLOCK_DEFAULT_HASHES_PER_TICK (12500UL)
      12             : 
      13             : /* ts_est_ele_t is a temporary struct used for sorting vote accounts by
      14             :    last vote timestamp for clock sysvar calculation. */
      15             : struct ts_est_ele {
      16             :   long        timestamp;
      17             :   fd_w_u128_t stake; /* should really be fine as ulong, but we match Agave */
      18             : };
      19             : typedef struct ts_est_ele ts_est_ele_t;
      20             : 
      21             : /* The clock sysvar provides an approximate measure of network time. */
      22             : 
      23             : /* fd_sysvar_clock_init initializes the sysvar account to genesis state. */
      24             : 
      25             : FD_PROTOTYPES_BEGIN
      26             : 
      27             : void
      28             : fd_sysvar_clock_init( fd_bank_t *        bank,
      29             :                       fd_accdb_t *       accdb,
      30             :                       fd_capture_ctx_t * capture_ctx );
      31             : 
      32             : /* fd_sysvar_clock_read reads the current value of the clock sysvar at
      33             :    fork_id into *clock.  Returns clock on success, NULL if the account
      34             :    is missing or too small. */
      35             : 
      36             : fd_sol_sysvar_clock_t *
      37             : fd_sysvar_clock_read( fd_accdb_t *            accdb,
      38             :                       fd_accdb_fork_id_t      fork_id,
      39             :                       fd_sol_sysvar_clock_t * clock );
      40             : 
      41             : /* fd_sysvar_clock_update updates the clock sysvar account.  Runs
      42             :    fd_calculate_stake_weighted_timestamp under the hood.  Should be
      43             :    called at the start of every slot before execution commences.  Takes
      44             :    in a pointer to the parent_epoch, where *parent_epoch is the epoch of
      45             :    the parent slot.  parent_epoch = NULL is used for genesis bootup.
      46             :    Crashes the process with FD_LOG_ERR on failure. */
      47             : 
      48             : void
      49             : fd_sysvar_clock_update( fd_bank_t *          bank,
      50             :                         fd_accdb_t *         accdb,
      51             :                         fd_capture_ctx_t *   capture_ctx,
      52             :                         fd_runtime_stack_t * runtime_stack,
      53             :                         ulong const *        parent_epoch );
      54             : 
      55             : /* fd_sysvar_clock_update_slot_for_alpenglow advances the clock sysvar's
      56             :    slot, epoch and leader_schedule_epoch at the start of an alpenglow
      57             :    block, without the stake-weighted timestamp calculation.
      58             : 
      59             :    https://github.com/anza-xyz/agave/blob/386cf57c45e135d8a3a8b7d16877eb896f695c64/runtime/src/bank.rs#L2507
      60             : 
      61             :    At an epoch boundary the parent's timestamp becomes the epoch start
      62             :    timestamp. */
      63             : 
      64             : void
      65             : fd_sysvar_clock_update_slot_alpenglow( fd_bank_t *        bank,
      66             :                                        fd_accdb_t *       accdb,
      67             :                                        fd_capture_ctx_t * capture_ctx );
      68             : 
      69             : FD_PROTOTYPES_END
      70             : 
      71             : #endif /* HEADER_fd_src_flamenco_runtime_sysvar_fd_sysvar_clock_h */

Generated by: LCOV version 1.14