Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fddev: enable the same feature flags we had before #1570

Merged
merged 2 commits into from
Apr 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 95 additions & 22 deletions src/app/fddev/configure/genesis.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,81 @@

#include "../../../ballet/poh/fd_poh.h"
#include "../../../disco/keyguard/fd_keyload.h"
#include "../../../flamenco/features/fd_features.h"
#include "../../../flamenco/genesis/fd_genesis_create.h"
#include "../../../flamenco/types/fd_types_custom.h"
#include "../../../flamenco/runtime/sysvar/fd_sysvar_clock.h"

#define NAME "genesis"

/* default_enable_features is a table of features enabled by default */

static void
default_enable_features( fd_features_t * features ) {
features->index_erasure_conflict_duplicate_proofs = 0UL;
features->curve25519_restrict_msm_length = 0UL;
features->commission_updates_only_allowed_in_first_half_of_epoch = 0UL;
features->validate_fee_collector_account = 0UL;
features->zk_token_sdk_enabled = 0UL;
features->enable_zk_transfer_with_fee = 0UL;
features->incremental_snapshot_only_incremental_hash_calculation = 0UL;
features->stake_redelegate_instruction = 0UL;
features->timely_vote_credits = 0UL;
features->apply_cost_tracker_during_replay = 0UL;
features->reject_callx_r10 = 0UL;
features->update_hashes_per_tick = 0UL;
features->enable_partitioned_epoch_reward = 0UL;
features->pico_inflation = 0UL;
features->libsecp256k1_fail_on_bad_count2 = 0UL;
features->remaining_compute_units_syscall_enabled = 0UL;
features->simplify_writable_program_account_check = 0UL;
features->set_exempt_rent_epoch_max = 0UL;
features->enable_bpf_loader_set_authority_checked_ix = 0UL;
features->consume_blockstore_duplicate_proofs = 0UL;
features->disable_deploy_of_alloc_free_syscall = 0UL;
features->disable_bpf_loader_instructions = 0UL;
features->full_inflation_enable = 0UL;
features->vote_state_add_vote_latency = 0UL;
features->curve25519_syscall_enabled = 0UL;
features->error_on_syscall_bpf_function_hash_collisions = 0UL;
features->update_hashes_per_tick3 = 0UL;
features->update_hashes_per_tick4 = 0UL;
features->enable_bpf_loader_extend_program_ix = 0UL;
features->libsecp256k1_fail_on_bad_count = 0UL;
features->enable_program_runtime_v2_and_loader_v4 = 0UL;
features->increase_tx_account_lock_limit = 0UL;
features->stake_raise_minimum_delegation_to_1_sol = 0UL;
features->enable_alt_bn128_syscall = 0UL;
features->revise_turbine_epoch_stakes = 0UL;
features->clean_up_delegation_errors = 0UL;
features->update_hashes_per_tick5 = 0UL;
features->full_inflation_vote = 0UL;
features->skip_rent_rewrites = 0UL;
features->switch_to_new_elf_parser = 0UL;
features->require_rent_exempt_split_destination = 0UL;
features->enable_turbine_fanout_experiments = 0UL;
features->devnet_and_testnet = 0UL;
features->enable_big_mod_exp_syscall = 0UL;
features->enable_alt_bn128_compression_syscall = 0UL;
features->update_hashes_per_tick2 = 0UL;
features->include_loaded_accounts_data_size_in_fee_calculation = 0UL;
features->bpf_account_data_direct_mapping = 0UL;
features->relax_authority_signer_check_for_lookup_table_creation = 0UL;
features->update_hashes_per_tick6 = 0UL;
features->enable_poseidon_syscall = 0UL;
features->better_error_codes_for_tx_lamport_check = 0UL;
features->stake_minimum_delegation_for_rewards = 0UL;
features->loosen_cpi_size_restriction = 0UL;
features->drop_legacy_shreds = 0UL;
features->deprecate_rewards_sysvar = 0UL;
features->warp_timestamp_again = 0UL;
features->reduce_stake_warmup_cooldown = 0UL;
features->disable_turbine_fanout_experiments = 0UL;
features->blake3_syscall_enabled = 0UL;
features->last_restart_slot_sysvar = 0UL;
features->disable_fees_sysvar = 0UL;
}

/* estimate_hashes_per_tick approximates the PoH hashrate of the current
tile. Spins PoH hashing for estimate_dur_ns nanoseconds. Returns
the hashes per tick achieved, where tick_mhz is the target tick rate
Expand Down Expand Up @@ -45,6 +114,7 @@ estimate_hashes_per_tick( ulong tick_mhz,
return (ulong)hashes_per_tick;
}


/* 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
provided buffer is not large enough. */
Expand All @@ -53,39 +123,34 @@ static ulong
create_genesis( config_t * const config,
uchar * blob,
ulong blob_sz ) {

fd_genesis_options_t options[1];

/* Read in keys */

uchar const * identity_pubkey_ = fd_keyload_load( config->consensus.identity_path, 1 );
if( FD_UNLIKELY( !identity_pubkey_ ) ) FD_LOG_ERR(( "Failed to load identity key" ));
fd_pubkey_t identity_pubkey; memcpy( identity_pubkey.key, identity_pubkey_, 32 );
memcpy( options->identity_pubkey.key, identity_pubkey_, 32 );

char file_path[ PATH_MAX ];
FD_TEST( fd_cstr_printf_check( file_path, PATH_MAX, NULL, "%s/faucet.json", config->scratch_directory ) );
uchar const * faucet_pubkey_ = fd_keyload_load( file_path, 1 );
if( FD_UNLIKELY( !faucet_pubkey_ ) ) FD_LOG_ERR(( "Failed to load faucet key" ));
fd_pubkey_t faucet_pubkey; memcpy( faucet_pubkey.key, faucet_pubkey_, 32 );
memcpy( options->faucet_pubkey.key, faucet_pubkey_, 32 );

FD_TEST( fd_cstr_printf_check( file_path, PATH_MAX, NULL, "%s/stake-account.json", config->scratch_directory ) );
uchar const * stake_pubkey_ = fd_keyload_load( file_path, 1 );
if( FD_UNLIKELY( !stake_pubkey_ ) ) FD_LOG_ERR(( "Failed to load stake account key" ));
fd_pubkey_t stake_pubkey; memcpy( stake_pubkey.key, stake_pubkey_, 32 );
memcpy( options->stake_pubkey.key, stake_pubkey_, 32 );

FD_TEST( fd_cstr_printf_check( file_path, PATH_MAX, NULL, "%s/vote-account.json", config->scratch_directory ) );
uchar const * vote_pubkey_ = fd_keyload_load( file_path, 1 );
if( FD_UNLIKELY( !vote_pubkey_ ) ) FD_LOG_ERR(( "Failed to load vote account key" ));
fd_pubkey_t vote_pubkey; memcpy( vote_pubkey.key, vote_pubkey_, 32 );

uchar pod_mem[ 8192 ];
uchar * pod = fd_pod_join( fd_pod_new( pod_mem, sizeof(pod_mem) ) );

fd_pod_insert_pubkey( pod, "identity.pubkey", &identity_pubkey );
fd_pod_insert_pubkey( pod, "faucet.pubkey", &faucet_pubkey );
fd_pod_insert_pubkey( pod, "stake.pubkey", &stake_pubkey );
fd_pod_insert_pubkey( pod, "vote.pubkey", &vote_pubkey );
memcpy( options->vote_pubkey.key, vote_pubkey_, 32 );

fd_pod_insert_ulong( pod, "creation_time", (ulong)fd_log_wallclock() / (ulong)1e9 );

fd_pod_insert_ulong( pod, "faucet.balance", 500000000000000000UL );
options->creation_time = (ulong)fd_log_wallclock() / (ulong)1e9;
options->faucet_balance = 500000000000000000UL;

/* Set up PoH config */

Expand All @@ -102,24 +167,32 @@ create_genesis( config_t * const config,
hashes_per_tick = FD_SYSVAR_CLOCK_DEFAULT_HASHES_PER_TICK;
}

fd_pod_insert_ulong( pod, "hashes_per_tick", hashes_per_tick );
options->hashes_per_tick = hashes_per_tick;

} else if( 1UL==config->development.genesis.hashes_per_tick ) {

/* do not set hashes_per_tick field */
/* set hashes_per_tick field to 0, which means sleep mode */
options->hashes_per_tick = 0UL;

} else {

/* set hashes_per_tick to the specified value */
fd_pod_insert_ulong( pod, "hashes_per_tick", config->development.genesis.hashes_per_tick );
options->hashes_per_tick = config->development.genesis.hashes_per_tick;

}

fd_pod_insert_ulong( pod, "ticks_per_slot", config->development.genesis.ticks_per_slot );
fd_pod_insert_ulong( pod, "target_tick_µs", config->development.genesis.target_tick_duration_micros );
options->ticks_per_slot = config->development.genesis.ticks_per_slot;
options->target_tick_duration_micros = config->development.genesis.target_tick_duration_micros;

options->fund_initial_accounts = config->development.genesis.fund_initial_accounts;
options->fund_initial_amount_lamports = config->development.genesis.fund_initial_amount_lamports;

fd_features_t features[1];
fd_features_disable_all( features );
fd_features_enable_hardcoded( features );
default_enable_features( features );

fd_pod_insert_ulong( pod, "default_funded.cnt", config->development.genesis.fund_initial_accounts );
fd_pod_insert_ulong( pod, "default_funded.balance", config->development.genesis.fund_initial_amount_lamports );
options->features = features;

/* Serialize blob */

Expand All @@ -128,7 +201,7 @@ create_genesis( config_t * const config,
fd_scratch_attach( scratch_smem, scratch_fmem,
sizeof(scratch_smem), sizeof(scratch_fmem)/sizeof(ulong) );

ulong blob_len = fd_genesis_create( blob, blob_sz, pod );
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 ));
Expand Down
4 changes: 2 additions & 2 deletions src/flamenco/features/fd_features.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ fd_features_enable_hardcoded( fd_features_t * );

for( fd_feature_id_t const * id = fd_feature_iter_init();
!fd_feature_iter_done( id );
id = fd_feature_iter_next( id ) ) {{
id = fd_feature_iter_next( id ) ) {
...
}} */
} */

static inline fd_feature_id_t const *
fd_feature_iter_init( void ) {
Expand Down
Loading