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
3 changes: 2 additions & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ check-cfg = [

[workspace.dependencies]
Inflector = "0.11.4"
alpenglow-vote = { git = "ssh://[email protected]/solana-program/alpenglow-vote.git", rev = "80318d3" }
alpenglow-vote = { git = "ssh://[email protected]/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" }
Expand Down
3 changes: 2 additions & 1 deletion programs/sbf/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 runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ edition = { workspace = true }

[dependencies]
ahash = { workspace = true }
alpenglow-vote = { workspace = true }
aquamarine = { workspace = true }
arrayref = { workspace = true }
base64 = { workspace = true }
Expand Down
69 changes: 47 additions & 22 deletions runtime/src/bank/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -2011,7 +2019,7 @@ type StakeDelegations = Vec<(Pubkey, StakeAccount<Delegation>)>;
type StakeDelegationsMap = DashMap<Pubkey, StakeDelegations>;

#[cfg(test)]
fn check_bank_update_vote_stake_rewards<F>(load_vote_and_stake_accounts: F)
fn check_bank_update_vote_stake_rewards<F>(load_vote_and_stake_accounts: F, is_alpenglow: bool)
where
F: Fn(&Bank) -> StakeDelegationsMap,
{
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);

Expand All @@ -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);
Expand Down Expand Up @@ -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() {
Expand Down
Loading