LCOV - code coverage report
Current view: top level - flamenco/alpenglow - fd_block_marker_serde.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 7 52 13.5 %
Date: 2026-11-11 12:40:43 Functions: 0 0 -

          Line data    Source code
       1             : #ifndef HEADER_fd_src_flamenco_alpenglow_fd_block_marker_serde_h
       2             : #define HEADER_fd_src_flamenco_alpenglow_fd_block_marker_serde_h
       3             : 
       4             : #include "fd_block_marker.h"
       5             : 
       6        9973 : #define FD_BLOCK_MARKER_DE_SUCCESS         ( 0)
       7           2 : #define FD_BLOCK_MARKER_DE_ERR_SZ          (-1) /* Io(ReadSizeLimit), PreallocationSizeLimit, Custom("LengthPrefixed: inner serialized size does not match length prefix") */
       8        2562 : #define FD_BLOCK_MARKER_DE_ERR_INVAL       (-2) /* InvalidTagEncoding, InvalidValue                                                                                         */
       9           0 : #define FD_BLOCK_MARKER_DE_ERR_UNSUPPORTED (-3) /* no wincode error: BlockMarkerV1::GenesisCertificate decodes in agave but fd_block_marker_t cannot carry it              */
      10             : 
      11             : /* BlockMarkerV1: https://github.com/anza-xyz/agave/blob/v4.3.0-beta.0/entry/src/block_component.rs#L380-L386 */
      12             : 
      13           0 : #define FD_BLOCK_MARKER_SERDE_TAG_FOOTER        (0) /* BlockMarkerV1::BlockFooter        (implicit tag 0) */
      14           0 : #define FD_BLOCK_MARKER_SERDE_TAG_HEADER        (1) /* BlockMarkerV1::BlockHeader        (implicit tag 1) */
      15           0 : #define FD_BLOCK_MARKER_SERDE_TAG_UPDATE_PARENT (2) /* BlockMarkerV1::UpdateParent       (implicit tag 2) */
      16           0 : #define FD_BLOCK_MARKER_SERDE_TAG_GENESIS_CERT  (3) /* BlockMarkerV1::GenesisCertificate (implicit tag 3) */
      17             : 
      18             : FD_STATIC_ASSERT( FD_BLOCK_MARKER_KIND_FOOTER       ==FD_BLOCK_MARKER_SERDE_TAG_FOOTER,        fd_block_marker_serde );
      19             : FD_STATIC_ASSERT( FD_BLOCK_MARKER_KIND_HEADER       ==FD_BLOCK_MARKER_SERDE_TAG_HEADER,        fd_block_marker_serde );
      20             : FD_STATIC_ASSERT( FD_BLOCK_MARKER_KIND_UPDATE_PARENT==FD_BLOCK_MARKER_SERDE_TAG_UPDATE_PARENT, fd_block_marker_serde );
      21             : FD_STATIC_ASSERT( FD_BLOCK_MARKER_KIND_GENESIS_CERT ==FD_BLOCK_MARKER_SERDE_TAG_GENESIS_CERT,  fd_block_marker_serde );
      22             : 
      23        1993 : #define FD_BLOCK_MARKER_PREAMBLE_SZ ( sizeof(ulong)  /* entry_cnt */ + \
      24        1993 :                                       sizeof(ushort) /* version   */ + \
      25        1993 :                                       sizeof(uchar)  /* tag       */ + \
      26        1993 :                                       sizeof(ushort) /* length    */ )
      27             : 
      28             : #define FD_BLOCK_HEADER_SER_SZ ( sizeof(uchar)     /* version         */ + \
      29             :                                  sizeof(ulong)     /* parent_slot     */ + \
      30             :                                  sizeof(fd_hash_t) /* parent_block_id */ )
      31             : 
      32             : #define FD_UPDATE_PARENT_SER_SZ ( sizeof(uchar)     /* version             */ + \
      33             :                                   sizeof(ulong)     /* new_parent_slot     */ + \
      34             :                                   sizeof(fd_hash_t) /* new_parent_block_id */ )
      35             : 
      36           0 : #define FD_BLOCK_BITMAP_SER_HDR_SZ ( sizeof(uchar)  /* version */ + \
      37           0 :                                      sizeof(ushort) /* bit_cnt */ )
      38             : 
      39           0 : #define FD_BLOCK_BITMAP_SER_SZ( bit_cnt ) ( FD_BLOCK_BITMAP_SER_HDR_SZ + ((bit_cnt)+7UL)/8UL /* base2 payload */ )
      40             : 
      41           0 : #define FD_BLOCK_VOTES_AGGREGATE_SER_HDR_SZ ( FD_BLS_SIG_COMPRESSED_SZ /* signature */ + \
      42           0 :                                               sizeof(ushort)           /* bitmap_sz */ )
      43             : 
      44           0 : #define FD_BLOCK_VOTES_AGGREGATE_SER_SZ( bit_cnt ) ( FD_BLOCK_VOTES_AGGREGATE_SER_HDR_SZ + \
      45           0 :                                                      FD_BLOCK_BITMAP_SER_SZ( bit_cnt ) /* bitmap */ )
      46             : 
      47           0 : #define FD_BLOCK_VOTES_AGGREGATE_SER_MAX ( FD_BLOCK_VOTES_AGGREGATE_SER_SZ( FD_VOTOR_VAT_MAX ) )
      48             : 
      49           0 : #define FD_BLOCK_FINAL_CERT_SER_HDR_SZ ( sizeof(ulong)     /* slot     */ + \
      50           0 :                                          sizeof(fd_hash_t) /* block_id */ )
      51             : 
      52           0 : #define FD_BLOCK_FINAL_CERT_SER_MAX ( FD_BLOCK_FINAL_CERT_SER_HDR_SZ   /* slot, block_id      */ + \
      53           0 :                                       FD_BLOCK_VOTES_AGGREGATE_SER_MAX /* final_aggregate     */ + \
      54           0 :                                       sizeof(uchar)                    /* has_notar_aggregate */ + \
      55           0 :                                       FD_BLOCK_VOTES_AGGREGATE_SER_MAX /* notar_aggregate     */ )
      56             : 
      57           0 : #define FD_BLOCK_REWARD_CERT_SER_CU16_MAX (3UL) /* a ShortU16 is at most three bytes */
      58             : 
      59           0 : #define FD_BLOCK_SKIP_REWARD_CERT_SER_HDR_SZ ( sizeof(ulong)            /* slot      */ + \
      60           0 :                                                FD_BLS_SIG_COMPRESSED_SZ /* signature */ )
      61             : 
      62           0 : #define FD_BLOCK_SKIP_REWARD_CERT_SER_MAX ( FD_BLOCK_SKIP_REWARD_CERT_SER_HDR_SZ       /* slot, signature */ + \
      63           0 :                                             FD_BLOCK_REWARD_CERT_SER_CU16_MAX          /* bitmap_sz       */ + \
      64           0 :                                             FD_BLOCK_BITMAP_SER_SZ( FD_VOTOR_VAT_MAX ) /* bitmap          */ )
      65             : 
      66           0 : #define FD_BLOCK_NOTAR_REWARD_CERT_SER_HDR_SZ ( sizeof(ulong)            /* slot      */ + \
      67           0 :                                                 sizeof(fd_hash_t)        /* block_id  */ + \
      68           0 :                                                 FD_BLS_SIG_COMPRESSED_SZ /* signature */ )
      69             : 
      70           0 : #define FD_BLOCK_NOTAR_REWARD_CERT_SER_MAX ( FD_BLOCK_NOTAR_REWARD_CERT_SER_HDR_SZ      /* slot, block_id, signature */ + \
      71           0 :                                              FD_BLOCK_REWARD_CERT_SER_CU16_MAX          /* bitmap_sz                 */ + \
      72           0 :                                              FD_BLOCK_BITMAP_SER_SZ( FD_VOTOR_VAT_MAX ) /* bitmap                    */ )
      73             : 
      74           0 : #define FD_BLOCK_FOOTER_SER_HDR_SZ ( sizeof(uchar)     /* version                   */ + \
      75           0 :                                      sizeof(fd_hash_t) /* bank_hash                 */ + \
      76           0 :                                      sizeof(ulong)     /* block_producer_time_nanos */ + \
      77           0 :                                      sizeof(uchar)     /* user_agent_len            */ )
      78             : 
      79           0 : #define FD_BLOCK_FOOTER_SER_MAX ( FD_BLOCK_MARKER_PREAMBLE_SZ    /* preamble              */ + \
      80           0 :                                   FD_BLOCK_FOOTER_SER_HDR_SZ     /* fixed fields          */ + \
      81           0 :                                   FD_BLOCK_FOOTER_USER_AGENT_MAX /* user_agent            */ + \
      82           0 :                                   sizeof(uchar)                  /* has_block_final_cert  */ + \
      83           0 :                                   FD_BLOCK_FINAL_CERT_SER_MAX    /* block_final_cert      */ + \
      84           0 :                                   sizeof(uchar)                      /* has_skip_reward_cert  */ + \
      85           0 :                                   FD_BLOCK_SKIP_REWARD_CERT_SER_MAX  /* skip_reward_cert      */ + \
      86           0 :                                   sizeof(uchar)                      /* has_notar_reward_cert */ + \
      87           0 :                                   FD_BLOCK_NOTAR_REWARD_CERT_SER_MAX /* notar_reward_cert     */ )
      88             : 
      89           0 : #define FD_BLOCK_MARKER_SER_MAX ( FD_BLOCK_FOOTER_SER_MAX ) /* the footer is the widest marker */
      90             : 
      91             : FD_STATIC_ASSERT( FD_BLOCK_MARKER_PREAMBLE_SZ                ==  13UL, fd_block_marker_serde );
      92             : FD_STATIC_ASSERT( FD_BLOCK_HEADER_SER_SZ                     ==  41UL, fd_block_marker_serde );
      93             : FD_STATIC_ASSERT( FD_UPDATE_PARENT_SER_SZ                    ==  41UL, fd_block_marker_serde );
      94             : FD_STATIC_ASSERT( FD_BLOCK_BITMAP_SER_HDR_SZ                 ==   3UL, fd_block_marker_serde );
      95             : FD_STATIC_ASSERT( FD_BLOCK_BITMAP_SER_SZ( FD_VOTOR_VAT_MAX ) == 253UL, fd_block_marker_serde );
      96             : FD_STATIC_ASSERT( FD_BLOCK_VOTES_AGGREGATE_SER_HDR_SZ        ==  98UL, fd_block_marker_serde );
      97             : FD_STATIC_ASSERT( FD_BLOCK_VOTES_AGGREGATE_SER_MAX           == 351UL, fd_block_marker_serde );
      98             : FD_STATIC_ASSERT( FD_BLOCK_FINAL_CERT_SER_HDR_SZ             ==  40UL, fd_block_marker_serde );
      99             : FD_STATIC_ASSERT( FD_BLOCK_FINAL_CERT_SER_MAX                == 743UL, fd_block_marker_serde );
     100             : FD_STATIC_ASSERT( FD_BLOCK_SKIP_REWARD_CERT_SER_HDR_SZ       == 104UL, fd_block_marker_serde );
     101             : FD_STATIC_ASSERT( FD_BLOCK_SKIP_REWARD_CERT_SER_MAX          == 360UL, fd_block_marker_serde );
     102             : FD_STATIC_ASSERT( FD_BLOCK_NOTAR_REWARD_CERT_SER_HDR_SZ      == 136UL, fd_block_marker_serde );
     103             : FD_STATIC_ASSERT( FD_BLOCK_NOTAR_REWARD_CERT_SER_MAX         == 392UL, fd_block_marker_serde );
     104             : FD_STATIC_ASSERT( FD_BLOCK_FOOTER_SER_HDR_SZ                 ==  42UL, fd_block_marker_serde );
     105             : FD_STATIC_ASSERT( FD_BLOCK_FOOTER_SER_MAX                    ==1808UL, fd_block_marker_serde );
     106             : FD_STATIC_ASSERT( FD_BLOCK_FOOTER_SER_MAX-FD_BLOCK_MARKER_PREAMBLE_SZ<=(ulong)USHORT_MAX, fd_block_marker_serde ); /* LengthPrefixed::len is a u16 */
     107             : 
     108             : FD_PROTOTYPES_BEGIN
     109             : 
     110             : ulong
     111             : fd_block_marker_ser( fd_block_marker_t const * self,
     112             :                      uchar                     buf[ static FD_BLOCK_MARKER_SER_MAX ] );
     113             : 
     114             : int
     115             : fd_block_marker_de( fd_block_marker_t * self,
     116             :                     uchar const *       buf,
     117             :                     ulong               buf_sz );
     118             : 
     119             : FD_PROTOTYPES_END
     120             : 
     121             : #endif /* HEADER_fd_src_flamenco_alpenglow_fd_block_marker_serde_h */

Generated by: LCOV version 1.14