LCOV - code coverage report
Current view: top level - choreo/votor - ag_votor_base.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 31 0.0 %
Date: 2026-10-22 18:10:43 Functions: 0 785 0.0 %

          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           0 : #define AG_SLOTS_PER_WINDOW        (4UL)
       7           0 : #define AG_REWARD_SLOT_DELTA       (8UL)    /* Agave NUM_SLOTS_FOR_REWARD */
       8           0 : #define AG_VAT_MAX                 (2000UL) /* Validator Admission Ticket caps at 2000 */
       9           0 : #define AG_EQVOC_BLOCK_HASH_MAX    (7UL)    /* Corollary 50 */
      10           0 : #define AG_NOTAR_FALLBACK_VOTE_MAX (3UL)    /* Definition 12 */
      11           0 : #define AG_NOTAR_FALLBACK_CERT_MAX (4UL)    /* Lemma 48 */
      12           0 : #define AG_SLOT_VOTE_SIG_MAX       (5UL)    /* notar + 3 notar_fallback + skip_fallback */
      13             : 
      14           0 : #define AG_DELTA_TIMEOUT_NS    (400000000L)   /* skip timeout */
      15           0 : #define AG_DELTA_STANDSTILL_NS (10000000000L) /* 10s since last finalize */
      16             : 
      17           0 : #define AG_WEAKEST_QUORUM_THRESHOLD_NUMER (1UL) /* 20%, safe-to-notar + 40% skip */
      18           0 : #define AG_WEAK_QUORUM_THRESHOLD_NUMER    (2UL) /* 40%, safe-to-notar / safe-to-skip */
      19           0 : #define AG_QUORUM_THRESHOLD_NUMER         (3UL) /* 60%, notarize, finalize and skip */
      20           0 : #define AG_STRONG_QUORUM_THRESHOLD_NUMER  (4UL) /* 80%, fast-finalize */
      21           0 : #define AG_QUORUM_THRESHOLD_DENOM         (5UL) /* 100% */
      22             : 
      23             : typedef uchar ag_vote_key_t  [ 32 ]; /* vote account address */
      24             : typedef uchar ag_id_key_t    [ 32 ]; /* identity public key */
      25             : typedef uchar ag_bls_key_t   [ 48 ]; /* compressed BLS public key */
      26             : 
      27             : typedef uchar ag_block_hash_t[ 32 ]; /* double merkle root of the block */
      28             : static const ag_block_hash_t ag_block_hash_null = { 0 };
      29             : 
      30             : struct ag_block_hash_key { /* ag_block_hash_t as an assignable fd_map key */
      31             :   ag_block_hash_t block_hash;
      32             : };
      33             : typedef struct ag_block_hash_key ag_block_hash_key_t;
      34             : static const ag_block_hash_key_t ag_block_hash_key_null = { 0 };
      35             : 
      36             : struct ag_block_id {
      37             :   ulong           slot;
      38             :   ag_block_hash_t hash;
      39             : };
      40             : typedef struct ag_block_id ag_block_id_t;
      41             : FD_STATIC_ASSERT( sizeof(ag_block_id_t)==40UL, ag_block_id );
      42             : 
      43             : struct ag_block_info {
      44             :   ag_block_hash_t hash;
      45             :   ag_block_id_t   parent;
      46             : };
      47             : typedef struct ag_block_info ag_block_info_t;
      48             : 
      49             : typedef struct ag_vote ag_vote_t; /* forward decl */
      50             : typedef struct ag_cert ag_cert_t; /* forward decl */
      51             : 
      52             : struct ag_standstill {
      53             :   ulong       slot;
      54             :   ag_cert_t * certs;
      55             :   ulong       cert_cnt;
      56             :   ag_vote_t * votes;
      57             :   ulong       vote_cnt;
      58             : };
      59             : typedef struct ag_standstill ag_standstill_t;
      60             : 
      61             : FD_PROTOTYPES_BEGIN
      62             : 
      63             : /* Algorithm 2, line 1. Slot::first_slot_in_window */
      64             : 
      65             : FD_FN_CONST static inline ulong
      66           0 : ag_first_slot_in_window( ulong slot ) {
      67           0 :   return ( slot / AG_SLOTS_PER_WINDOW ) * AG_SLOTS_PER_WINDOW;
      68           0 : }
      69             : 
      70             : /* Algorithm 2, line 1. Slot::is_start_of_window */
      71             : 
      72             : FD_FN_CONST static inline int
      73           0 : ag_is_start_of_window( ulong slot ) {
      74           0 :   return ( slot % AG_SLOTS_PER_WINDOW )==0UL;
      75           0 : }
      76             : 
      77             : /* Definition 4. BlockId, the (Slot, BlockHash) tuple */
      78             : 
      79             : static inline ag_block_id_t
      80             : ag_block_id( ulong                 slot,
      81           0 :              ag_block_hash_t const hash ) {
      82           0 :   ag_block_id_t id = { .slot = slot };
      83           0 :   memcpy( id.hash, hash, sizeof(ag_block_hash_t) );
      84           0 :   return id;
      85           0 : }
      86             : 
      87             : /* Definition 4. BlockId == */
      88             : 
      89             : FD_FN_PURE static inline int
      90             : ag_block_id_eq( ag_block_id_t const * a,
      91           0 :                 ag_block_id_t const * b ) {
      92           0 :   return a->slot==b->slot && !memcmp( a->hash, b->hash, sizeof(ag_block_hash_t) );
      93           0 : }
      94             : 
      95             : /* Definition 4. BlockId <, ordered by (slot, hash) */
      96             : 
      97             : FD_FN_PURE static inline int
      98             : ag_block_id_lt( ag_block_id_t const * a,
      99           0 :                 ag_block_id_t const * b ) {
     100           0 :   return a->slot<b->slot || ( a->slot==b->slot && 0>memcmp( a->hash, b->hash, sizeof(ag_block_hash_t) ) );
     101           0 : }
     102             : 
     103             : FD_PROTOTYPES_END
     104             : 
     105             : #endif

Generated by: LCOV version 1.14