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 : #include "../fd_bank.h" 14 : 15 : // https://github.com/anza-xyz/agave/blob/v2.0.1/sdk/program/src/vote/state/mod.rs#L35 16 0 : #define MAX_LOCKOUT_HISTORY 31UL 17 : 18 : // https://github.com/anza-xyz/agave/blob/v2.0.1/sdk/program/src/vote/state/mod.rs#L36 19 : #define MAX_EPOCH_CREDITS_HISTORY 64UL 20 : 21 : // https://github.com/anza-xyz/agave/blob/v2.0.1/sdk/program/src/vote/state/mod.rs#L48 22 0 : #define VOTE_CREDITS_MAXIMUM_PER_SLOT 16 23 : 24 : // https://github.com/anza-xyz/agave/blob/v2.0.1/sdk/program/src/vote/state/mod.rs#L45 25 0 : #define VOTE_CREDITS_GRACE_SLOTS 2 26 : 27 : /* https://github.com/anza-xyz/agave/blob/v3.1.1/programs/vote/src/vote_state/handler.rs#L597-L598 */ 28 0 : #define DEFAULT_BLOCK_REVENUE_COMMISSION_BPS (10000UL) 29 : 30 : /* Vote program custom error codes */ 31 : 32 0 : #define FD_VOTE_ERR_VOTE_TOO_OLD ( 0) 33 0 : #define FD_VOTE_ERR_SLOTS_MISMATCH ( 1) 34 0 : #define FD_VOTE_ERR_SLOTS_HASH_MISMATCH ( 2) 35 0 : #define FD_VOTE_ERR_EMPTY_SLOTS ( 3) 36 0 : #define FD_VOTE_ERR_TIMESTAMP_TOO_OLD ( 4) 37 0 : #define FD_VOTE_ERR_TOO_SOON_TO_REAUTHORIZE ( 5) 38 0 : #define FD_VOTE_ERR_LOCKOUT_CONFLICT ( 6) 39 0 : #define FD_VOTE_ERR_NEW_VOTE_STATE_LOCKOUT_MISMATCH ( 7) 40 0 : #define FD_VOTE_ERR_SLOTS_NOT_ORDERED ( 8) 41 0 : #define FD_VOTE_ERR_CONFIRMATIONS_NOT_ORDERED ( 9) 42 0 : #define FD_VOTE_ERR_ZERO_CONFIRMATIONS (10) 43 0 : #define FD_VOTE_ERR_CONFIRMATION_TOO_LARGE (11) 44 0 : #define FD_VOTE_ERR_ROOT_ROLL_BACK (12) 45 0 : #define FD_VOTE_ERR_CONFIRMATION_ROLL_BACK (13) 46 0 : #define FD_VOTE_ERR_SLOT_SMALLER_THAN_ROOT (14) 47 0 : #define FD_VOTE_ERR_TOO_MANY_VOTES (15) 48 0 : #define FD_VOTE_ERR_VOTES_TOO_OLD_ALL_FILTERED (16) 49 0 : #define FD_VOTE_ERR_ROOT_ON_DIFFERENT_FORK (17) 50 0 : #define FD_VOTE_ERR_ACTIVE_VOTE_ACCOUNT_CLOSE (18) 51 0 : #define FD_VOTE_ERR_COMMISSION_UPDATE_TOO_LATE (19) 52 : 53 : #define FD_VOTE_STATE_V2_SZ (3731UL) 54 24 : #define FD_VOTE_STATE_V3_SZ (3762UL) 55 0 : #define FD_VOTE_STATE_V4_SZ (3762UL) 56 : 57 : /* Target vote state versions 58 : https://github.com/anza-xyz/agave/blob/v3.1.1/programs/vote/src/vote_state/handler.rs#L639-L645 */ 59 0 : #define VOTE_STATE_TARGET_VERSION_V3 (0) 60 0 : #define VOTE_STATE_TARGET_VERSION_V4 (1) 61 : 62 : FD_PROTOTYPES_BEGIN 63 : 64 : /* fd_vote_program_execute is the instruction processing entrypoint 65 : for the vote program. */ 66 : int 67 : fd_vote_program_execute( fd_exec_instr_ctx_t * ctx ); 68 : 69 : /* An implementation of solana_sdk::transaction_context::BorrowedAccount::get_state 70 : for setting the vote state. 71 : 72 : https://github.com/anza-xyz/agave/blob/v2.1.14/sdk/src/transaction_context.rs#L965 */ 73 : fd_vote_state_versioned_t * 74 : fd_vote_get_state( fd_account_meta_t const * meta, 75 : uchar * mem ); 76 : 77 : void 78 : fd_vote_convert_to_current( fd_vote_state_versioned_t * self, 79 : uchar * authorized_voters_mem, 80 : uchar * landed_votes_mem ); 81 : 82 : FD_PROTOTYPES_END 83 : 84 : #endif /* HEADER_fd_src_flamenco_runtime_program_fd_vote_program_h */