From b848bff330fd44c4655af97a161e785901388ae9 Mon Sep 17 00:00:00 2001 From: Wen <113942165+wen-coding@users.noreply.github.com> Date: Thu, 13 Mar 2025 20:12:13 -0700 Subject: [PATCH 1/4] Allow Alpenglow accounts in StakesCache --- Cargo.lock | 1 + programs/sbf/Cargo.lock | 1 + runtime/Cargo.toml | 1 + runtime/src/bank/tests.rs | 69 +++++++++++----- runtime/src/stakes.rs | 164 +++++++++++++++++++++++++++++++------- svm/examples/Cargo.lock | 1 + 6 files changed, 185 insertions(+), 52 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 16fef553d8..b98dad0cb1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9407,6 +9407,7 @@ version = "2.3.0" dependencies = [ "agave-transaction-view", "ahash 0.8.11", + "alpenglow-vote", "aquamarine", "arrayref", "assert_matches", diff --git a/programs/sbf/Cargo.lock b/programs/sbf/Cargo.lock index 9cd687501f..74aee20a81 100644 --- a/programs/sbf/Cargo.lock +++ b/programs/sbf/Cargo.lock @@ -7441,6 +7441,7 @@ name = "solana-runtime" version = "2.3.0" dependencies = [ "ahash 0.8.11", + "alpenglow-vote", "aquamarine", "arrayref", "base64 0.22.1", diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index 18f45f4f10..f17f1d370d 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -11,6 +11,7 @@ edition = { workspace = true } [dependencies] ahash = { workspace = true } +alpenglow-vote = { workspace = true } aquamarine = { workspace = true } arrayref = { workspace = true } base64 = { workspace = true } diff --git a/runtime/src/bank/tests.rs b/runtime/src/bank/tests.rs index d004f70fe7..80dd057ee0 100644 --- a/runtime/src/bank/tests.rs +++ b/runtime/src/bank/tests.rs @@ -1906,12 +1906,20 @@ fn test_rent_eager_collect_rent_zero_lamport_deterministic() { assert_ne!(hash2_with_zero, Hash::default()); } -#[test] -fn test_bank_update_vote_stake_rewards() { +fn test_bank_update_vote_stake_rewards(is_alpenglow: bool) { let thread_pool = ThreadPoolBuilder::new().num_threads(1).build().unwrap(); - check_bank_update_vote_stake_rewards(|bank: &Bank| { - bank._load_vote_and_stake_accounts(&thread_pool, null_tracer()) - }); + check_bank_update_vote_stake_rewards( + |bank: &Bank| bank._load_vote_and_stake_accounts(&thread_pool, null_tracer()), + is_alpenglow, + ); +} + +#[test] +fn test_bank_update_vote_stake_rewards_tests() { + test_bank_update_vote_stake_rewards(false); + //TODO(wen): rewards to Alpenglow vote accounts don't work until epoch_stakes calculation + // is updated. + // test_bank_update_vote_stake_rewards(true); } impl Bank { @@ -2011,7 +2019,7 @@ type StakeDelegations = Vec<(Pubkey, StakeAccount)>; type StakeDelegationsMap = DashMap; #[cfg(test)] -fn check_bank_update_vote_stake_rewards(load_vote_and_stake_accounts: F) +fn check_bank_update_vote_stake_rewards(load_vote_and_stake_accounts: F, is_alpenglow: bool) where F: Fn(&Bank) -> StakeDelegationsMap, { @@ -2050,27 +2058,39 @@ where ); let ((vote_id, mut vote_account), (stake_id, stake_account)) = - crate::stakes::tests::create_staked_node_accounts(10_000); + crate::stakes::tests::create_staked_node_accounts(10_000, is_alpenglow); let starting_vote_and_stake_balance = 10_000 + 1; // set up accounts bank0.store_account_and_update_capitalization(&stake_id, &stake_account); // generate some rewards - let mut vote_state = Some(vote_state::from(&vote_account).unwrap()); - for i in 0..MAX_LOCKOUT_HISTORY + 42 { - if let Some(v) = vote_state.as_mut() { - vote_state::process_slot_vote_unchecked(v, i as u64) + if is_alpenglow { + let mut vote_state = + *alpenglow_vote::state::VoteState::deserialize(vote_account.data()).unwrap(); + for _ in 0..MAX_LOCKOUT_HISTORY + 42 { + let mut epoch_credits = *vote_state.epoch_credits(); + epoch_credits.set_credits(epoch_credits.credits() + 16); + vote_state.set_epoch_credits(epoch_credits); + vote_state.serialize_into(vote_account.data_as_mut_slice()); + bank0.store_account_and_update_capitalization(&vote_id, &vote_account); } - let versioned = VoteStateVersions::Current(Box::new(vote_state.take().unwrap())); - vote_state::to(&versioned, &mut vote_account).unwrap(); - bank0.store_account_and_update_capitalization(&vote_id, &vote_account); - match versioned { - VoteStateVersions::Current(v) => { - vote_state = Some(*v); + } else { + let mut vote_state = Some(vote_state::from(&vote_account).unwrap()); + for i in 0..MAX_LOCKOUT_HISTORY + 42 { + if let Some(v) = vote_state.as_mut() { + vote_state::process_slot_vote_unchecked(v, i as u64) } - _ => panic!("Has to be of type Current"), - }; + let versioned = VoteStateVersions::Current(Box::new(vote_state.take().unwrap())); + vote_state::to(&versioned, &mut vote_account).unwrap(); + bank0.store_account_and_update_capitalization(&vote_id, &vote_account); + match versioned { + VoteStateVersions::Current(v) => { + vote_state = Some(*v); + } + _ => panic!("Has to be of type Current"), + }; + } } bank0.store_account_and_update_capitalization(&vote_id, &vote_account); bank0.freeze(); @@ -4897,8 +4917,7 @@ fn test_add_duplicate_static_program() { ); } -#[test] -fn test_add_instruction_processor_for_existing_unrelated_accounts() { +fn test_add_instruction_processor_for_existing_unrelated_accounts(is_alpenglow: bool) { for pass in 0..5 { let mut bank = create_simple_test_bank(500); @@ -4919,7 +4938,7 @@ fn test_add_instruction_processor_for_existing_unrelated_accounts() { } let ((vote_id, vote_account), (stake_id, stake_account)) = - crate::stakes::tests::create_staked_node_accounts(1_0000); + crate::stakes::tests::create_staked_node_accounts(1_0000, is_alpenglow); bank.capitalization .fetch_add(vote_account.lamports() + stake_account.lamports(), Relaxed); bank.store_account(&vote_id, &vote_account); @@ -4992,6 +5011,12 @@ fn test_add_instruction_processor_for_existing_unrelated_accounts() { } } +#[test] +fn test_add_instruction_processor_for_existing_unrelated_accounts_tests() { + test_add_instruction_processor_for_existing_unrelated_accounts(false); + test_add_instruction_processor_for_existing_unrelated_accounts(true); +} + #[allow(deprecated)] #[test] fn test_recent_blockhashes_sysvar() { diff --git a/runtime/src/stakes.rs b/runtime/src/stakes.rs index 3755b7e99d..783ba78a67 100644 --- a/runtime/src/stakes.rs +++ b/runtime/src/stakes.rs @@ -79,7 +79,7 @@ impl StakesCache { // Zero lamport accounts are not stored in accounts-db // and so should be removed from cache as well. if account.lamports() == 0 { - if solana_vote_program::check_id(owner) { + if solana_vote_program::check_id(owner) || alpenglow_vote::check_id(owner) { let _old_vote_account = { let mut stakes = self.0.write().unwrap(); stakes.remove_vote_account(pubkey) @@ -120,6 +120,35 @@ impl StakesCache { stakes.remove_vote_account(pubkey) }; }; + } else if alpenglow_vote::check_id(owner) { + match VoteAccount::try_from(account.to_account_shared_data()) { + Ok(vote_account) => { + if vote_account.alpenglow_vote_state().unwrap().version() > 0 { + // drop the old account after releasing the lock + let _old_vote_account = { + let mut stakes = self.0.write().unwrap(); + stakes.upsert_vote_account( + pubkey, + vote_account, + new_rate_activation_epoch, + ) + }; + } else { + // drop the old account after releasing the lock + let _old_vote_account = { + let mut stakes = self.0.write().unwrap(); + stakes.remove_vote_account(pubkey) + }; + } + } + Err(_) => { + // drop the old account after releasing the lock + let _old_vote_account = { + let mut stakes = self.0.write().unwrap(); + stakes.remove_vote_account(pubkey) + }; + } + } } else if solana_stake_program::check_id(owner) { match StakeAccount::try_from(account.to_account_shared_data()) { Ok(stake_account) => { @@ -230,7 +259,8 @@ impl Stakes { let voter_pubkey = &delegation.voter_pubkey; if stakes.vote_accounts.get(voter_pubkey).is_none() { if let Some(account) = get_account(voter_pubkey) { - if VoteStateVersions::is_correct_size_and_initialized(account.data()) + if (alpenglow_vote::check_id(account.owner()) + || VoteStateVersions::is_correct_size_and_initialized(account.data())) && VoteAccount::try_from(account.clone()).is_ok() { error!("vote account not cached: {voter_pubkey}, {account:?}"); @@ -603,6 +633,7 @@ fn refresh_vote_accounts( pub(crate) mod tests { use { super::*, + alpenglow_vote::state::VoteState as AlpenglowVoteState, rayon::ThreadPoolBuilder, solana_sdk::{account::WritableAccount, pubkey::Pubkey, rent::Rent, stake}, solana_stake_program::stake_state, @@ -612,10 +643,20 @@ pub(crate) mod tests { // set up some dummies for a staked node (( vote ) ( stake )) pub(crate) fn create_staked_node_accounts( stake: u64, + is_alpenglow: bool, ) -> ((Pubkey, AccountSharedData), (Pubkey, AccountSharedData)) { let vote_pubkey = solana_pubkey::new_rand(); - let vote_account = - vote_state::create_account(&vote_pubkey, &solana_pubkey::new_rand(), 0, 1); + let vote_account = if is_alpenglow { + AlpenglowVoteState::create_account_with_authorized( + &vote_pubkey, + &vote_pubkey, + &vote_pubkey, + 0, + 1, + ) + } else { + vote_state::create_account(&vote_pubkey, &solana_pubkey::new_rand(), 0, 1) + }; let stake_pubkey = solana_pubkey::new_rand(); ( (vote_pubkey, vote_account), @@ -644,10 +685,20 @@ pub(crate) mod tests { fn create_warming_staked_node_accounts( stake: u64, epoch: Epoch, + is_alpenglow: bool, ) -> ((Pubkey, AccountSharedData), (Pubkey, AccountSharedData)) { let vote_pubkey = solana_pubkey::new_rand(); - let vote_account = - vote_state::create_account(&vote_pubkey, &solana_pubkey::new_rand(), 0, 1); + let vote_account = if is_alpenglow { + AlpenglowVoteState::create_account_with_authorized( + &vote_pubkey, + &vote_pubkey, + &vote_pubkey, + 0, + 1, + ) + } else { + vote_state::create_account(&vote_pubkey, &solana_pubkey::new_rand(), 0, 1) + }; ( (vote_pubkey, vote_account), create_warming_stake_account(stake, epoch, &vote_pubkey), @@ -674,8 +725,7 @@ pub(crate) mod tests { ) } - #[test] - fn test_stakes_basic() { + fn test_stakes_basic(is_alpenglow: bool) { for i in 0..4 { let stakes_cache = StakesCache::new(Stakes { epoch: i, @@ -683,7 +733,7 @@ pub(crate) mod tests { }); let ((vote_pubkey, vote_account), (stake_pubkey, mut stake_account)) = - create_staked_node_accounts(10); + create_staked_node_accounts(10, is_alpenglow); stakes_cache.check_and_store(&vote_pubkey, &vote_account, None); stakes_cache.check_and_store(&stake_pubkey, &stake_account, None); @@ -737,38 +787,54 @@ pub(crate) mod tests { } #[test] - fn test_stakes_highest() { + fn test_stakes_basics() { + test_stakes_basic(false); + test_stakes_basic(true); + } + + fn test_stakes_highest(is_alpenglow: bool) { let stakes_cache = StakesCache::default(); assert_eq!(stakes_cache.stakes().highest_staked_node(), None); let ((vote_pubkey, vote_account), (stake_pubkey, stake_account)) = - create_staked_node_accounts(10); + create_staked_node_accounts(10, is_alpenglow); stakes_cache.check_and_store(&vote_pubkey, &vote_account, None); stakes_cache.check_and_store(&stake_pubkey, &stake_account, None); let ((vote11_pubkey, vote11_account), (stake11_pubkey, stake11_account)) = - create_staked_node_accounts(20); + create_staked_node_accounts(20, is_alpenglow); stakes_cache.check_and_store(&vote11_pubkey, &vote11_account, None); stakes_cache.check_and_store(&stake11_pubkey, &stake11_account, None); - let vote11_node_pubkey = vote_state::from(&vote11_account).unwrap().node_pubkey; + let vote11_node_pubkey = if is_alpenglow { + *AlpenglowVoteState::deserialize(vote11_account.data()) + .unwrap() + .node_pubkey() + } else { + vote_state::from(&vote11_account).unwrap().node_pubkey + }; let highest_staked_node = stakes_cache.stakes().highest_staked_node().copied(); assert_eq!(highest_staked_node, Some(vote11_node_pubkey)); } #[test] - fn test_stakes_vote_account_disappear_reappear() { + fn test_stakes_highests() { + test_stakes_highest(false); + test_stakes_highest(true); + } + + fn test_stakes_vote_account_disappear_reappear(is_alpenglow: bool) { let stakes_cache = StakesCache::new(Stakes { epoch: 4, ..Stakes::default() }); let ((vote_pubkey, mut vote_account), (stake_pubkey, stake_account)) = - create_staked_node_accounts(10); + create_staked_node_accounts(10, is_alpenglow); stakes_cache.check_and_store(&vote_pubkey, &vote_account, None); stakes_cache.check_and_store(&stake_pubkey, &stake_account, None); @@ -815,9 +881,15 @@ pub(crate) mod tests { } // Vote account uninitialized - let default_vote_state = VoteState::default(); - let versioned = VoteStateVersions::new_current(default_vote_state); - vote_state::to(&versioned, &mut vote_account).unwrap(); + if is_alpenglow { + vote_account.set_data(cache_data.clone()); + let default_vote_state = AlpenglowVoteState::default(); + default_vote_state.serialize_into(vote_account.data_as_mut_slice()); + } else { + let default_vote_state = VoteState::default(); + let versioned = VoteStateVersions::new_current(default_vote_state); + vote_state::to(&versioned, &mut vote_account).unwrap(); + } stakes_cache.check_and_store(&vote_pubkey, &vote_account, None); { @@ -839,17 +911,22 @@ pub(crate) mod tests { } #[test] - fn test_stakes_change_delegate() { + fn test_stakes_vote_account_disappear_reappears() { + test_stakes_vote_account_disappear_reappear(false); + test_stakes_vote_account_disappear_reappear(true); + } + + fn test_stakes_change_delegate(is_alpenglow: bool) { let stakes_cache = StakesCache::new(Stakes { epoch: 4, ..Stakes::default() }); let ((vote_pubkey, vote_account), (stake_pubkey, stake_account)) = - create_staked_node_accounts(10); + create_staked_node_accounts(10, is_alpenglow); let ((vote_pubkey2, vote_account2), (_stake_pubkey2, stake_account2)) = - create_staked_node_accounts(10); + create_staked_node_accounts(10, is_alpenglow); stakes_cache.check_and_store(&vote_pubkey, &vote_account, None); stakes_cache.check_and_store(&vote_pubkey2, &vote_account2, None); @@ -886,15 +963,21 @@ pub(crate) mod tests { ); } } + #[test] - fn test_stakes_multiple_stakers() { + fn test_stakes_change_delegates() { + test_stakes_change_delegate(false); + test_stakes_change_delegate(true); + } + + fn test_stakes_multiple_stakers(is_alpenglow: bool) { let stakes_cache = StakesCache::new(Stakes { epoch: 4, ..Stakes::default() }); let ((vote_pubkey, vote_account), (stake_pubkey, stake_account)) = - create_staked_node_accounts(10); + create_staked_node_accounts(10, is_alpenglow); let stake_pubkey2 = solana_pubkey::new_rand(); let stake_account2 = create_stake_account(10, &vote_pubkey, &stake_pubkey2); @@ -914,11 +997,16 @@ pub(crate) mod tests { } #[test] - fn test_activate_epoch() { + fn test_stakes_multiple_stakers_tests() { + test_stakes_multiple_stakers(false); + test_stakes_multiple_stakers(true); + } + + fn test_activate_epoch(is_alpenglow: bool) { let stakes_cache = StakesCache::default(); let ((vote_pubkey, vote_account), (stake_pubkey, stake_account)) = - create_staked_node_accounts(10); + create_staked_node_accounts(10, is_alpenglow); stakes_cache.check_and_store(&vote_pubkey, &vote_account, None); stakes_cache.check_and_store(&stake_pubkey, &stake_account, None); @@ -945,14 +1033,19 @@ pub(crate) mod tests { } #[test] - fn test_stakes_not_delegate() { + fn test_activate_epochs() { + test_activate_epoch(false); + test_activate_epoch(true); + } + + fn test_stakes_not_delegate(is_alpenglow: bool) { let stakes_cache = StakesCache::new(Stakes { epoch: 4, ..Stakes::default() }); let ((vote_pubkey, vote_account), (stake_pubkey, stake_account)) = - create_staked_node_accounts(10); + create_staked_node_accounts(10, is_alpenglow); stakes_cache.check_and_store(&vote_pubkey, &vote_account, None); stakes_cache.check_and_store(&stake_pubkey, &stake_account, None); @@ -978,14 +1071,19 @@ pub(crate) mod tests { } } + #[test] + fn test_stakes_not_delegates() { + test_stakes_not_delegate(false); + test_stakes_not_delegate(true); + } + #[test] fn test_vote_balance_and_staked_empty() { let stakes = Stakes::::default(); assert_eq!(stakes.vote_balance_and_staked(), 0); } - #[test] - fn test_vote_balance_and_staked_normal() { + fn test_vote_balance_and_staked_normal(is_alpenglow: bool) { let stakes_cache = StakesCache::default(); #[allow(non_local_definitions)] impl Stakes { @@ -1006,7 +1104,7 @@ pub(crate) mod tests { let genesis_epoch = 0; let ((vote_pubkey, vote_account), (stake_pubkey, stake_account)) = - create_warming_staked_node_accounts(10, genesis_epoch); + create_warming_staked_node_accounts(10, genesis_epoch, is_alpenglow); stakes_cache.check_and_store(&vote_pubkey, &vote_account, None); stakes_cache.check_and_store(&stake_pubkey, &stake_account, None); @@ -1029,4 +1127,10 @@ pub(crate) mod tests { ); } } + + #[test] + fn test_vote_balance_and_staked_normal_tests() { + test_vote_balance_and_staked_normal(false); + test_vote_balance_and_staked_normal(true); + } } diff --git a/svm/examples/Cargo.lock b/svm/examples/Cargo.lock index 21b3583596..9f5005066d 100644 --- a/svm/examples/Cargo.lock +++ b/svm/examples/Cargo.lock @@ -7265,6 +7265,7 @@ name = "solana-runtime" version = "2.3.0" dependencies = [ "ahash 0.8.11", + "alpenglow-vote", "aquamarine", "arrayref", "base64 0.22.1", From d5252e66a07b0b01b2d58229b65a7511b13c445d Mon Sep 17 00:00:00 2001 From: Wen <113942165+wen-coding@users.noreply.github.com> Date: Mon, 17 Mar 2025 09:04:45 -0700 Subject: [PATCH 2/4] Use is_initialized instead of checking version directly. --- Cargo.lock | 2 +- Cargo.toml | 2 +- programs/sbf/Cargo.lock | 2 +- runtime/src/stakes.rs | 23 ++++++++++++++++++----- svm/examples/Cargo.lock | 2 +- 5 files changed, 22 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b98dad0cb1..2a3ff94068 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -472,7 +472,7 @@ checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" [[package]] name = "alpenglow-vote" version = "0.1.0" -source = "git+ssh://git@github.com/solana-program/alpenglow-vote.git?rev=3c4c514#3c4c514d726891011c60d7576889c56384fd82f7" +source = "git+ssh://git@github.com/solana-program/alpenglow-vote.git?rev=83bad2f#83bad2f6bc42ca0e1141a0e3b922e824e377bb59" dependencies = [ "bincode", "bitflags 2.9.0", diff --git a/Cargo.toml b/Cargo.toml index 7dd04e0127..36de77fa1e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -171,7 +171,7 @@ check-cfg = [ [workspace.dependencies] Inflector = "0.11.4" -alpenglow-vote = { git = "ssh://git@github.com/solana-program/alpenglow-vote.git", rev = "3c4c514" } +alpenglow-vote = { git = "ssh://git@github.com/solana-program/alpenglow-vote.git", rev = "83bad2f" } # alpenglow-vote = { path = "../alpenglow-vote/program" } axum = "0.7.9" agave-banking-stage-ingress-types = { path = "banking-stage-ingress-types", version = "=2.3.0" } diff --git a/programs/sbf/Cargo.lock b/programs/sbf/Cargo.lock index 74aee20a81..c77e95eb14 100644 --- a/programs/sbf/Cargo.lock +++ b/programs/sbf/Cargo.lock @@ -229,7 +229,7 @@ checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" [[package]] name = "alpenglow-vote" version = "0.1.0" -source = "git+ssh://git@github.com/solana-program/alpenglow-vote.git?rev=3c4c514#3c4c514d726891011c60d7576889c56384fd82f7" +source = "git+ssh://git@github.com/solana-program/alpenglow-vote.git?rev=83bad2f#83bad2f6bc42ca0e1141a0e3b922e824e377bb59" dependencies = [ "bincode", "bitflags 2.9.0", diff --git a/runtime/src/stakes.rs b/runtime/src/stakes.rs index 783ba78a67..6762662263 100644 --- a/runtime/src/stakes.rs +++ b/runtime/src/stakes.rs @@ -123,7 +123,11 @@ impl StakesCache { } else if alpenglow_vote::check_id(owner) { match VoteAccount::try_from(account.to_account_shared_data()) { Ok(vote_account) => { - if vote_account.alpenglow_vote_state().unwrap().version() > 0 { + if vote_account + .alpenglow_vote_state() + .unwrap() + .is_initialized() + { // drop the old account after releasing the lock let _old_vote_account = { let mut stakes = self.0.write().unwrap(); @@ -259,10 +263,19 @@ impl Stakes { let voter_pubkey = &delegation.voter_pubkey; if stakes.vote_accounts.get(voter_pubkey).is_none() { if let Some(account) = get_account(voter_pubkey) { - if (alpenglow_vote::check_id(account.owner()) - || VoteStateVersions::is_correct_size_and_initialized(account.data())) - && VoteAccount::try_from(account.clone()).is_ok() - { + let is_valid_account = if alpenglow_vote::check_id(account.owner()) { + match VoteAccount::try_from(account.clone()) { + Ok(vote_account) => vote_account + .alpenglow_vote_state() + .unwrap() + .is_initialized(), + Err(_) => false, + } + } else { + VoteStateVersions::is_correct_size_and_initialized(account.data()) + && VoteAccount::try_from(account.clone()).is_ok() + }; + if is_valid_account { error!("vote account not cached: {voter_pubkey}, {account:?}"); return Err(Error::VoteAccountNotCached(*voter_pubkey)); } diff --git a/svm/examples/Cargo.lock b/svm/examples/Cargo.lock index 9f5005066d..4d7fff9df2 100644 --- a/svm/examples/Cargo.lock +++ b/svm/examples/Cargo.lock @@ -154,7 +154,7 @@ checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" [[package]] name = "alpenglow-vote" version = "0.1.0" -source = "git+ssh://git@github.com/solana-program/alpenglow-vote.git?rev=3c4c514#3c4c514d726891011c60d7576889c56384fd82f7" +source = "git+ssh://git@github.com/solana-program/alpenglow-vote.git?rev=83bad2f#83bad2f6bc42ca0e1141a0e3b922e824e377bb59" dependencies = [ "bincode", "bitflags 2.9.0", From 07e19facf6c7251a2396291e97ba12d527d34f92 Mon Sep 17 00:00:00 2001 From: Wen <113942165+wen-coding@users.noreply.github.com> Date: Mon, 17 Mar 2025 09:29:49 -0700 Subject: [PATCH 3/4] Use test_case instead of arbitrary names --- runtime/src/stakes.rs | 57 ++++++++++++------------------------------- 1 file changed, 15 insertions(+), 42 deletions(-) diff --git a/runtime/src/stakes.rs b/runtime/src/stakes.rs index 6762662263..5b48081e80 100644 --- a/runtime/src/stakes.rs +++ b/runtime/src/stakes.rs @@ -651,6 +651,7 @@ pub(crate) mod tests { solana_sdk::{account::WritableAccount, pubkey::Pubkey, rent::Rent, stake}, solana_stake_program::stake_state, solana_vote_program::vote_state::{self, VoteState, VoteStateVersions}, + test_case::test_case, }; // set up some dummies for a staked node (( vote ) ( stake )) @@ -738,6 +739,8 @@ pub(crate) mod tests { ) } + #[test_case(true; "alpenglow")] + #[test_case(false; "towerbft")] fn test_stakes_basic(is_alpenglow: bool) { for i in 0..4 { let stakes_cache = StakesCache::new(Stakes { @@ -799,12 +802,8 @@ pub(crate) mod tests { } } - #[test] - fn test_stakes_basics() { - test_stakes_basic(false); - test_stakes_basic(true); - } - + #[test_case(true; "alpenglow")] + #[test_case(false; "towerbft")] fn test_stakes_highest(is_alpenglow: bool) { let stakes_cache = StakesCache::default(); @@ -834,12 +833,8 @@ pub(crate) mod tests { assert_eq!(highest_staked_node, Some(vote11_node_pubkey)); } - #[test] - fn test_stakes_highests() { - test_stakes_highest(false); - test_stakes_highest(true); - } - + #[test_case(true; "alpenglow")] + #[test_case(false; "towerbft")] fn test_stakes_vote_account_disappear_reappear(is_alpenglow: bool) { let stakes_cache = StakesCache::new(Stakes { epoch: 4, @@ -923,12 +918,8 @@ pub(crate) mod tests { } } - #[test] - fn test_stakes_vote_account_disappear_reappears() { - test_stakes_vote_account_disappear_reappear(false); - test_stakes_vote_account_disappear_reappear(true); - } - + #[test_case(true; "alpenglow")] + #[test_case(false; "towerbft")] fn test_stakes_change_delegate(is_alpenglow: bool) { let stakes_cache = StakesCache::new(Stakes { epoch: 4, @@ -977,12 +968,8 @@ pub(crate) mod tests { } } - #[test] - fn test_stakes_change_delegates() { - test_stakes_change_delegate(false); - test_stakes_change_delegate(true); - } - + #[test_case(true; "alpenglow")] + #[test_case(false; "towerbft")] fn test_stakes_multiple_stakers(is_alpenglow: bool) { let stakes_cache = StakesCache::new(Stakes { epoch: 4, @@ -1009,12 +996,8 @@ pub(crate) mod tests { } } - #[test] - fn test_stakes_multiple_stakers_tests() { - test_stakes_multiple_stakers(false); - test_stakes_multiple_stakers(true); - } - + #[test_case(true; "alpenglow")] + #[test_case(false; "towerbft")] fn test_activate_epoch(is_alpenglow: bool) { let stakes_cache = StakesCache::default(); @@ -1045,12 +1028,8 @@ pub(crate) mod tests { } } - #[test] - fn test_activate_epochs() { - test_activate_epoch(false); - test_activate_epoch(true); - } - + #[test_case(true; "alpenglow")] + #[test_case(false; "towerbft")] fn test_stakes_not_delegate(is_alpenglow: bool) { let stakes_cache = StakesCache::new(Stakes { epoch: 4, @@ -1084,12 +1063,6 @@ pub(crate) mod tests { } } - #[test] - fn test_stakes_not_delegates() { - test_stakes_not_delegate(false); - test_stakes_not_delegate(true); - } - #[test] fn test_vote_balance_and_staked_empty() { let stakes = Stakes::::default(); From 4f4529e82b606b5254f4decbf13319f200307934 Mon Sep 17 00:00:00 2001 From: Wen <113942165+wen-coding@users.noreply.github.com> Date: Mon, 17 Mar 2025 17:56:31 -0700 Subject: [PATCH 4/4] Update alpenglow-vote version --- Cargo.lock | 2 +- Cargo.toml | 2 +- programs/sbf/Cargo.lock | 2 +- svm/examples/Cargo.lock | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2a3ff94068..4c15060c33 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -472,7 +472,7 @@ checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" [[package]] name = "alpenglow-vote" version = "0.1.0" -source = "git+ssh://git@github.com/solana-program/alpenglow-vote.git?rev=83bad2f#83bad2f6bc42ca0e1141a0e3b922e824e377bb59" +source = "git+ssh://git@github.com/solana-program/alpenglow-vote.git?rev=b3d25ff#b3d25ff8775a3671d88ccaf080e70773b6897231" dependencies = [ "bincode", "bitflags 2.9.0", diff --git a/Cargo.toml b/Cargo.toml index 36de77fa1e..4fe8e0266c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -171,7 +171,7 @@ check-cfg = [ [workspace.dependencies] Inflector = "0.11.4" -alpenglow-vote = { git = "ssh://git@github.com/solana-program/alpenglow-vote.git", rev = "83bad2f" } +alpenglow-vote = { git = "ssh://git@github.com/solana-program/alpenglow-vote.git", rev = "b3d25ff" } # alpenglow-vote = { path = "../alpenglow-vote/program" } axum = "0.7.9" agave-banking-stage-ingress-types = { path = "banking-stage-ingress-types", version = "=2.3.0" } diff --git a/programs/sbf/Cargo.lock b/programs/sbf/Cargo.lock index c77e95eb14..a3a7cef0b1 100644 --- a/programs/sbf/Cargo.lock +++ b/programs/sbf/Cargo.lock @@ -229,7 +229,7 @@ checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" [[package]] name = "alpenglow-vote" version = "0.1.0" -source = "git+ssh://git@github.com/solana-program/alpenglow-vote.git?rev=83bad2f#83bad2f6bc42ca0e1141a0e3b922e824e377bb59" +source = "git+ssh://git@github.com/solana-program/alpenglow-vote.git?rev=b3d25ff#b3d25ff8775a3671d88ccaf080e70773b6897231" dependencies = [ "bincode", "bitflags 2.9.0", diff --git a/svm/examples/Cargo.lock b/svm/examples/Cargo.lock index 4d7fff9df2..a8600a728a 100644 --- a/svm/examples/Cargo.lock +++ b/svm/examples/Cargo.lock @@ -154,7 +154,7 @@ checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" [[package]] name = "alpenglow-vote" version = "0.1.0" -source = "git+ssh://git@github.com/solana-program/alpenglow-vote.git?rev=83bad2f#83bad2f6bc42ca0e1141a0e3b922e824e377bb59" +source = "git+ssh://git@github.com/solana-program/alpenglow-vote.git?rev=b3d25ff#b3d25ff8775a3671d88ccaf080e70773b6897231" dependencies = [ "bincode", "bitflags 2.9.0",