LCOV - code coverage report
Current view: top level - flamenco/stakes - fd_stakes.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 6 0.0 %
Date: 2026-08-13 04:56:22 Functions: 0 9 0.0 %

          Line data    Source code
       1             : #ifndef HEADER_fd_src_flamenco_stakes_fd_stakes_h
       2             : #define HEADER_fd_src_flamenco_stakes_fd_stakes_h
       3             : 
       4             : #include "fd_stake_delegations.h"
       5             : #include "fd_stake_types.h"
       6             : #include "fd_stake_weight.h"
       7             : #include "fd_vote_stakes.h"
       8             : #include "../types/fd_cast.h"
       9             : 
      10             : FD_PROTOTYPES_BEGIN
      11             : 
      12             : fd_stake_state_t const *
      13             : fd_stakes_get_state( fd_acc_t const * acc );
      14             : 
      15             : fd_stake_history_entry_t
      16             : stake_activating_and_deactivating( fd_delegation_t const *    self,
      17             :                                    ulong                      target_epoch,
      18             :                                    fd_stake_history_t const * stake_history,
      19             :                                    ulong *                    new_rate_activation_epoch );
      20             : 
      21             : #if FD_HAS_DOUBLE
      22             : /* Caller must ensure cluster_portion is nonzero. */
      23             : 
      24             : static inline ulong
      25             : fd_stake_calculate_change_allowance_float( ulong   current_epoch,
      26             :                                            ulong   account_portion,
      27             :                                            ulong   cluster_portion,
      28             :                                            ulong   cluster_effective,
      29           0 :                                            ulong * new_rate_activation_epoch ) {
      30           0 :   double weight = (double)account_portion / (double)cluster_portion;
      31           0 :   double warmup_cooldown_rate = fd_stake_delegations_warmup_cooldown_rate_to_double( fd_stake_warmup_cooldown_rate( current_epoch, new_rate_activation_epoch ) );
      32           0 :   double newly_changed_cluster_stake = (double)cluster_effective * warmup_cooldown_rate;
      33           0 :   return fd_rust_cast_double_to_ulong( weight * newly_changed_cluster_stake );
      34           0 : }
      35             : #endif /* FD_HAS_DOUBLE */
      36             : 
      37             : ulong
      38             : fd_stake_calculate_activation_allowance( ulong                            current_epoch,
      39             :                                          ulong                            account_activating_stake,
      40             :                                          fd_stake_history_entry_t const * prev_epoch_cluster_state,
      41             :                                          ulong *                          opt_rate_change_activation_epoch );
      42             : 
      43             : /* https://github.com/anza-xyz/agave/blob/v4.2.0-beta.1/runtime/src/stake_delegation.rs#L27-L41 */
      44             : fd_stake_history_entry_t
      45             : fd_delegation_activation_status( fd_delegation_t const *    self,
      46             :                                  ulong                      target_epoch,
      47             :                                  fd_stake_history_t const * stake_history,
      48             :                                  ulong *                    new_rate_activation_epoch,
      49             :                                  int                        use_fixed_point_stake_math );
      50             : 
      51             : fd_stake_history_entry_t
      52             : fd_stakes_activating_and_deactivating( fd_stake_delegation_t const * self,
      53             :                                        ulong                         target_epoch,
      54             :                                        fd_stake_history_t const *    stake_history,
      55             :                                        ulong *                       new_rate_activation_epoch,
      56             :                                        int                           use_fixed_point_stake_math );
      57             : 
      58             : /* fd_stake_weights_by_node converts Stakes (unordered list of (vote
      59             :    acc, active stake) tuples) to an ordered list of (stake, vote pubkey, node
      60             :    identity) sorted by (stake descending, vote pubkey descending).
      61             : 
      62             :    weights points to an array suitable to hold ...
      63             : 
      64             :      fd_vote_accounts_pair_t_map_size( accs->vote_accounts_pool,
      65             :                                        accs->vote_accounts_root )
      66             : 
      67             :    ... items.  On return, weights be an ordered list.
      68             : 
      69             :    Returns the number of items in weights (which is <= no of vote accs). */
      70             : 
      71             : ulong
      72             : fd_stake_weights_by_node( fd_vote_stakes_t const * vote_stakes,
      73             :                           ulong                    fork_id,
      74             :                           int                      use_t_1,
      75             :                           fd_vote_stake_weight_t * weights );
      76             : 
      77             : void
      78             : fd_stakes_activate_epoch( fd_bank_t *                    bank,
      79             :                           fd_runtime_stack_t *           runtime_stack,
      80             :                           fd_accdb_t *                   accdb,
      81             :                           fd_capture_ctx_t *             capture_ctx,
      82             :                           fd_stake_delegations_t *       stake_delegations,
      83             :                           ulong *                        new_rate_activation_epoch );
      84             : 
      85             : void
      86             : fd_refresh_vote_accounts( fd_bank_t *                    bank,
      87             :                           fd_accdb_t *                   accdb,
      88             :                           fd_runtime_stack_t *           runtime_stack,
      89             :                           fd_stake_delegations_t const * stake_delegations,
      90             :                           fd_stake_history_t const *     history,
      91             :                           ulong *                        new_rate_activation_epoch );
      92             : 
      93             : /* fd_stakes_update_delegation is used to maintain the in-memory cache
      94             :    of the stake delegations that is used at the epoch boundary.  Entries
      95             :    in the cache will be inserted/updated/removed based on the state of
      96             :    the stake account. */
      97             : 
      98             : void
      99             : fd_stakes_update_stake_delegation( fd_pubkey_t const * pubkey,
     100             :                                    fd_acc_t const *    acc,
     101             :                                    fd_bank_t *         bank );
     102             : 
     103             : FD_PROTOTYPES_END
     104             : 
     105             : #endif /* HEADER_fd_src_flamenco_stakes_fd_stakes_h */

Generated by: LCOV version 1.14