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

          Line data    Source code
       1             : #ifndef HEADER_fd_src_flamenco_runtime_context_fd_exec_epoch_ctx_h
       2             : #define HEADER_fd_src_flamenco_runtime_context_fd_exec_epoch_ctx_h
       3             : 
       4             : #include "../../features/fd_features.h"
       5             : #include "../../leaders/fd_leaders.h"
       6             : #include "../fd_bank_hash_cmp.h"
       7             : #include "../fd_rent_lists.h"
       8             : 
       9             : /* fd_exec_epoch_ctx_t is the context that stays constant throughout
      10             :    an entire epoch. */
      11             : 
      12             : struct fd_exec_epoch_ctx_layout {
      13             :   ulong vote_acc_max;
      14             :   ulong footprint;
      15             : 
      16             :   ulong stake_votes_off;
      17             :   ulong stake_delegations_off;
      18             :   ulong next_epoch_stakes_off;
      19             :   ulong leaders_off; /* Current epoch only */
      20             : };
      21             : 
      22             : typedef struct fd_exec_epoch_ctx_layout fd_exec_epoch_ctx_layout_t;
      23             : 
      24             : typedef struct fd_runtime_public fd_runtime_public_t;
      25             : 
      26             : struct __attribute__((aligned(64UL))) fd_exec_epoch_ctx {
      27             :   ulong                      magic; /* ==FD_EXEC_EPOCH_CTX_MAGIC */
      28             : 
      29             :   fd_exec_epoch_ctx_layout_t layout;
      30             : 
      31             :   fd_features_t              features;
      32             :   fd_epoch_bank_t            epoch_bank;
      33             : 
      34             :   fd_bank_hash_cmp_t       * bank_hash_cmp;
      35             :   fd_runtime_public_t      * replay_public;
      36             :   int                        constipate_root; /* Used for constipation in offline replay .*/
      37             :   ulong                      total_epoch_stake;
      38             : };
      39             : 
      40        7665 : #define FD_EXEC_EPOCH_CTX_ALIGN (alignof(fd_exec_epoch_ctx_t))
      41           0 : #define FD_EXEC_EPOCH_CTX_MAGIC (0x3E64F44C9F44366AUL) /* random */
      42             : 
      43             : FD_PROTOTYPES_BEGIN
      44             : 
      45             : void *
      46             : fd_exec_epoch_ctx_new( void * mem,
      47             :                        ulong  vote_acc_max );
      48             : 
      49             : fd_exec_epoch_ctx_t *
      50             : fd_exec_epoch_ctx_join( void * mem );
      51             : 
      52             : void *
      53             : fd_exec_epoch_ctx_leave( fd_exec_epoch_ctx_t * ctx );
      54             : 
      55             : void *
      56             : fd_exec_epoch_ctx_delete( void * mem );
      57             : 
      58             : void
      59             : fd_exec_epoch_ctx_epoch_bank_delete( fd_exec_epoch_ctx_t * epoch_ctx );
      60             : 
      61             : ulong
      62             : fd_exec_epoch_ctx_align( void );
      63             : 
      64             : ulong
      65             : fd_exec_epoch_ctx_footprint( ulong vote_acc_max );
      66             : 
      67             : /* fd_exec_epoch_ctx_bank_mem_clear empties out the existing bank
      68             :    data structures (votes, delegations, stake history, next_epoch_stakes).
      69             :    This method should be used before decoding a bank from funk so as
      70             :    to not step on the work done while decoding.
      71             : */
      72             : void
      73             : fd_exec_epoch_ctx_bank_mem_clear( fd_exec_epoch_ctx_t * epoch_ctx );
      74             : 
      75             : /* fd_exec_epoch_ctx_bank_mem_setup initializes the bank
      76             :    data structures (votes, delegations, stake history, next_epoch_stakes)
      77             :    to have the correct pool initialization and layout.
      78             : */
      79             : fd_epoch_bank_t *
      80             : fd_exec_epoch_ctx_bank_mem_setup( fd_exec_epoch_ctx_t * epoch_ctx );
      81             : 
      82             : /* Accessors **********************************************************/
      83             : 
      84             : FD_FN_CONST static inline fd_epoch_bank_t *
      85           0 : fd_exec_epoch_ctx_epoch_bank( fd_exec_epoch_ctx_t * ctx ) {
      86           0 :   return &ctx->epoch_bank;
      87           0 : }
      88             : 
      89             : FD_FN_CONST static inline fd_epoch_bank_t const *
      90           0 : fd_exec_epoch_ctx_epoch_bank_const( fd_exec_epoch_ctx_t const * ctx ) {
      91           0 :   return &ctx->epoch_bank;
      92           0 : }
      93             : 
      94             : FD_FN_PURE static inline fd_vote_accounts_pair_t_mapnode_t *
      95           0 : fd_exec_epoch_ctx_stake_votes_join( fd_exec_epoch_ctx_t * ctx ) {
      96           0 :   void * mem = (void *)((ulong)ctx + ctx->layout.stake_votes_off);
      97           0 :   return fd_vote_accounts_pair_t_map_join( mem );
      98           0 : }
      99             : 
     100             : FD_FN_PURE static inline fd_delegation_pair_t_mapnode_t *
     101           0 : fd_exec_epoch_ctx_stake_delegations_join( fd_exec_epoch_ctx_t * ctx ) {
     102           0 :   void * mem = (void *)((ulong)ctx + ctx->layout.stake_delegations_off);
     103           0 :   return fd_delegation_pair_t_map_join( mem );
     104           0 : }
     105             : 
     106             : FD_FN_PURE static inline fd_vote_accounts_pair_t_mapnode_t *
     107           0 : fd_exec_epoch_ctx_next_epoch_stakes_join( fd_exec_epoch_ctx_t * ctx ) {
     108           0 :   void * mem = (void *)((ulong)ctx + ctx->layout.next_epoch_stakes_off);
     109           0 :   return fd_vote_accounts_pair_t_map_join( mem );
     110           0 : }
     111             : 
     112             : FD_FN_PURE static inline fd_epoch_leaders_t *
     113           0 : fd_exec_epoch_ctx_leaders( fd_exec_epoch_ctx_t * ctx ) {
     114           0 :   return (fd_epoch_leaders_t *)((uchar *)ctx + ctx->layout.leaders_off);
     115           0 : }
     116             : 
     117             : void
     118             : fd_exec_epoch_ctx_from_prev( fd_exec_epoch_ctx_t * self,
     119             :                              fd_exec_epoch_ctx_t * prev,
     120             :                              fd_spad_t *           runtime_spad );
     121             : 
     122             : FD_PROTOTYPES_END
     123             : 
     124             : #endif /* HEADER_fd_src_flamenco_runtime_context_fd_exec_epoch_ctx_h */

Generated by: LCOV version 1.14