Line data Source code
1 : #ifndef HEADER_fd_src_flamenco_runtime_fd_genesis_parse_h 2 : #define HEADER_fd_src_flamenco_runtime_fd_genesis_parse_h 3 : 4 : #include "../../util/fd_util_base.h" 5 : #include "../fd_flamenco_base.h" 6 : 7 : /* These two constants are not defined at the Solana protocol level 8 : and are instead used to bound out the amount of memory that will be 9 : allocated for the genesis message. */ 10 : #define FD_GENESIS_ACCOUNT_MAX_COUNT (2048UL) 11 : #define FD_GENESIS_BUILTIN_MAX_COUNT (16UL) 12 0 : #define FD_GENESIS_MAX_MESSAGE_SIZE (1024UL*1024UL*10UL) /* 10MiB */ 13 : 14 0 : #define FD_GENESIS_TYPE_TESTNET (0) 15 0 : #define FD_GENESIS_TYPE_MAINNET (1) 16 0 : #define FD_GENESIS_TYPE_DEVNET (2) 17 : #define FD_GENESIS_TYPE_DEVELOPMENT (3) 18 : 19 : struct fd_genesis_account { 20 : uchar pubkey[32]; 21 : fd_account_meta_t meta; 22 : uchar data[]; 23 : }; 24 : typedef struct fd_genesis_account fd_genesis_account_t; 25 : 26 : struct fd_genesis_builtin { 27 : uchar pubkey[32]; 28 : ulong data_len; 29 : uchar data[]; 30 : }; 31 : typedef struct fd_genesis_builtin fd_genesis_builtin_t; 32 : 33 : struct fd_genesis { 34 : /* total_sz represents the total memory footprint taken up by 35 : fd_genesis_t and the variable length data that follows. */ 36 : ulong total_sz; 37 : 38 : ulong creation_time; 39 : uint cluster_type; 40 : 41 : struct { 42 : ulong ticks_per_slot; 43 : ulong tick_duration_secs; 44 : ulong tick_duration_ns; 45 : ulong target_tick_count; 46 : ulong hashes_per_tick; 47 : } poh; 48 : 49 : struct { 50 : ulong target_lamports_per_signature; 51 : ulong target_signatures_per_slot; 52 : ulong min_lamports_per_signature; 53 : ulong max_lamports_per_signature; 54 : uchar burn_percent; 55 : } fee_rate_governor; 56 : 57 : struct { 58 : ulong lamports_per_uint8_year; 59 : double exemption_threshold; 60 : uchar burn_percent; 61 : } rent; 62 : 63 : struct { 64 : double initial; 65 : double terminal; 66 : double taper; 67 : double foundation; 68 : double foundation_term; 69 : } inflation; 70 : 71 : struct { 72 : ulong slots_per_epoch; 73 : ulong leader_schedule_slot_offset; 74 : uchar warmup; 75 : ulong first_normal_epoch; 76 : ulong first_normal_slot; 77 : } epoch_schedule; 78 : 79 : ulong accounts_len; 80 : uint accounts_off[ FD_GENESIS_ACCOUNT_MAX_COUNT ]; 81 : ulong builtin_len; 82 : uint builtin_off[ FD_GENESIS_BUILTIN_MAX_COUNT ]; 83 : 84 : /* variable length account data follows */ 85 : }; 86 : typedef struct fd_genesis fd_genesis_t; 87 : 88 : FD_PROTOTYPES_BEGIN 89 : 90 : /* fd_genesis_parse is a bincode parser for an encoded genesis type 91 : which outputs a pointer to a decoded struct (fd_genesis_t). 92 : A genesis_mem which is a region of memory assumed to be at minimum 93 : of footprint FD_GENESIS_MAX_MESSAGE_SIZE with alignment of 94 : alignof(fd_genesis_t) is passed in along with a binary blob (bin) of 95 : size (bin_sz). 96 : 97 : The data in the binary blob will be assumed to be a bincode encoded 98 : genesis type and will be decoded into a fd_genesis_t 99 : type using the memory in genesis_mem. If the type is a valid bincode 100 : encoded genesis type and it doesn't violate any Solana cluster 101 : protocol limits as well as any Firedancer specific buffer limits 102 : (e.g. number of accounts, total accounts footprint, etc.) then a 103 : pointer to a valid fd_genesis_t will be returned. If the decoding 104 : fails due to being an invalid input or violating aforementioned 105 : limits, then NULL will be returned. 106 : 107 : The bincode encoded type matches the Agave client GenesisConfig type. 108 : https://github.com/anza-xyz/solana-sdk/blob/genesis-config%40v3.0.0/genesis-config/src/lib.rs#L59 */ 109 : 110 : fd_genesis_t * 111 : fd_genesis_parse( void * genesis_mem, 112 : uchar const * bin, 113 : ulong bin_sz ); 114 : 115 : FD_PROTOTYPES_END 116 : 117 : #endif /* HEADER_fd_src_flamenco_runtime_fd_genesis_parse_h */