Line data Source code
1 : #ifndef HEADER_fd_src_flamenco_fd_flamenco_base_h 2 : #define HEADER_fd_src_flamenco_fd_flamenco_base_h 3 : 4 : #include "../ballet/base58/fd_base58.h" 5 : #include "../ballet/sha256/fd_sha256.h" 6 : #include "types/fd_types_custom.h" 7 : #include "types/fd_cast.h" 8 : #include <alloca.h> 9 : 10 0 : #define FD_DEFAULT_SLOTS_PER_EPOCH ( 432000UL ) 11 : #define FD_DEFAULT_SHREDS_PER_EPOCH ( ( 1 << 15UL ) * FD_DEFAULT_SLOTS_PER_EPOCH ) 12 0 : #define FD_SLOT_NULL ( ULONG_MAX ) 13 0 : #define FD_SHRED_IDX_NULL ( UINT_MAX ) 14 : 15 123 : #define FD_FUNK_KEY_TYPE_ACC ((uchar)1) 16 57 : #define FD_FUNK_KEY_TYPE_ELF_CACHE ((uchar)2) 17 : 18 : /* CLUSTER_VERSION is the default value for the cluster version 19 : in the epoch context. This value will foll forward to the 20 : latest version. 21 : */ 22 0 : #define FD_DEFAULT_AGAVE_CLUSTER_VERSION_MAJOR 2 23 0 : #define FD_DEFAULT_AGAVE_CLUSTER_VERSION_MINOR 0 24 0 : #define FD_DEFAULT_AGAVE_CLUSTER_VERSION_PATCH 0 25 : 26 : #if FD_HAS_ALLOCA 27 : 28 : /* FD_BASE58_ENC_{32,64}_ALLOCA is a shorthand for fd_base58_encode_{32,64}, 29 : including defining a temp buffer. With additional support for passing 30 : NULL. Useful for printf-like functions. 31 : Example: 32 : 33 : fd_pubkey_t pk = ... ; 34 : printf("%s", FD_BASE58_ENC_32_ALLOCA( pk ) ); 35 : 36 : The temp buffer is allocated on the stack and therefore invalidated 37 : when the function this is used in returns. NULL will result in 38 : "<NULL>". 39 : Do NOT use this marco in a long loop or a recursive function. 40 : */ 41 : 42 : static inline char * 43 : fd_base58_enc_32_fmt( char * out, 44 12 : uchar const * in ) { 45 12 : if( FD_UNLIKELY( !in ) ) { 46 3 : strcpy( out, "<NULL>"); 47 9 : } else { 48 9 : fd_base58_encode_32( in, NULL, out ); 49 9 : } 50 12 : return out; 51 12 : } 52 : 53 6 : #define FD_BASE58_ENC_32_ALLOCA( x ) __extension__({ \ 54 6 : char * _out = fd_alloca_check( 1UL, FD_BASE58_ENCODED_32_SZ ); \ 55 6 : fd_base58_enc_32_fmt( _out, (uchar const *)(x) ); \ 56 6 : }) 57 : 58 : static inline char * 59 : fd_base58_enc_64_fmt( char * out, 60 6 : uchar const * in ) { 61 6 : if( FD_UNLIKELY( !in ) ) { 62 3 : strcpy( out, "<NULL>"); 63 3 : } else { 64 3 : fd_base58_encode_64( in, NULL, out ); 65 3 : } 66 6 : return out; 67 6 : } 68 : 69 6 : #define FD_BASE58_ENC_64_ALLOCA( x ) __extension__({ \ 70 6 : char * _out = fd_alloca_check( 1UL, FD_BASE58_ENCODED_64_SZ ); \ 71 6 : fd_base58_enc_64_fmt( _out, (uchar const *)(x) ); \ 72 6 : }) 73 : 74 : #endif /* FD_HAS_ALLOCA */ 75 : 76 : /* Forward declarations */ 77 : 78 : struct fd_exec_slot_ctx; 79 : typedef struct fd_exec_slot_ctx fd_exec_slot_ctx_t; 80 : 81 : struct fd_exec_txn_ctx; 82 : typedef struct fd_exec_txn_ctx fd_exec_txn_ctx_t; 83 : 84 : struct fd_exec_instr_ctx; 85 : typedef struct fd_exec_instr_ctx fd_exec_instr_ctx_t; 86 : 87 : struct fd_acc_mgr; 88 : typedef struct fd_acc_mgr fd_acc_mgr_t; 89 : 90 : struct fd_capture_ctx; 91 : typedef struct fd_capture_ctx fd_capture_ctx_t; 92 : 93 : struct fd_borrowed_account; 94 : typedef struct fd_borrowed_account fd_borrowed_account_t; 95 : 96 : struct fd_txn_account; 97 : typedef struct fd_txn_account fd_txn_account_t; 98 : 99 : /* fd_rawtxn_b_t is a convenience type to store a pointer to a 100 : serialized transaction. Should probably be removed in the future. */ 101 : 102 : struct fd_rawtxn_b { 103 : void * raw; 104 : ushort txn_sz; 105 : }; 106 : typedef struct fd_rawtxn_b fd_rawtxn_b_t; 107 : 108 : FD_PROTOTYPES_BEGIN 109 : 110 : /* fd_acct_addr_cstr converts the given Solana address into a base58- 111 : encoded cstr. Returns cstr. On return cstr contains a string with 112 : length in [32,44] (excluding NULL terminator). */ 113 : 114 : static inline char * 115 : fd_acct_addr_cstr( char cstr[ FD_BASE58_ENCODED_32_SZ ], 116 6 : uchar const addr[ 32 ] ) { 117 6 : return fd_base58_encode_32( addr, NULL, cstr ); 118 6 : } 119 : 120 : FD_PROTOTYPES_END 121 : 122 : #endif /* HEADER_fd_src_flamenco_fd_flamenco_base_h */