LCOV - code coverage report
Current view: top level - flamenco/types - fd_types_custom.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 16 24 66.7 %
Date: 2025-10-13 04:42:14 Functions: 4 993 0.4 %

          Line data    Source code
       1             : #ifndef HEADER_fd_src_flamenco_runtime_fd_types_custom
       2             : #define HEADER_fd_src_flamenco_runtime_fd_types_custom
       3             : 
       4             : #include "../fd_flamenco_base.h"
       5             : #include "fd_types_meta.h"
       6             : #include "fd_bincode.h"
       7             : #include "../../ballet/bmtree/fd_bmtree.h"
       8             : #include "../../ballet/ed25519/fd_ed25519.h"
       9             : 
      10             : #define FD_SIGNATURE_ALIGN (8UL)
      11             : 
      12             : /* TODO this should not have packed alignment, but it's misused everywhere */
      13             : 
      14        1830 : #define FD_HASH_FOOTPRINT   (32UL)
      15           0 : #define FD_HASH_ALIGN       (8UL)
      16        1830 : #define FD_PUBKEY_FOOTPRINT FD_HASH_FOOTPRINT
      17           0 : #define FD_PUBKEY_ALIGN     FD_HASH_ALIGN
      18             : union __attribute__((packed)) fd_hash {
      19             :   uchar hash[ FD_HASH_FOOTPRINT ];
      20             :   uchar key [ FD_HASH_FOOTPRINT ]; // Making fd_hash and fd_pubkey interchangeable
      21             : 
      22             :   // Generic type specific accessors
      23             :   ulong ul  [ FD_HASH_FOOTPRINT / sizeof(ulong) ];
      24             :   uint  ui  [ FD_HASH_FOOTPRINT / sizeof(uint)  ];
      25             :   uchar uc  [ FD_HASH_FOOTPRINT ];
      26             : };
      27             : typedef union fd_hash fd_hash_t;
      28             : typedef union fd_hash fd_pubkey_t;
      29             : 
      30             : FD_STATIC_ASSERT( sizeof(fd_hash_t) == sizeof(fd_bmtree_node_t), hash incompatibility ); /* various areas of Firedancer code use fd_hash_t as the type for merkle roots */
      31             : 
      32             : FD_FN_PURE static inline int
      33             : fd_hash_eq( fd_hash_t const * a,
      34         741 :             fd_hash_t const * b ) {
      35         741 :   return 0==memcmp( a, b, sizeof(fd_hash_t) );
      36         741 : }
      37             : 
      38             : FD_FN_PURE static inline int
      39             : fd_hash_eq1( fd_hash_t a,
      40         453 :              fd_hash_t b ) {
      41         453 :   return
      42         453 :     ( a.ul[0]==b.ul[0] ) & ( a.ul[1]==b.ul[1] ) &
      43         453 :     ( a.ul[2]==b.ul[2] ) & ( a.ul[3]==b.ul[3] );
      44         453 : }
      45             : 
      46             : union fd_signature {
      47             :   uchar uc[ 64 ];
      48             :   ulong ul[  8 ];
      49             : };
      50             : typedef union fd_signature fd_signature_t;
      51             : 
      52             : 
      53             : FD_FN_PURE
      54             : static inline int
      55             : fd_signature_eq( fd_signature_t const * a,
      56           0 :                  fd_signature_t const * b ) {
      57           0 :   return 0==memcmp( a, b, sizeof(fd_signature_t) );
      58           0 : }
      59             : 
      60             : 
      61             : FD_PROTOTYPES_BEGIN
      62             : 
      63             : #define fd_hash_check_zero(_x) (!((_x)->ul[0] | (_x)->ul[1] | (_x)->ul[2] | (_x)->ul[3]))
      64             : #define fd_hash_set_zero(_x)   {((_x)->ul[0] = 0); ((_x)->ul[1] = 0); ((_x)->ul[2] = 0); ((_x)->ul[3] = 0);}
      65             : 
      66          36 : #define fd_pubkey_new                     fd_hash_new
      67         978 : #define fd_pubkey_encode                  fd_hash_encode
      68             : #define fd_pubkey_destroy                 fd_hash_destroy
      69           0 : #define fd_pubkey_size                    fd_hash_size
      70             : #define fd_pubkey_check_zero              fd_hash_check_zero
      71             : #define fd_pubkey_set_zero                fd_hash_set_zero
      72         330 : #define fd_pubkey_walk                    fd_hash_walk
      73         552 : #define fd_pubkey_decode_inner            fd_hash_decode_inner
      74             : #define fd_pubkey_decode_footprint        fd_hash_decode_footprint
      75          42 : #define fd_pubkey_decode_footprint_inner  fd_hash_decode_footprint_inner
      76             : #define fd_pubkey_decode                  fd_hash_decode
      77         171 : #define fd_pubkey_eq                      fd_hash_eq
      78             : 
      79             : struct __attribute__((aligned(8UL))) fd_option_slot {
      80             :   uchar is_some;
      81             :   ulong slot;
      82             : };
      83             : typedef struct fd_option_slot fd_option_slot_t;
      84             : 
      85             : /* Index structure needed for transaction status (metadata) blocks */
      86             : struct fd_txnstatusidx {
      87             :     fd_ed25519_sig_t sig;
      88             :     ulong offset;
      89             :     ulong status_sz;
      90             : };
      91             : typedef struct fd_txnstatusidx fd_txnstatusidx_t;
      92             : 
      93             : typedef struct fd_rust_duration fd_rust_duration_t;
      94             : 
      95             : void
      96             : fd_rust_duration_normalize ( fd_rust_duration_t * );
      97             : 
      98             : int
      99             : fd_rust_duration_footprint_validator ( fd_bincode_decode_ctx_t * ctx );
     100             : 
     101             : int fd_tower_sync_decode_footprint_inner( fd_bincode_decode_ctx_t * ctx, ulong * total_sz );
     102             : void fd_tower_sync_decode_inner( void * struct_mem, void * * alloc_mem, fd_bincode_decode_ctx_t * ctx );
     103             : 
     104             : FD_PROTOTYPES_END
     105             : 
     106             : struct fd_vote_stake_weight {
     107             :   fd_pubkey_t vote_key; /* vote account pubkey */
     108             :   fd_pubkey_t id_key;   /* validator identity pubkey */
     109             :   ulong       stake;    /* total stake by vote account */
     110             : };
     111             : typedef struct fd_vote_stake_weight fd_vote_stake_weight_t;
     112             : 
     113             : #define SORT_NAME sort_vote_weights_by_stake_vote
     114           0 : #define SORT_KEY_T fd_vote_stake_weight_t
     115           0 : #define SORT_BEFORE(a,b) ((a).stake > (b).stake ? 1 : ((a).stake < (b).stake ? 0 : memcmp( (a).vote_key.uc, (b).vote_key.uc, 32UL )>0))
     116             : #include "../../util/tmpl/fd_sort.c"
     117             : 
     118             : struct fd_stake_weight {
     119             :   fd_pubkey_t key;      /* validator identity pubkey */
     120             :   ulong       stake;    /* total stake by identity */
     121             : };
     122             : typedef struct fd_stake_weight fd_stake_weight_t;
     123             : 
     124             : struct fd_stake_weight_t_mapnode {
     125             :     fd_stake_weight_t elem;
     126             :     ulong redblack_parent;
     127             :     ulong redblack_left;
     128             :     ulong redblack_right;
     129             :     int redblack_color;
     130             : };
     131             : typedef struct fd_stake_weight_t_mapnode fd_stake_weight_t_mapnode_t;
     132             : #define REDBLK_T fd_stake_weight_t_mapnode_t
     133             : #define REDBLK_NAME fd_stake_weight_t_map
     134             : #define REDBLK_IMPL_STYLE 1
     135             : #include "../../util/tmpl/fd_redblack.c"
     136             : 
     137             : #endif /* HEADER_fd_src_flamenco_runtime_fd_types_custom */

Generated by: LCOV version 1.14