Skip to content
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
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dev-bins/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 43 additions & 13 deletions genesis/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#![allow(clippy::arithmetic_side_effects)]

use {
agave_feature_set::FEATURE_NAMES,
agave_feature_set::{vote_state_v4, FEATURE_NAMES},
base64::{prelude::BASE64_STANDARD, Engine},
clap::{crate_description, crate_name, value_t, value_t_or_exit, App, Arg, ArgMatches},
itertools::Itertools,
Expand Down Expand Up @@ -48,7 +48,7 @@ use {
solana_sdk_ids::system_program,
solana_signer::Signer,
solana_stake_interface::state::StakeStateV2,
solana_vote_program::vote_state::{self, VoteStateV4},
solana_vote_program::vote_state::{self, VoteStateV3, VoteStateV4},
std::{
collections::HashMap,
error,
Expand Down Expand Up @@ -131,6 +131,7 @@ pub fn load_validator_accounts(
commission: u8,
rent: &Rent,
genesis_config: &mut GenesisConfig,
vote_state_v4_enabled: bool,
) -> io::Result<()> {
let accounts_file = File::open(file)?;
let validator_genesis_accounts: Vec<StakedValidatorAccountInfo> =
Expand Down Expand Up @@ -179,6 +180,7 @@ pub fn load_validator_accounts(
commission,
rent,
None,
vote_state_v4_enabled,
)?;
}

Expand Down Expand Up @@ -258,6 +260,7 @@ fn add_validator_accounts(
commission: u8,
rent: &Rent,
authorized_pubkey: Option<&Pubkey>,
vote_state_v4_enabled: bool,
) -> io::Result<()> {
rent_exempt_check(
stake_lamports,
Expand All @@ -277,14 +280,24 @@ fn add_validator_accounts(
);

let bls_pubkey_compressed_bytes = bls_pubkeys_iter.next().map(|bls_pubkey| bls_pubkey.0);
let vote_account = vote_state::create_v4_account_with_authorized(
identity_pubkey,
identity_pubkey,
identity_pubkey,
bls_pubkey_compressed_bytes,
u16::from(commission) * 100,
rent.minimum_balance(VoteStateV4::size_of()).max(1),
);
let vote_account = if vote_state_v4_enabled {
vote_state::create_v4_account_with_authorized(
identity_pubkey,
identity_pubkey,
identity_pubkey,
bls_pubkey_compressed_bytes,
u16::from(commission) * 100,
rent.minimum_balance(VoteStateV4::size_of()).max(1),
)
} else {
vote_state::create_v3_account_with_authorized(
identity_pubkey,
identity_pubkey,
identity_pubkey,
commission,
rent.minimum_balance(VoteStateV3::size_of()).max(1),
)
};

genesis_config.add_account(
*stake_pubkey,
Expand Down Expand Up @@ -727,6 +740,9 @@ fn main() -> Result<(), Box<dyn error::Error>> {
std::process::exit(1);
});

// Determine if vote_state_v4 will be active at genesis
let vote_state_v4_enabled = !features_to_deactivate.contains(&vote_state_v4::id());

match matches.value_of("hashes_per_tick").unwrap() {
"auto" => match cluster_type {
ClusterType::Development => {
Expand Down Expand Up @@ -796,6 +812,7 @@ fn main() -> Result<(), Box<dyn error::Error>> {
commission,
&rent,
bootstrap_stake_authorized_pubkey.as_ref(),
vote_state_v4_enabled,
)?;

if let Some(creation_time) = unix_timestamp_from_rfc3339_datetime(&matches, "creation_time") {
Expand Down Expand Up @@ -833,7 +850,13 @@ fn main() -> Result<(), Box<dyn error::Error>> {

if let Some(files) = matches.values_of("validator_accounts_file") {
for file in files {
load_validator_accounts(file, commission, &rent, &mut genesis_config)?;
load_validator_accounts(
file,
commission,
&rent,
&mut genesis_config,
vote_state_v4_enabled,
)?;
}
}

Expand Down Expand Up @@ -1325,6 +1348,7 @@ mod tests {
100,
&Rent::default(),
&mut GenesisConfig::default(),
true, // vote_state_v4_enabled
)
.is_err());

Expand Down Expand Up @@ -1387,8 +1411,14 @@ mod tests {
file.write_all(b"validator_accounts:\n").unwrap();
file.write_all(serialized.as_bytes()).unwrap();

load_validator_accounts(&filename, 100, &Rent::default(), &mut genesis_config)
.expect("Failed to load validator accounts");
load_validator_accounts(
&filename,
100,
&Rent::default(),
&mut genesis_config,
true, // vote_state_v4_enabled
)
.expect("Failed to load validator accounts");

remove_file(path).unwrap();

Expand Down
1 change: 1 addition & 0 deletions local-cluster/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ agave-unstable-api = []
dev-context-only-utils = ["solana-core/dev-context-only-utils"]

[dependencies]
agave-feature-set = { workspace = true }
agave-logger = { workspace = true }
agave-snapshots = { workspace = true }
crossbeam-channel = { workspace = true }
Expand Down
4 changes: 4 additions & 0 deletions local-cluster/src/local_cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use {
integration_tests::DEFAULT_NODE_STAKE,
validator_configs::*,
},
agave_feature_set::FeatureSet,
agave_snapshots::{paths::BANK_SNAPSHOTS_DIR, snapshot_config::SnapshotConfig},
itertools::izip,
log::*,
Expand Down Expand Up @@ -296,6 +297,8 @@ impl LocalCluster {
let leader_pubkey = leader_keypair.pubkey();
let leader_node = Node::new_localhost_with_pubkey(&leader_pubkey);

let feature_set = FeatureSet::all_enabled();

let GenesisConfigInfo {
mut genesis_config,
mint_keypair,
Expand All @@ -305,6 +308,7 @@ impl LocalCluster {
&keys_in_genesis,
stakes_in_genesis,
config.cluster_type,
&feature_set,
false,
);
genesis_config.accounts.extend(
Expand Down
34 changes: 15 additions & 19 deletions program-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
pub use tokio;
use {
agave_feature_set::{
increase_cpi_account_info_limit, raise_cpi_nesting_limit_to_8, FEATURE_NAMES,
increase_cpi_account_info_limit, raise_cpi_nesting_limit_to_8, FeatureSet, FEATURE_NAMES,
},
async_trait::async_trait,
base64::{prelude::BASE64_STANDARD, Engine},
Expand Down Expand Up @@ -814,6 +814,19 @@ impl ProgramTest {
let mint_keypair = Keypair::new();
let voting_keypair = Keypair::new();

// Remove features tagged to deactivate
let mut feature_set = FeatureSet::all_enabled();
for deactivate_feature_pk in &self.deactivate_feature_set {
if FEATURE_NAMES.contains_key(deactivate_feature_pk) {
feature_set.deactivate(deactivate_feature_pk);
} else {
warn!(
"Feature {deactivate_feature_pk:?} set for deactivation is not a known \
Feature public key"
);
}
}

let mut genesis_config = create_genesis_config_with_leader_ex(
1_000_000 * LAMPORTS_PER_SOL,
&mint_keypair.pubkey(),
Expand All @@ -826,27 +839,10 @@ impl ProgramTest {
fee_rate_governor,
rent.clone(),
ClusterType::Development,
&feature_set,
std::mem::take(&mut self.genesis_accounts),
);

// Remove features tagged to deactivate
for deactivate_feature_pk in &self.deactivate_feature_set {
if FEATURE_NAMES.contains_key(deactivate_feature_pk) {
match genesis_config.accounts.remove(deactivate_feature_pk) {
Some(_) => debug!("Feature for {deactivate_feature_pk:?} deactivated"),
None => warn!(
"Feature {deactivate_feature_pk:?} set for deactivation not found in \
genesis_config account list, ignored."
),
}
} else {
warn!(
"Feature {deactivate_feature_pk:?} set for deactivation is not a known \
Feature public key"
);
}
}

let target_tick_duration = Duration::from_micros(100);
genesis_config.poh_config = PohConfig::new_sleep(target_tick_duration);
debug!("Payer address: {}", mint_keypair.pubkey());
Expand Down
1 change: 1 addition & 0 deletions programs/sbf/tests/programs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1951,6 +1951,7 @@ fn get_stable_genesis_config() -> GenesisConfigInfo {
FeeRateGovernor::new(0, 0), // most tests can't handle transaction fees
Rent::free(), // most tests don't expect rent
ClusterType::Development,
&FeatureSet::all_enabled(),
vec![],
);
genesis_config.creation_time = Duration::ZERO.as_secs() as UnixTimestamp;
Expand Down
6 changes: 3 additions & 3 deletions programs/vote/src/vote_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ mod tests {
)
} else {
let balance = rent.minimum_balance(vote_state_size_of(vote_state_v4_enabled));
vote_state::create_account_with_authorized(
vote_state::create_v3_account_with_authorized(
&node_pubkey,
&vote_pubkey,
&vote_pubkey,
Expand Down Expand Up @@ -546,7 +546,7 @@ mod tests {
100,
)
} else {
vote_state::create_account_with_authorized(
vote_state::create_v3_account_with_authorized(
&node_pubkey,
authorized_voter,
authorized_withdrawer,
Expand Down Expand Up @@ -586,7 +586,7 @@ mod tests {
100,
)
} else {
vote_state::create_account_with_authorized(
vote_state::create_v3_account_with_authorized(
&node_pubkey,
&authorized_voter,
&authorized_withdrawer,
Expand Down
3 changes: 1 addition & 2 deletions programs/vote/src/vote_state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1189,8 +1189,7 @@ fn do_process_tower_sync(
)
}

#[cfg(test)]
pub fn create_account_with_authorized(
pub fn create_v3_account_with_authorized(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is what modules are for

node_pubkey: &Pubkey,
authorized_voter: &Pubkey,
authorized_withdrawer: &Pubkey,
Expand Down
Loading
Loading