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
40 changes: 36 additions & 4 deletions local-cluster/src/local_cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use {
integration_tests::{ValidatorKeys, DEFAULT_NODE_STAKE},
validator_configs::*,
},
agave_feature_set::FeatureSet,
agave_feature_set::{bls_pubkey_management_in_vote_account, vote_state_v4, FeatureSet},
agave_snapshots::{paths::BANK_SNAPSHOTS_DIR, snapshot_config::SnapshotConfig},
agave_votor_messages::migration::GENESIS_CERTIFICATE_ACCOUNT,
itertools::izip,
Expand Down Expand Up @@ -55,7 +55,10 @@ use {
solana_transaction_error::TransportError,
solana_vote_program::{
vote_instruction,
vote_state::{self, VoteInit, VoteStateV4},
vote_state::{
self, create_bls_pubkey_and_proof_of_possession, VoteAuthorize, VoteInit, VoteStateV4,
VoterWithBLSArgs,
},
},
std::{
collections::HashMap,
Expand Down Expand Up @@ -1058,6 +1061,20 @@ impl LocalCluster {
.expect("client transfer should succeed");
}

fn is_feature_active(rpc_client: &RpcClient, feature_id: &Pubkey) -> bool {
rpc_client
.get_account_with_commitment(feature_id, CommitmentConfig::processed())
.ok()
.and_then(|r| r.value)
.and_then(|account| solana_feature_gate_interface::from_account(&account))
.is_some_and(|feature| feature.activated_at.is_some())
}

fn is_bls_pubkey_feature_enabled(rpc_client: &RpcClient) -> bool {
Self::is_feature_active(rpc_client, &bls_pubkey_management_in_vote_account::id())
&& Self::is_feature_active(rpc_client, &vote_state_v4::id())
}

fn setup_vote_and_stake_accounts(
client: &QuicTpuClient,
vote_account: &Keypair,
Expand All @@ -1079,8 +1096,8 @@ impl LocalCluster {
.unwrap_or(0)
== 0
{
// 1) Create vote account
let instructions = vote_instruction::create_account_with_config(
// 1) Create vote account — always use V1 InitializeAccount
let mut instructions = vote_instruction::create_account_with_config(
&from_account.pubkey(),
&vote_account_pubkey,
&VoteInit {
Expand All @@ -1095,6 +1112,21 @@ impl LocalCluster {
..vote_instruction::CreateVoteAccountConfig::default()
},
);

// If BLS feature is active, append an authorize instruction to set the BLS key
if Self::is_bls_pubkey_feature_enabled(client.rpc_client()) {
let (bls_pubkey, bls_proof_of_possession) =
create_bls_pubkey_and_proof_of_possession(&vote_account_pubkey);
instructions.push(vote_instruction::authorize(
&vote_account_pubkey,
&vote_account_pubkey,
&vote_account_pubkey,
VoteAuthorize::VoterWithBLS(VoterWithBLSArgs {
bls_pubkey,
bls_proof_of_possession,
}),
));
}
let message = Message::new(&instructions, Some(&from_account.pubkey()));
let mut transaction = Transaction::new(
&[from_account.as_ref(), vote_account],
Expand Down
12 changes: 9 additions & 3 deletions runtime/src/bank/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,9 @@ use {
solana_vote_program::{
vote_instruction,
vote_state::{
self, create_v4_account_with_authorized, BlockTimestamp, VoteAuthorize, VoteInit,
VoteStateV4, VoteStateVersions, MAX_LOCKOUT_HISTORY,
self, create_bls_pubkey_and_proof_of_possession, create_v4_account_with_authorized,
BlockTimestamp, VoteAuthorize, VoteInit, VoteStateV4, VoteStateVersions,
VoterWithBLSArgs, MAX_LOCKOUT_HISTORY,
},
},
spl_generic_token::token,
Expand Down Expand Up @@ -10085,12 +10086,17 @@ fn test_rent_state_changes_sysvars() {
let (bank, _bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config);

// Ensure transactions with sysvars succeed, even though sysvars appear RentPaying by balance
let (bls_pubkey, bls_proof_of_possession) =
create_bls_pubkey_and_proof_of_possession(&validator_vote_account_pubkey);
let tx = Transaction::new_signed_with_payer(
&[vote_instruction::authorize(
&validator_vote_account_pubkey,
&validator_voting_keypair.pubkey(),
&Pubkey::new_unique(),
VoteAuthorize::Voter,
VoteAuthorize::VoterWithBLS(VoterWithBLSArgs {
bls_pubkey,
bls_proof_of_possession,
}),
)],
Some(&mint_keypair.pubkey()),
&[&mint_keypair, &validator_voting_keypair],
Expand Down
7 changes: 0 additions & 7 deletions runtime/src/genesis_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,6 @@ fn do_activate_all_features<const IS_ALPENGLOW: bool>(genesis_config: &mut Genes
// Activate all features at genesis in development mode
for feature_id in FeatureSet::default().inactive() {
if (IS_ALPENGLOW || *feature_id != agave_feature_set::alpenglow::id())
// Skip bls_pubkey_management_in_vote_account feature activation until cli change is in place
&& *feature_id
!= agave_feature_set::bls_pubkey_management_in_vote_account::id()
// TODO: Remove me once SIMD-0464 is no longer hard-coded as `false` in
// `FeatureSet::runtime_features` and omitted from `FEATURE_NAMES` in
// agave-feature-set.
Expand Down Expand Up @@ -516,10 +513,6 @@ pub fn create_genesis_config_with_leader_ex(
if *feature_id == agave_feature_set::alpenglow::id() {
continue;
}
// Skip bls_pubkey_management_in_vote_account feature activation until cli change is in place
if *feature_id == agave_feature_set::bls_pubkey_management_in_vote_account::id() {
continue;
}
// TODO: Remove me once SIMD-0464 is no longer hard-coded as `false` in
// `FeatureSet::runtime_features` and omitted from `FEATURE_NAMES` in
// agave-feature-set.
Expand Down
Loading