LCOV - code coverage report
Current view: top level - choreo/votor - fd_votor_base.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 32 0.0 %
Date: 2026-11-11 12:40:43 Functions: 0 850 0.0 %

          Line data    Source code
       1             : #ifndef HEADER_fd_src_choreo_votor_fd_votor_base_h
       2             : #define HEADER_fd_src_choreo_votor_fd_votor_base_h
       3             : 
       4             : #include "../../util/fd_util.h"
       5             : 
       6           0 : #define FD_VOTOR_SLOTS_PER_WINDOW        (4UL)
       7           0 : #define FD_VOTOR_REWARD_SLOT_DELTA       (8UL)    /* Agave NUM_SLOTS_FOR_REWARD */
       8           0 : #define FD_VOTOR_VAT_MAX                 (2000UL) /* Validator Admission Ticket caps at 2000 */
       9           0 : #define FD_VOTOR_EQVOC_MAX               (7UL)    /* Corollary 50 */
      10           0 : #define FD_VOTOR_NOTAR_FALLBACK_VOTE_MAX (3UL)    /* Definition 12 */
      11           0 : #define FD_VOTOR_NOTAR_FALLBACK_CERT_MAX (4UL)    /* Lemma 48 */
      12           0 : #define FD_VOTOR_VOTES_PER_SLOT_MAX      (5UL)    /* notar + 3 notar_fallback + skip_fallback */
      13             : 
      14           0 : #define FD_VOTOR_DELTA_TIMEOUT_NS     (400000000L)     /* skip timeout */
      15           0 : #define FD_VOTOR_DELTA_TIMEOUT_MAX_NS (3600000000000L) /* skip timeout cap under standstill, Agave MAX_TIMEOUT */
      16           0 : #define FD_VOTOR_DELTA_STANDSTILL_NS  (10000000000L)   /* 10s since last finalize */
      17             : 
      18           0 : #define FD_VOTOR_WEAKEST_QUORUM_THRESHOLD_NUMER (1UL) /* 20%, safe-to-notar + 40% skip */
      19           0 : #define FD_VOTOR_WEAK_QUORUM_THRESHOLD_NUMER    (2UL) /* 40%, safe-to-notar / safe-to-skip */
      20           0 : #define FD_VOTOR_QUORUM_THRESHOLD_NUMER         (3UL) /* 60%, notarize, finalize and skip */
      21           0 : #define FD_VOTOR_STRONG_QUORUM_THRESHOLD_NUMER  (4UL) /* 80%, fast-finalize */
      22           0 : #define FD_VOTOR_QUORUM_THRESHOLD_DENOM         (5UL) /* 100% */
      23             : 
      24             : struct fd_block_hash { /* double merkle root of the block */
      25             :   uchar uc[ 32 ];
      26             : };
      27             : typedef struct fd_block_hash fd_block_hash_t;
      28             : static const fd_block_hash_t fd_block_hash_null = { 0 };
      29             : 
      30             : struct fd_block_id {
      31             :   ulong           slot;
      32             :   fd_block_hash_t hash;
      33             : };
      34             : typedef struct fd_block_id fd_block_id_t;
      35             : FD_STATIC_ASSERT( sizeof(fd_block_id_t)==40UL, fd_block_id );
      36             : 
      37             : struct fd_block_info {
      38             :   fd_block_hash_t hash;
      39             :   fd_block_id_t   parent;
      40             : };
      41             : typedef struct fd_block_info fd_block_info_t;
      42             : 
      43             : typedef struct fd_vote fd_vote_t; /* forward decl */
      44             : typedef struct fd_cert fd_cert_t; /* forward decl */
      45             : 
      46             : struct fd_standstill {
      47             :   ulong       slot;
      48             :   fd_cert_t * certs;
      49             :   ulong       cert_cnt;
      50             :   fd_vote_t * votes;
      51             :   ulong       vote_cnt;
      52             : };
      53             : typedef struct fd_standstill fd_standstill_t;
      54             : 
      55             : FD_PROTOTYPES_BEGIN
      56             : 
      57             : /* Algorithm 2, line 1. Slot::first_slot_in_window */
      58             : 
      59             : FD_FN_CONST static inline ulong
      60           0 : fd_first_slot_in_window( ulong slot ) {
      61           0 :   return ( slot / FD_VOTOR_SLOTS_PER_WINDOW ) * FD_VOTOR_SLOTS_PER_WINDOW;
      62           0 : }
      63             : 
      64             : /* Algorithm 2, line 1. Slot::is_start_of_window */
      65             : 
      66             : FD_FN_CONST static inline int
      67           0 : fd_is_start_of_window( ulong slot ) {
      68           0 :   return ( slot % FD_VOTOR_SLOTS_PER_WINDOW )==0UL;
      69           0 : }
      70             : 
      71             : /* Definition 4. BlockId, the (Slot, BlockHash) tuple */
      72             : 
      73             : static inline fd_block_id_t
      74             : fd_block_id( ulong         slot,
      75           0 :              uchar const * hash ) {
      76           0 :   fd_block_id_t id = { .slot = slot };
      77           0 :   memcpy( &id.hash, hash, sizeof(fd_block_hash_t) );
      78           0 :   return id;
      79           0 : }
      80             : 
      81             : /* Definition 4. BlockId == */
      82             : 
      83             : FD_FN_PURE static inline int
      84             : fd_block_id_eq( fd_block_id_t const * a,
      85           0 :                 fd_block_id_t const * b ) {
      86           0 :   return a->slot==b->slot && !memcmp( &a->hash, &b->hash, sizeof(fd_block_hash_t) );
      87           0 : }
      88             : 
      89             : /* Definition 4. BlockId <, ordered by (slot, hash) */
      90             : 
      91             : FD_FN_PURE static inline int
      92             : fd_block_id_lt( fd_block_id_t const * a,
      93           0 :                 fd_block_id_t const * b ) {
      94           0 :   return a->slot<b->slot || ( a->slot==b->slot && 0>memcmp( &a->hash, &b->hash, sizeof(fd_block_hash_t) ) );
      95           0 : }
      96             : 
      97             : FD_PROTOTYPES_END
      98             : 
      99             : #endif

Generated by: LCOV version 1.14