Line data Source code
1 : #ifndef HEADER_fd_src_flamenco_genesis_fd_genesis_create_h 2 : #define HEADER_fd_src_flamenco_genesis_fd_genesis_create_h 3 : 4 : /* fd_genesis_create.h is a tool for creating Solana genesis blobs. 5 : A genesis blob is used to bootstrap a Solana ledger. */ 6 : 7 : #include "../fd_flamenco_base.h" 8 : #include "../features/fd_features.h" 9 : 10 : 11 : /* fd_genesis_options_t exists as a convenient way to specify options 12 : for genesis creation. */ 13 : 14 : struct fd_genesis_options { 15 : fd_pubkey_t identity_pubkey; 16 : fd_pubkey_t faucet_pubkey; 17 : fd_pubkey_t stake_pubkey; 18 : fd_pubkey_t vote_pubkey; 19 : 20 : ulong creation_time; /* unix time, i.e. seconds since the unix epoch */ 21 : ulong faucet_balance; /* in lamports */ 22 : ulong vote_account_stake; /* in lamports */ 23 : 24 : ulong hashes_per_tick; /* 0 means unset */ 25 : ulong ticks_per_slot; 26 : ulong target_tick_duration_micros; 27 : 28 : ulong fund_initial_accounts; 29 : ulong fund_initial_amount_lamports; 30 : 31 : uchar const * token_program_elf; 32 : ulong token_program_elf_sz; 33 : 34 : int warmup_epochs; 35 : 36 : /* features points to an externally owned feature map. 37 : Adds a feature account to the genesis blob for feature enabled at 38 : slot 0. If features==NULL, creates no feature accounts. */ 39 : fd_features_t const * features; 40 : }; 41 : 42 : typedef struct fd_genesis_options fd_genesis_options_t; 43 : 44 : FD_PROTOTYPES_BEGIN 45 : 46 : /* fd_genesis_create creates a 'genesis.bin' compatible genesis blob. 47 : (Bincode encoded Solana GenesisConfig) [buf,bufsz) is the output 48 : memory region into which the genesis blob will be written. options 49 : points to a struct containing the genesis configuration parameters. 50 : 51 : Returns the number of bytes in the output memory region used on 52 : success. On failure, returns 0UL and logs reason for error. 53 : 54 : Assumes that caller is attached to an fd_scratch with sufficient 55 : memory to buffer intermediate data. Without token accounts, allow 56 : 16384 + 128*n bytes for n funded accounts. With token accounts, 57 : allow 16384 + 704*n + token_program_elf_sz bytes. Requires 2 58 : frames. 59 : 60 : THIS METHOD IS NOT SAFE FOR PRODUCTION USE. 61 : It is intended for development only. */ 62 : 63 : ulong 64 : fd_genesis_create( void * buf, 65 : ulong bufsz, 66 : fd_genesis_options_t const * options ); 67 : 68 : /* The number of token accounts created for each primordial account, and 69 : the token balance each of them holds, when token_program_elf is 70 : set. */ 71 : 72 147 : #define FD_GENESIS_TOKEN_ACCOUNTS_PER_ACCOUNT (2UL) 73 : #define FD_GENESIS_TOKEN_AMOUNT (1UL<<40) 74 : 75 : /* fd_genesis_token_mint_address writes the address of the token mint to 76 : out. 77 : 78 : fd_genesis_token_account_address writes the address of a token 79 : account to out. acct_idx is the index of the owning primordial 80 : account, in [0,fund_initial_accounts), and token_idx selects one of 81 : that owner's accounts, in 82 : [0,FD_GENESIS_TOKEN_ACCOUNTS_PER_ACCOUNT). 83 : 84 : Both are pure functions of their inputs, so callers can rediscover 85 : the addresses without parsing the genesis blob. */ 86 : 87 : void 88 : fd_genesis_token_mint_address( fd_pubkey_t * out ); 89 : 90 : void 91 : fd_genesis_token_account_address( fd_pubkey_t * out, 92 : ulong acct_idx, 93 : ulong token_idx ); 94 : 95 : /* TODO Add method to estimate the scratch and genesis blob size given options */ 96 : 97 : FD_PROTOTYPES_END 98 : 99 : #endif /* HEADER_fd_src_flamenco_genesis_fd_genesis_create_h */