LCOV - code coverage report
Current view: top level - choreo/votor - ag_cert.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 31 34 91.2 %
Date: 2026-09-17 04:28:31 Functions: 12 156 7.7 %

          Line data    Source code
       1             : #ifndef HEADER_fd_src_choreo_votor_ag_cert_h
       2             : #define HEADER_fd_src_choreo_votor_ag_cert_h
       3             : 
       4             : #include "../../ballet/bls/fd_bls.h"
       5             : #include "ag_epoch_info.h"
       6             : #include "ag_votor_base.h"
       7             : 
       8        1134 : #define AG_CERT_KIND_FINAL          (0)
       9        3951 : #define AG_CERT_KIND_FAST_FINAL     (1)
      10        3399 : #define AG_CERT_KIND_NOTAR          (2)
      11        3522 : #define AG_CERT_KIND_NOTAR_FALLBACK (3)
      12        1131 : #define AG_CERT_KIND_SKIP           (4)
      13             : 
      14             : #define AG_CERT_CSTR_MAX (512UL)
      15             : 
      16             : struct ag_cert_final {
      17             :   ulong        slot;
      18             :   fd_bls_agg_t agg;
      19             :   ulong        stake;
      20             :   ushort       shred_version;
      21             : };
      22             : typedef struct ag_cert_final ag_cert_final_t;
      23             : 
      24             : struct ag_cert_fast_final {
      25             :   ulong           slot;
      26             :   ag_block_hash_t block_hash;
      27             :   fd_bls_agg_t    agg;
      28             :   ulong           stake;
      29             :   ushort          shred_version;
      30             : };
      31             : typedef struct ag_cert_fast_final ag_cert_fast_final_t;
      32             : 
      33             : struct ag_cert_notar {
      34             :   ulong           slot;
      35             :   ag_block_hash_t block_hash;
      36             :   fd_bls_agg_t    agg;
      37             :   ulong           stake;
      38             :   ushort          shred_version;
      39             : };
      40             : typedef struct ag_cert_notar ag_cert_notar_t;
      41             : 
      42             : struct ag_cert_notar_fallback {
      43             :   ulong           slot;
      44             :   ag_block_hash_t block_hash;
      45             :   fd_bls_agg_t    agg_notar;
      46             :   fd_bls_agg_t    agg_notar_fallback;
      47             :   ulong           stake;
      48             :   ushort          shred_version;
      49             : };
      50             : typedef struct ag_cert_notar_fallback ag_cert_notar_fallback_t;
      51             : 
      52             : struct ag_cert_skip {
      53             :   ulong        slot;
      54             :   fd_bls_agg_t agg_skip;
      55             :   fd_bls_agg_t agg_skip_fallback;
      56             :   ulong        stake;
      57             :   ushort       shred_version;
      58             : };
      59             : typedef struct ag_cert_skip ag_cert_skip_t;
      60             : 
      61             : struct ag_cert {
      62             :   uint kind;
      63             :   union {
      64             :     ag_cert_final_t          final;
      65             :     ag_cert_fast_final_t     fast_final;
      66             :     ag_cert_notar_t          notar;
      67             :     ag_cert_notar_fallback_t notar_fallback;
      68             :     ag_cert_skip_t           skip;
      69             :   };
      70             : };
      71             : typedef struct ag_cert ag_cert_t;
      72             : 
      73             : FD_PROTOTYPES_BEGIN
      74             : 
      75             : FD_FN_PURE static inline ulong
      76        1314 : ag_cert_slot( ag_cert_t const * self ) {
      77        1314 :   switch( self->kind ) {
      78          63 :   case AG_CERT_KIND_FINAL:          return self->final.slot;
      79         414 :   case AG_CERT_KIND_FAST_FINAL:     return self->fast_final.slot;
      80         384 :   case AG_CERT_KIND_NOTAR:          return self->notar.slot;
      81         354 :   case AG_CERT_KIND_NOTAR_FALLBACK: return self->notar_fallback.slot;
      82          99 :   case AG_CERT_KIND_SKIP:           return self->skip.slot;
      83           0 :   default:                          FD_LOG_CRIT(( "unreachable" ));
      84        1314 :   }
      85        1314 : }
      86             : 
      87             : FD_FN_PURE static inline uchar const *
      88         756 : ag_cert_block_hash( ag_cert_t const * self ) {
      89         756 :   switch( self->kind ) {
      90           6 :   case AG_CERT_KIND_FINAL:          return NULL;
      91           6 :   case AG_CERT_KIND_FAST_FINAL:     return self->fast_final.block_hash;
      92         369 :   case AG_CERT_KIND_NOTAR:          return self->notar.block_hash;
      93         366 :   case AG_CERT_KIND_NOTAR_FALLBACK: return self->notar_fallback.block_hash;
      94           9 :   case AG_CERT_KIND_SKIP:           return NULL;
      95           0 :   default:                          FD_LOG_CRIT(( "unreachable" )); }
      96         756 : }
      97             : 
      98             : FD_FN_PURE static inline ushort
      99         102 : ag_cert_shred_version( ag_cert_t const * self ) {
     100         102 :   switch( self->kind ) {
     101          18 :   case AG_CERT_KIND_FINAL:          return self->final.shred_version;
     102          18 :   case AG_CERT_KIND_FAST_FINAL:     return self->fast_final.shred_version;
     103          12 :   case AG_CERT_KIND_NOTAR:          return self->notar.shred_version;
     104          30 :   case AG_CERT_KIND_NOTAR_FALLBACK: return self->notar_fallback.shred_version;
     105          24 :   case AG_CERT_KIND_SKIP:           return self->skip.shred_version;
     106           0 :   default:                          FD_LOG_CRIT(( "unreachable" ));
     107         102 :   }
     108         102 : }
     109             : 
     110             : int
     111             : ag_cert_verify( ag_cert_t const *       self,
     112             :                 ag_epoch_info_t const * epoch_info );
     113             : 
     114             : char *
     115             : ag_cert_to_cstr( ag_cert_t const * self,
     116             :                  char              cstr[ static AG_CERT_CSTR_MAX ] );
     117             : 
     118             : FD_PROTOTYPES_END
     119             : 
     120             : #endif

Generated by: LCOV version 1.14