Line data Source code
1 : #ifndef HEADER_fd_src_choreo_votor_ag_votor_base_h 2 : #define HEADER_fd_src_choreo_votor_ag_votor_base_h 3 : 4 : #include "../../util/fd_util.h" 5 : 6 3978 : #define AG_SLOTS_PER_WINDOW (4UL) 7 10392 : #define AG_REWARD_SLOT_DELTA (8UL) /* Agave NUM_SLOTS_FOR_REWARD */ 8 24051 : #define AG_VAT_MAX (2000UL) /* Validator Admission Ticket caps at 2000 */ 9 984 : #define AG_EQVOC_BLOCK_HASH_MAX (7UL) /* Corollary 50 */ 10 18369 : #define AG_NOTAR_FALLBACK_VOTE_MAX (3UL) /* Definition 12 */ 11 405 : #define AG_NOTAR_FALLBACK_CERT_MAX (4UL) /* Lemma 48 */ 12 : 13 33 : #define AG_DELTA_NS (250000000L) /* 250 ms 0.5-RTT, partial-synchrony */ 14 222 : #define AG_DELTA_BLOCK_NS (200000000L) /* 200 ms slots */ 15 135 : #define AG_DELTA_FIRST_SLICE_NS (10000000L) /* TODO */ 16 33 : #define AG_DELTA_TIMEOUT_NS (3L * AG_DELTA_NS) /* skip timeout */ 17 : #define AG_DELTA_STANDSTILL_NS (10000000000L) /* 10s since last finalize */ 18 : 19 3777 : #define AG_WEAKEST_QUORUM_THRESHOLD_NUMER (1UL) /* 20%, safe-to-notar + 40% skip */ 20 7002 : #define AG_WEAK_QUORUM_THRESHOLD_NUMER (2UL) /* 40%, safe-to-notar / safe-to-skip */ 21 9732 : #define AG_QUORUM_THRESHOLD_NUMER (3UL) /* 60%, notarize, finalize and skip */ 22 1635 : #define AG_STRONG_QUORUM_THRESHOLD_NUMER (4UL) /* 80%, fast-finalize */ 23 22146 : #define AG_QUORUM_THRESHOLD_DENOM (5UL) /* 100% */ 24 : 25 : typedef uchar ag_block_hash_t[ 32 ]; /* double merkle root of the block */ 26 : typedef uchar ag_vote_key_t [ 32 ]; /* vote account address */ 27 : typedef uchar ag_id_key_t [ 32 ]; /* identity public key */ 28 : 29 : union ag_block_hash_key { /* ag_block_hash_t as an assignable fd_map key */ 30 : uchar uc[ 32 ]; 31 : ulong ul[ 4 ]; 32 : }; 33 : typedef union ag_block_hash_key ag_block_hash_key_t; 34 : 35 : struct ag_block_id { 36 : ulong slot; 37 : ag_block_hash_t hash; 38 : }; 39 : typedef struct ag_block_id ag_block_id_t; 40 : FD_STATIC_ASSERT( sizeof(ag_block_id_t)==40UL, ag_block_id ); 41 : 42 : struct ag_block_info { 43 : ag_block_hash_t hash; 44 : ag_block_id_t parent; 45 : }; 46 : typedef struct ag_block_info ag_block_info_t; 47 : 48 : typedef struct ag_vote ag_vote_t; /* forward decl */ 49 : typedef struct ag_cert ag_cert_t; /* forward decl */ 50 : 51 : struct ag_standstill { 52 : ulong slot; 53 : ag_cert_t * certs; 54 : ulong cert_cnt; 55 : ag_vote_t * votes; 56 : ulong vote_cnt; 57 : }; 58 : typedef struct ag_standstill ag_standstill_t; 59 : 60 : FD_PROTOTYPES_BEGIN 61 : 62 : FD_FN_CONST static inline ulong 63 939 : ag_first_slot_in_window( ulong slot ) { 64 939 : return ( slot / AG_SLOTS_PER_WINDOW ) * AG_SLOTS_PER_WINDOW; 65 939 : } 66 : 67 : FD_FN_CONST static inline int 68 1101 : ag_is_start_of_window( ulong slot ) { 69 1101 : return ( slot % AG_SLOTS_PER_WINDOW )==0UL; 70 1101 : } 71 : 72 : static inline ag_block_id_t 73 : ag_block_id( ulong slot, 74 3330 : ag_block_hash_t const hash ) { 75 3330 : ag_block_id_t id = { .slot = slot }; 76 3330 : memcpy( id.hash, hash, sizeof(ag_block_hash_t) ); 77 3330 : return id; 78 3330 : } 79 : 80 : FD_FN_PURE static inline int 81 : ag_block_id_eq( ag_block_id_t const * a, 82 219 : ag_block_id_t const * b ) { 83 219 : return a->slot==b->slot && !memcmp( a->hash, b->hash, sizeof(ag_block_hash_t) ); 84 219 : } 85 : 86 : FD_PROTOTYPES_END 87 : 88 : #endif