LCOV - code coverage report
Current view: top level - flamenco/genesis - fd_genesis_create.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 1 0.0 %
Date: 2026-10-23 17:13:25 Functions: 0 0 -

          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             : #include "../runtime/program/vote/fd_vote_codec.h"
      10             : 
      11             : 
      12             : /* fd_genesis_options_t exists as a convenient way to specify options
      13             :    for genesis creation. */
      14             : 
      15             : struct fd_genesis_options {
      16             :   fd_pubkey_t identity_pubkey;
      17             :   fd_pubkey_t faucet_pubkey;
      18             :   fd_pubkey_t stake_pubkey;
      19             :   fd_pubkey_t vote_pubkey;
      20             : 
      21             :   ulong creation_time;      /* unix time, i.e. seconds since the unix epoch */
      22             :   ulong faucet_balance;     /* in lamports */
      23             :   ulong vote_account_stake; /* in lamports */
      24             : 
      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             :   /* bls_pubkey is the compressed BLS pubkey written into the vote
      37             :      account.  Should be derived from the identity key with
      38             :      fd_keyguard_bls_key_derive, else the validator cannot vote under
      39             :      Alpenglow. */
      40             :   uchar bls_pubkey[ FD_BLS_PUBKEY_COMPRESSED_SZ ];
      41             : 
      42             :   /* features points to an externally owned feature map.
      43             :      Adds a feature account to the genesis blob for feature enabled at
      44             :      slot 0.  If features==NULL, creates no feature accounts. */
      45             :   fd_features_t const * features;
      46             : };
      47             : 
      48             : typedef struct fd_genesis_options fd_genesis_options_t;
      49             : 
      50             : FD_PROTOTYPES_BEGIN
      51             : 
      52             : /* fd_genesis_create creates a 'genesis.bin' compatible genesis blob.
      53             :    (Bincode encoded Solana GenesisConfig)  [buf,bufsz) is the output
      54             :    memory region into which the genesis blob will be written.  options
      55             :    points to a struct containing the genesis configuration parameters.
      56             : 
      57             :    Returns the number of bytes in the output memory region used on
      58             :    success.  On failure, returns 0UL and logs reason for error.
      59             : 
      60             :    Assumes that caller is attached to an fd_scratch with sufficient
      61             :    memory to buffer intermediate data.  Without token accounts, allow
      62             :    16384 + 128*n bytes for n funded accounts.  With token accounts,
      63             :    allow 16384 + 704*n + token_program_elf_sz bytes.  Requires 2
      64             :    frames.
      65             : 
      66             :    THIS METHOD IS NOT SAFE FOR PRODUCTION USE.
      67             :    It is intended for development only. */
      68             : 
      69             : ulong
      70             : fd_genesis_create( void *                       buf,
      71             :                    ulong                        bufsz,
      72             :                    fd_genesis_options_t const * options );
      73             : 
      74             : /* The number of token accounts created for each primordial account, and
      75             :    the token balance each of them holds, when token_program_elf is
      76             :    set. */
      77             : 
      78           0 : #define FD_GENESIS_TOKEN_ACCOUNTS_PER_ACCOUNT (2UL)
      79             : #define FD_GENESIS_TOKEN_AMOUNT               (1UL<<40)
      80             : 
      81             : /* fd_genesis_token_mint_address writes the address of the token mint to
      82             :    out.
      83             : 
      84             :    fd_genesis_token_account_address writes the address of a token
      85             :    account to out.  acct_idx is the index of the owning primordial
      86             :    account, in [0,fund_initial_accounts), and token_idx selects one of
      87             :    that owner's accounts, in
      88             :    [0,FD_GENESIS_TOKEN_ACCOUNTS_PER_ACCOUNT).
      89             : 
      90             :    Both are pure functions of their inputs, so callers can rediscover
      91             :    the addresses without parsing the genesis blob. */
      92             : 
      93             : void
      94             : fd_genesis_token_mint_address( fd_pubkey_t * out );
      95             : 
      96             : void
      97             : fd_genesis_token_account_address( fd_pubkey_t * out,
      98             :                                   ulong         acct_idx,
      99             :                                   ulong         token_idx );
     100             : 
     101             : /* TODO Add method to estimate the scratch and genesis blob size given options */
     102             : 
     103             : FD_PROTOTYPES_END
     104             : 
     105             : #endif /* HEADER_fd_src_flamenco_genesis_fd_genesis_create_h */

Generated by: LCOV version 1.14