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

          Line data    Source code
       1             : #ifndef HEADER_fd_src_choreo_votor_ag_vote_h
       2             : #define HEADER_fd_src_choreo_votor_ag_vote_h
       3             : 
       4             : #include "ag_votor_base.h"
       5             : #include "../../ballet/bls/fd_bls.h"
       6             : 
       7           0 : #define AG_VOTE_KIND_NOTAR           (0U)
       8           0 : #define AG_VOTE_KIND_FINAL           (1U)
       9           0 : #define AG_VOTE_KIND_SKIP            (2U)
      10           0 : #define AG_VOTE_KIND_NOTAR_FALLBACK  (3U)
      11           0 : #define AG_VOTE_KIND_SKIP_FALLBACK   (4U)
      12             : 
      13             : /* public_key is the canonical compressed BLS key selector.  payload is
      14             :    the exact consensus preimage; the signer must not include public_key
      15             :    in the signed bytes. */
      16             : 
      17             : typedef void
      18             : (* fd_bls_sign_fn)( void *         ctx,
      19             :                     fd_bls_sig_t * sig,
      20             :                     uchar const *  public_key,
      21             :                     uchar const *  payload,
      22             :                     ulong          payload_sz );
      23             : struct ag_vote_notar {
      24             :   ulong           slot;
      25             :   ag_block_hash_t block_hash;
      26             :   fd_bls_sig_t    sig;
      27             :   ushort          rank;
      28             :   ushort          shred_version;
      29             : };
      30             : typedef struct ag_vote_notar ag_vote_notar_t;
      31             : 
      32             : struct ag_vote_final {
      33             :   ulong        slot;
      34             :   fd_bls_sig_t sig;
      35             :   ushort       rank;
      36             :   ushort       shred_version;
      37             : };
      38             : typedef struct ag_vote_final ag_vote_final_t;
      39             : 
      40             : struct ag_vote_skip {
      41             :   ulong        slot;
      42             :   fd_bls_sig_t sig;
      43             :   ushort       rank;
      44             :   ushort       shred_version;
      45             : };
      46             : typedef struct ag_vote_skip ag_vote_skip_t;
      47             : 
      48             : struct ag_vote_notar_fallback {
      49             :   ulong           slot;
      50             :   ag_block_hash_t block_hash;
      51             :   fd_bls_sig_t    sig;
      52             :   ushort          rank;
      53             :   ushort          shred_version;
      54             : };
      55             : typedef struct ag_vote_notar_fallback ag_vote_notar_fallback_t;
      56             : 
      57             : struct ag_vote_skip_fallback {
      58             :   ulong        slot;
      59             :   fd_bls_sig_t sig;
      60             :   ushort       rank;
      61             :   ushort       shred_version;
      62             : };
      63             : typedef struct ag_vote_skip_fallback ag_vote_skip_fallback_t;
      64             : 
      65             : struct ag_vote {
      66             :   uint   kind;
      67             :   union {
      68             :     ag_vote_notar_t          notar;
      69             :     ag_vote_final_t          final;
      70             :     ag_vote_skip_t           skip;
      71             :     ag_vote_notar_fallback_t notar_fallback;
      72             :     ag_vote_skip_fallback_t  skip_fallback;
      73             :   };
      74             : };
      75             : typedef struct ag_vote ag_vote_t;
      76             : 
      77             : FD_PROTOTYPES_BEGIN
      78             : 
      79             : /* Definition 11. Vote::slot */
      80             : 
      81             : FD_FN_PURE static inline ulong
      82           0 : ag_vote_slot( ag_vote_t const * self ) {
      83           0 :   switch( self->kind ) {
      84           0 :   case AG_VOTE_KIND_NOTAR:          return self->notar.slot;
      85           0 :   case AG_VOTE_KIND_FINAL:          return self->final.slot;
      86           0 :   case AG_VOTE_KIND_SKIP:           return self->skip.slot;
      87           0 :   case AG_VOTE_KIND_NOTAR_FALLBACK: return self->notar_fallback.slot;
      88           0 :   case AG_VOTE_KIND_SKIP_FALLBACK:  return self->skip_fallback.slot;
      89           0 :   default:                          FD_LOG_CRIT(( "unreachable" ));
      90           0 :   }
      91           0 : }
      92             : 
      93             : /* Definition 11. Vote::block_hash */
      94             : 
      95             : FD_FN_PURE static inline uchar const *
      96           0 : ag_vote_block_hash( ag_vote_t const * self ) {
      97           0 :   switch( self->kind ) {
      98           0 :   case AG_VOTE_KIND_NOTAR:          return self->notar.block_hash;
      99           0 :   case AG_VOTE_KIND_FINAL:          return NULL;
     100           0 :   case AG_VOTE_KIND_SKIP:           return NULL;
     101           0 :   case AG_VOTE_KIND_NOTAR_FALLBACK: return self->notar_fallback.block_hash;
     102           0 :   case AG_VOTE_KIND_SKIP_FALLBACK:  return NULL;
     103           0 :   default:                          FD_LOG_CRIT(( "unreachable" ));
     104           0 :   }
     105           0 : }
     106             : 
     107             : /* Definition 11. SignedVote::sig */
     108             : 
     109             : FD_FN_PURE static inline fd_bls_sig_t const *
     110           0 : ag_vote_sig( ag_vote_t const * self ) {
     111           0 :   switch( self->kind ) {
     112           0 :   case AG_VOTE_KIND_NOTAR:          return &self->notar.sig;
     113           0 :   case AG_VOTE_KIND_FINAL:          return &self->final.sig;
     114           0 :   case AG_VOTE_KIND_SKIP:           return &self->skip.sig;
     115           0 :   case AG_VOTE_KIND_NOTAR_FALLBACK: return &self->notar_fallback.sig;
     116           0 :   case AG_VOTE_KIND_SKIP_FALLBACK:  return &self->skip_fallback.sig;
     117           0 :   default:                          FD_LOG_CRIT(( "unreachable" ));
     118           0 :   }
     119           0 : }
     120             : 
     121             : /* Definition 11. Vote::signer; assigned by the tile from the peer, not carried on the wire */
     122             : 
     123             : FD_FN_PURE static inline ushort
     124           0 : ag_vote_rank( ag_vote_t const * self ) {
     125           0 :   switch( self->kind ) {
     126           0 :   case AG_VOTE_KIND_NOTAR:          return self->notar.rank;
     127           0 :   case AG_VOTE_KIND_FINAL:          return self->final.rank;
     128           0 :   case AG_VOTE_KIND_SKIP:           return self->skip.rank;
     129           0 :   case AG_VOTE_KIND_NOTAR_FALLBACK: return self->notar_fallback.rank;
     130           0 :   case AG_VOTE_KIND_SKIP_FALLBACK:  return self->skip_fallback.rank;
     131           0 :   default:                          FD_LOG_CRIT(( "unreachable" ));
     132           0 :   }
     133           0 : }
     134             : 
     135             : FD_FN_PURE static inline ushort
     136           0 : ag_vote_shred_version( ag_vote_t const * self ) {
     137           0 :   switch( self->kind ) {
     138           0 :   case AG_VOTE_KIND_NOTAR:          return self->notar.shred_version;
     139           0 :   case AG_VOTE_KIND_FINAL:          return self->final.shred_version;
     140           0 :   case AG_VOTE_KIND_SKIP:           return self->skip.shred_version;
     141           0 :   case AG_VOTE_KIND_NOTAR_FALLBACK: return self->notar_fallback.shred_version;
     142           0 :   case AG_VOTE_KIND_SKIP_FALLBACK:  return self->skip_fallback.shred_version;
     143           0 :   default:                          FD_LOG_CRIT(( "unreachable" ));
     144           0 :   }
     145           0 : }
     146             : 
     147             : /* Definition 11. Vote::new_notar */
     148             : 
     149             : ag_vote_t
     150             : ag_vote_construct_notar( fd_bls_sign_fn        sign_fn,
     151             :                          void *                sign_ctx,
     152             :                          uchar const *         public_key,
     153             :                          ulong                 slot,
     154             :                          ag_block_hash_t const hash,
     155             :                          ushort                rank,
     156             :                          ushort                shred_version );
     157             : 
     158             : /* Definition 11. Vote::new_final */
     159             : 
     160             : ag_vote_t
     161             : ag_vote_construct_final( fd_bls_sign_fn sign_fn,
     162             :                          void *         sign_ctx,
     163             :                          uchar const *  public_key,
     164             :                          ulong          slot,
     165             :                          ushort         rank,
     166             :                          ushort         shred_version );
     167             : 
     168             : /* Definition 11. Vote::new_skip */
     169             : 
     170             : ag_vote_t
     171             : ag_vote_construct_skip( fd_bls_sign_fn sign_fn,
     172             :                         void *         sign_ctx,
     173             :                         uchar const *  public_key,
     174             :                         ulong          slot,
     175             :                         ushort         rank,
     176             :                         ushort         shred_version );
     177             : 
     178             : /* Definition 11. Vote::new_notar_fallback */
     179             : 
     180             : ag_vote_t
     181             : ag_vote_construct_notar_fallback( fd_bls_sign_fn        sign_fn,
     182             :                                   void *                sign_ctx,
     183             :                                   uchar const *         public_key,
     184             :                                   ulong                 slot,
     185             :                                   ag_block_hash_t const hash,
     186             :                                   ushort                rank,
     187             :                                   ushort                shred_version );
     188             : 
     189             : /* Definition 11. Vote::new_skip_fallback */
     190             : 
     191             : ag_vote_t
     192             : ag_vote_construct_skip_fallback( fd_bls_sign_fn sign_fn,
     193             :                                  void *         sign_ctx,
     194             :                                  uchar const *  public_key,
     195             :                                  ulong          slot,
     196             :                                  ushort         rank,
     197             :                                  ushort         shred_version );
     198             : 
     199             : FD_PROTOTYPES_END
     200             : 
     201             : #endif

Generated by: LCOV version 1.14