Skip to content

Commit

Permalink
fddev: print genesis hash and shred version
Browse files Browse the repository at this point in the history
  • Loading branch information
riptl committed Apr 22, 2024
1 parent 7a34721 commit fc6157a
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/app/fddev/configure/genesis.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,17 @@ estimate_hashes_per_tick( ulong tick_mhz,
return (ulong)hashes_per_tick;
}

/* Derive the shred version from a genesis hash */

static ushort
shred_version_from_genesis_hash( uchar const * genesis_hash ) {
uint version = 0;
for( ulong j=0; j<32; j+=2 ) {
version ^= ( genesis_hash[j ] << 8 );
version ^= ( genesis_hash[j+1] );
}
return (ushort)fd_uint_min( version+1, USHORT_MAX );
}

/* Create a new genesis.bin file contents into the provided blob buffer
and return the size of the buffer. Will abort on error if the
Expand Down Expand Up @@ -204,7 +215,14 @@ create_genesis( config_t * const config,
ulong blob_len = fd_genesis_create( blob, blob_sz, options );
if( FD_UNLIKELY( !blob_sz ) ) FD_LOG_ERR(( "Failed to create genesis blob" ));

FD_LOG_DEBUG(( "Created genesis blob (sz=%lu)", blob_len ));
uchar genesis_hash[ 32 ];
fd_sha256_hash( blob, blob_len, genesis_hash );

char genesis_hash_cstr[ FD_BASE58_ENCODED_32_SZ ];
FD_LOG_INFO(( "Created genesis.bin: genesis_hash=%s sz=%lu",
fd_acct_addr_cstr( genesis_hash_cstr, genesis_hash ),
blob_len ));
FD_LOG_INFO(( "Shred version: %u", shred_version_from_genesis_hash( genesis_hash ) ));

fd_scratch_detach( NULL );

Expand Down

0 comments on commit fc6157a

Please sign in to comment.