LCOV - code coverage report
Current view: top level - flamenco/types - fd_types_custom.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 13 19 68.4 %
Date: 2026-05-09 06:38:12 Functions: 16 1179 1.4 %

          Line data    Source code
       1             : #ifndef HEADER_fd_src_flamenco_types_fd_types_custom_h
       2             : #define HEADER_fd_src_flamenco_types_fd_types_custom_h
       3             : 
       4             : #include "../fd_flamenco_base.h"
       5             : #include "fd_bincode.h"
       6             : #include "../../ballet/bmtree/fd_bmtree.h"
       7             : 
       8             : #define FD_SIGNATURE_ALIGN (8UL)
       9             : 
      10             : /* TODO this should not have packed alignment, but it's misused everywhere */
      11             : 
      12       20376 : #define FD_HASH_FOOTPRINT   (32UL)
      13             : #define FD_HASH_ALIGN       (8UL)
      14        1140 : #define FD_PUBKEY_FOOTPRINT FD_HASH_FOOTPRINT
      15             : #define FD_PUBKEY_ALIGN     FD_HASH_ALIGN
      16             : union __attribute__((packed)) fd_hash {
      17             :   uchar hash[ FD_HASH_FOOTPRINT ];
      18             :   uchar key [ FD_HASH_FOOTPRINT ]; // Making fd_hash and fd_pubkey interchangeable
      19             : 
      20             :   // Generic type specific accessors
      21             :   ulong  ul  [ FD_HASH_FOOTPRINT / sizeof(ulong)  ];
      22             :   uint   ui  [ FD_HASH_FOOTPRINT / sizeof(uint)   ];
      23             :   ushort us  [ FD_HASH_FOOTPRINT / sizeof(ushort) ];
      24             :   uchar  uc  [ FD_HASH_FOOTPRINT                  ];
      25             : };
      26             : typedef union fd_hash fd_hash_t;
      27             : typedef union fd_hash fd_pubkey_t;
      28             : 
      29             : 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 */
      30             : 
      31             : FD_FN_PURE static inline int
      32             : fd_hash_eq( fd_hash_t const * a,
      33        7149 :             fd_hash_t const * b ) {
      34        7149 :   return 0==memcmp( a, b, sizeof(fd_hash_t) );
      35        7149 : }
      36             : 
      37             : FD_FN_PURE static inline int
      38             : fd_hash_eq1( fd_hash_t a,
      39         453 :              fd_hash_t b ) {
      40         453 :   return
      41         453 :     ( a.ul[0]==b.ul[0] ) & ( a.ul[1]==b.ul[1] ) &
      42         453 :     ( a.ul[2]==b.ul[2] ) & ( a.ul[3]==b.ul[3] );
      43         453 : }
      44             : 
      45             : union fd_signature {
      46             :   uchar uc[ 64 ];
      47             :   ulong ul[  8 ];
      48             : };
      49             : typedef union fd_signature fd_signature_t;
      50             : 
      51             : struct fd_hard_fork {
      52             :   ulong slot;
      53             :   ulong cnt; /* number of hard forks in that slot */
      54             : };
      55             : typedef struct fd_hard_fork fd_hard_fork_t;
      56             : 
      57             : FD_FN_PURE
      58             : static inline int
      59             : fd_signature_eq( fd_signature_t const * a,
      60           0 :                  fd_signature_t const * b ) {
      61           0 :   return 0==memcmp( a, b, sizeof(fd_signature_t) );
      62           0 : }
      63             : 
      64             : FD_PROTOTYPES_BEGIN
      65             : 
      66             : #define fd_hash_check_zero(_x) (!((_x)->ul[0] | (_x)->ul[1] | (_x)->ul[2] | (_x)->ul[3]))
      67             : #define fd_hash_set_zero(_x)   {((_x)->ul[0] = 0); ((_x)->ul[1] = 0); ((_x)->ul[2] = 0); ((_x)->ul[3] = 0);}
      68             : 
      69             : #define fd_pubkey_check_zero              fd_hash_check_zero
      70             : #define fd_pubkey_set_zero                fd_hash_set_zero
      71        5994 : #define fd_pubkey_eq                      fd_hash_eq
      72             : 
      73             : FD_PROTOTYPES_END
      74             : 
      75           0 : #define FD_DUMMY_ACCOUNT { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF }
      76             : static const fd_pubkey_t FD_DUMMY_ACCOUNT_PUBKEY = { .uc = FD_DUMMY_ACCOUNT };
      77             : 
      78             : struct fd_vote_stake_weight {
      79             :   fd_pubkey_t vote_key; /* vote account pubkey */
      80             :   fd_pubkey_t id_key;   /* validator identity pubkey */
      81             :   ulong       stake;    /* total stake by vote account */
      82             : };
      83             : typedef struct fd_vote_stake_weight fd_vote_stake_weight_t;
      84             : 
      85             : #define SORT_NAME sort_vote_weights_by_stake_vote
      86          12 : #define SORT_KEY_T fd_vote_stake_weight_t
      87           6 : #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))
      88             : #include "../../util/tmpl/fd_sort.c"
      89             : 
      90             : struct fd_stake_weight {
      91             :   fd_pubkey_t key;      /* validator identity pubkey */
      92             :   ulong       stake;    /* total stake by identity */
      93             : };
      94             : typedef struct fd_stake_weight fd_stake_weight_t;
      95             : 
      96             : #define SORT_NAME fd_stake_weight_key_sort
      97           0 : #define SORT_KEY_T fd_stake_weight_t
      98           0 : #define SORT_BEFORE(a,b) (memcmp( (a).key.uc, (b).key.uc, 32UL )<0)
      99             : #include "../../util/tmpl/fd_sort.c"
     100             : 
     101             : struct fd_fee_rate_governor {
     102             :   ulong target_lamports_per_signature;
     103             :   ulong target_signatures_per_slot;
     104             :   ulong min_lamports_per_signature;
     105             :   ulong max_lamports_per_signature;
     106             :   uchar burn_percent;
     107             : };
     108             : typedef struct fd_fee_rate_governor fd_fee_rate_governor_t;
     109             : 
     110             : struct fd_inflation {
     111             :   double initial;
     112             :   double terminal;
     113             :   double taper;
     114             :   double foundation;
     115             :   double foundation_term;
     116             :   double unused;
     117             : };
     118             : typedef struct fd_inflation fd_inflation_t;
     119             : 
     120             : #endif /* HEADER_fd_src_flamenco_types_fd_types_custom_h */

Generated by: LCOV version 1.14