LCOV - code coverage report
Current view: top level - flamenco/runtime/program - fd_vote_program.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 15 22 68.2 %
Date: 2025-01-08 12:08:44 Functions: 0 0 -

          Line data    Source code
       1             : #ifndef HEADER_fd_src_flamenco_runtime_program_fd_vote_program_h
       2             : #define HEADER_fd_src_flamenco_runtime_program_fd_vote_program_h
       3             : 
       4             : /* The vote program (native program) allows node operators to register
       5             :    their nodes and participate in consensus.  The vote program
       6             :    implements various Tower BFT logic like voting and lockouts.  The set
       7             :    of vote accounts is the 'source of truth' for Solana's consensus
       8             :    algorithm.
       9             : 
      10             :    Address: Vote111111111111111111111111111111111111111 */
      11             : 
      12             : #include "../context/fd_exec_instr_ctx.h"
      13             : 
      14             : /* Vote program custom error codes */
      15             : 
      16         144 : #define FD_VOTE_ERROR_VOTE_TOO_OLD                  (  0 )
      17         540 : #define FD_VOTE_ERR_SLOTS_MISMATCH                  (  1 )
      18           9 : #define FD_VOTE_ERR_SLOTS_HASH_MISMATCH             (  2 )
      19          54 : #define FD_VOTE_ERR_EMPTY_SLOTS                     (  3 )
      20           9 : #define FD_VOTE_ERR_TIMESTAMP_TOO_OLD               (  4 )
      21           6 : #define FD_VOTE_ERR_TOO_SOON_TO_REAUTHORIZE         (  5 )
      22           0 : #define FD_VOTE_ERR_LOCKOUT_CONFLICT                (  6 )
      23           3 : #define FD_VOTE_ERR_NEW_VOTE_STATE_LOCKOUT_MISMATCH (  7 )
      24           9 : #define FD_VOTE_ERR_SLOTS_NOT_ORDERED               (  8 )
      25           0 : #define FD_VOTE_ERR_CONFIRMATIONS_NOT_ORDERED       (  9 )
      26           0 : #define FD_VOTE_ERR_ZERO_CONFIRMATIONS              ( 10 )
      27           0 : #define FD_VOTE_ERR_CONFIRMATION_TOO_LARGE          ( 11 )
      28           6 : #define FD_VOTE_ERR_ROOT_ROLL_BACK                  ( 12 )
      29           0 : #define FD_VOTE_ERR_CONFIRMATION_ROLL_BACK          ( 13 )
      30           0 : #define FD_VOTE_ERR_SLOT_SMALLER_THAN_ROOT          ( 14 )
      31           0 : #define FD_VOTE_ERR_TOO_MANY_VOTES                  ( 15 )
      32          60 : #define FD_VOTE_ERR_VOTES_TOO_OLD_ALL_FILTERED      ( 16 )
      33          87 : #define FD_VOTE_ERR_ROOT_ON_DIFFERENT_FORK          ( 17 )
      34          18 : #define FD_VOTE_ERR_ACTIVE_VOTE_ACCOUNT_CLOSE       ( 18 )
      35         120 : #define FD_VOTE_ERR_COMMISSION_UPDATE_TOO_LATE      ( 19 )
      36             : 
      37        1374 : #define FD_VOTE_STATE_V2_SZ (3731UL)
      38        1398 : #define FD_VOTE_STATE_V3_SZ (3762UL)
      39             : 
      40             : FD_PROTOTYPES_BEGIN
      41             : 
      42             : /* fd_vote_program_execute is the instruction processing entrypoint
      43             :    for the vote program.  On return, ctx.txn_ctx->dirty_vote_acc==1 if a
      44             :    vote account may have been modified. */
      45             : 
      46             : int
      47             : fd_vote_program_execute( fd_exec_instr_ctx_t * ctx );
      48             : 
      49             : /* Queries the delegated stake amount for the given vote account pubkey,
      50             :    given the vote accounts map. Returns 0 if nonexistent. */
      51             : ulong
      52             : fd_query_pubkey_stake( fd_pubkey_t const * pubkey, fd_vote_accounts_t const * vote_accounts );
      53             : 
      54             : int
      55             : fd_vote_get_state( fd_borrowed_account_t const * self,
      56             :                    fd_valloc_t                   valloc,
      57             :                    fd_vote_state_versioned_t *   versioned /* out */ );
      58             : 
      59             : void
      60             : fd_vote_convert_to_current( fd_vote_state_versioned_t * self,
      61             :                             fd_valloc_t                 valloc );
      62             : 
      63             : void
      64             : fd_vote_record_timestamp_vote_with_slot( fd_exec_slot_ctx_t * slot_ctx,
      65             :                                          fd_pubkey_t const *  vote_acc,
      66             :                                          long                 timestamp,
      67             :                                          ulong                slot,
      68             :                                          fd_valloc_t          valloc );
      69             : 
      70             : struct fd_commission_split {
      71             :   ulong voter_portion;
      72             :   ulong staker_portion;
      73             :   uint  is_split;
      74             : };
      75             : typedef struct fd_commission_split fd_commission_split_t;
      76             : 
      77             : void
      78             : fd_vote_commission_split( fd_vote_state_versioned_t * vote_state_versioned,
      79             :                           ulong                       on,
      80             :                           fd_commission_split_t *     result );
      81             : 
      82             : void
      83             : fd_vote_store_account( fd_exec_slot_ctx_t *    slot_ctx,
      84             :                        fd_borrowed_account_t * vote_account,
      85             :                        fd_spad_t *             spad );
      86             : 
      87             : FD_PROTOTYPES_END
      88             : 
      89             : #endif /* HEADER_fd_src_flamenco_runtime_program_fd_vote_program_h */

Generated by: LCOV version 1.14