Skip to content

Commit da28f06

Browse files
ksn6bw-solana
authored andcommitted
refactor: remove unused alpenglow-vote items (anza-xyz#315)
1 parent 81958d1 commit da28f06

16 files changed

Lines changed: 43 additions & 2147 deletions

File tree

perf/src/sigverify.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ mod tests {
637637
crate::{
638638
packet::{to_packet_batches, Packet, PacketBatch, PACKETS_PER_BATCH},
639639
sigverify::{self, PacketOffsets},
640-
test_tx::{new_test_alpenglow_vote_tx, new_test_vote_tx, test_multisig_tx, test_tx},
640+
test_tx::{new_test_vote_tx, test_multisig_tx, test_tx},
641641
},
642642
bincode::{deserialize, serialize},
643643
curve25519_dalek::{edwards::CompressedEdwardsY, scalar::Scalar},
@@ -651,7 +651,6 @@ mod tests {
651651
iter::repeat_with,
652652
sync::atomic::{AtomicU64, Ordering},
653653
},
654-
test_case::test_case,
655654
};
656655

657656
const SIG_OFFSET: usize = 1;
@@ -1377,9 +1376,8 @@ mod tests {
13771376
}
13781377
}
13791378

1380-
#[test_case(true; "alpenglow")]
1381-
#[test_case(false; "towerbft")]
1382-
fn test_is_simple_vote_transaction_with_offsets(is_alpenglow: bool) {
1379+
#[test]
1380+
fn test_is_simple_vote_transaction_with_offsets() {
13831381
solana_logger::setup();
13841382
let mut rng = rand::thread_rng();
13851383

@@ -1388,11 +1386,7 @@ mod tests {
13881386
let mut current_offset = 0usize;
13891387
let mut batch = PacketBatch::default();
13901388
batch.push(Packet::from_data(None, test_tx()).unwrap());
1391-
let tx = if is_alpenglow {
1392-
new_test_alpenglow_vote_tx(&mut rng)
1393-
} else {
1394-
new_test_vote_tx(&mut rng)
1395-
};
1389+
let tx = new_test_vote_tx(&mut rng);
13961390
batch.push(Packet::from_data(None, tx).unwrap());
13971391
batch.iter_mut().enumerate().for_each(|(index, packet)| {
13981392
let packet_offsets = do_get_packet_offsets(packet, current_offset).unwrap();

perf/src/test_tx.rs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use {
88
solana_signer::Signer,
99
solana_system_interface::instruction::SystemInstruction,
1010
solana_transaction::Transaction,
11-
solana_vote::{alpenglow::vote::Vote as AlpenglowVote, vote_transaction},
11+
solana_vote::vote_transaction,
1212
solana_vote_program::vote_state::TowerSync,
1313
};
1414

@@ -69,15 +69,3 @@ where
6969
switch_proof_hash,
7070
)
7171
}
72-
73-
pub fn new_test_alpenglow_vote_tx<R>(rng: &mut R) -> Transaction
74-
where
75-
R: CryptoRng + RngCore,
76-
{
77-
let slot = rng.gen();
78-
let vote = AlpenglowVote::new_notarization_vote(slot, Hash::new_unique(), Hash::new_unique());
79-
let keypair = Keypair::new();
80-
let vote_ix = vote.to_vote_instruction(keypair.pubkey(), keypair.pubkey());
81-
82-
Transaction::new_with_payer(&[vote_ix], Some(&keypair.pubkey()))
83-
}

runtime/src/inflation_rewards/mod.rs

Lines changed: 17 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -255,14 +255,10 @@ fn commission_split(commission: u8, on: u64) -> (u64, u64, bool) {
255255
#[cfg(test)]
256256
mod tests {
257257
use {
258-
self::points::null_tracer,
259-
super::*,
260-
solana_program::stake::state::Delegation,
261-
solana_pubkey::Pubkey,
262-
solana_sdk::native_token::sol_to_lamports,
263-
solana_vote::alpenglow::{accounting::EpochCredit, state::VoteState as AlpenglowVoteState},
264-
solana_vote_program::vote_state::VoteState,
265-
test_case::test_case,
258+
self::points::null_tracer, super::*, solana_program::stake::state::Delegation,
259+
solana_pubkey::Pubkey, solana_sdk::native_token::sol_to_lamports,
260+
solana_vote::alpenglow::state::VoteState as AlpenglowVoteState,
261+
solana_vote_program::vote_state::VoteState, test_case::test_case,
266262
};
267263

268264
fn new_stake(
@@ -277,21 +273,15 @@ mod tests {
277273
}
278274
}
279275

280-
#[test_case(true; "alpenglow")]
281-
#[test_case(false; "towerbft")]
282-
fn test_stake_state_redeem_rewards(is_alpenglow: bool) {
276+
#[test]
277+
fn test_stake_state_redeem_rewards() {
283278
let mut vote_state = VoteState::default();
284-
let mut alpenglow_vote_state = AlpenglowVoteState::default();
285279
// assume stake.stake() is right
286280
// bootstrap means fully-vested stake at epoch 0
287281
let stake_lamports = 1;
288282
let mut stake = new_stake(stake_lamports, &Pubkey::default(), 0, u64::MAX);
289283

290-
let vote_account = if is_alpenglow {
291-
VoteAccount::new_from_alpenglow_vote_state(&alpenglow_vote_state)
292-
} else {
293-
VoteAccount::new_from_vote_state(&vote_state)
294-
};
284+
let vote_account = { VoteAccount::new_from_vote_state(&vote_state) };
295285
// this one can't collect now, credits_observed == vote_state.credits()
296286
assert_eq!(
297287
None,
@@ -310,10 +300,7 @@ mod tests {
310300
);
311301

312302
// put 2 credits in at epoch 0
313-
let vote_account = if is_alpenglow {
314-
alpenglow_vote_state.set_epoch_credits(EpochCredit::new(0, 2, 0));
315-
VoteAccount::new_from_alpenglow_vote_state(&alpenglow_vote_state)
316-
} else {
303+
let vote_account = {
317304
vote_state.increment_credits(0, 1);
318305
vote_state.increment_credits(0, 1);
319306
VoteAccount::new_from_vote_state(&vote_state)
@@ -343,21 +330,15 @@ mod tests {
343330
assert_eq!(stake.credits_observed, 2);
344331
}
345332

346-
//TODO(wen): the alpenglow test cases don't work yet because we only keep credits for one Epoch
347-
#[test_case(false; "towerbft")]
348-
fn test_stake_state_calculate_rewards(is_alpenglow: bool) {
333+
#[test]
334+
fn test_stake_state_calculate_rewards() {
349335
let mut vote_state = VoteState::default();
350-
let mut alpenglow_vote_state = AlpenglowVoteState::default();
351336

352337
// assume stake.stake() is right
353338
// bootstrap means fully-vested stake at epoch 0
354339
let mut stake = new_stake(1, &Pubkey::default(), 0, u64::MAX);
355340

356-
let vote_account = if is_alpenglow {
357-
VoteAccount::new_from_alpenglow_vote_state(&alpenglow_vote_state)
358-
} else {
359-
VoteAccount::new_from_vote_state(&vote_state)
360-
};
341+
let vote_account = VoteAccount::new_from_vote_state(&vote_state);
361342

362343
// this one can't collect now, credits_observed == vote_state.credits()
363344
assert_eq!(
@@ -377,10 +358,7 @@ mod tests {
377358
);
378359

379360
// put 2 credits in at epoch 0
380-
let vote_account = if is_alpenglow {
381-
alpenglow_vote_state.set_epoch_credits(EpochCredit::new(0, 2, 0));
382-
VoteAccount::new_from_alpenglow_vote_state(&alpenglow_vote_state)
383-
} else {
361+
let vote_account = {
384362
vote_state.increment_credits(0, 1);
385363
vote_state.increment_credits(0, 1);
386364
VoteAccount::new_from_vote_state(&vote_state)
@@ -430,10 +408,7 @@ mod tests {
430408
);
431409

432410
// put 1 credit in epoch 1
433-
let vote_account = if is_alpenglow {
434-
alpenglow_vote_state.set_epoch_credits(EpochCredit::new(1, 1, 2));
435-
VoteAccount::new_from_alpenglow_vote_state(&alpenglow_vote_state)
436-
} else {
411+
let vote_account = {
437412
vote_state.increment_credits(1, 1);
438413
VoteAccount::new_from_vote_state(&vote_state)
439414
};
@@ -461,10 +436,7 @@ mod tests {
461436
);
462437

463438
// put 1 credit in epoch 2
464-
let vote_account = if is_alpenglow {
465-
alpenglow_vote_state.set_epoch_credits(EpochCredit::new(2, 1, 1));
466-
VoteAccount::new_from_alpenglow_vote_state(&alpenglow_vote_state)
467-
} else {
439+
let vote_account = {
468440
vote_state.increment_credits(2, 1);
469441
VoteAccount::new_from_vote_state(&vote_state)
470442
};
@@ -516,10 +488,7 @@ mod tests {
516488

517489
// same as above, but is a really small commission out of 32 bits,
518490
// verify that None comes back on small redemptions where no one gets paid
519-
let vote_account = if is_alpenglow {
520-
alpenglow_vote_state.set_commission(1);
521-
VoteAccount::new_from_alpenglow_vote_state(&alpenglow_vote_state)
522-
} else {
491+
let vote_account = {
523492
vote_state.commission = 1;
524493
VoteAccount::new_from_vote_state(&vote_state)
525494
};
@@ -538,10 +507,7 @@ mod tests {
538507
None,
539508
)
540509
);
541-
let vote_account = if is_alpenglow {
542-
alpenglow_vote_state.set_commission(99);
543-
VoteAccount::new_from_alpenglow_vote_state(&alpenglow_vote_state)
544-
} else {
510+
let vote_account = {
545511
vote_state.commission = 99;
546512
VoteAccount::new_from_vote_state(&vote_state)
547513
};
@@ -658,10 +624,7 @@ mod tests {
658624
);
659625

660626
// get rewards and credits observed when not the activation epoch
661-
let vote_account = if is_alpenglow {
662-
alpenglow_vote_state.set_commission(0);
663-
VoteAccount::new_from_alpenglow_vote_state(&alpenglow_vote_state)
664-
} else {
627+
let vote_account = {
665628
vote_state.commission = 0;
666629
VoteAccount::new_from_vote_state(&vote_state)
667630
};

runtime/src/inflation_rewards/points.rs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,7 @@ pub(crate) fn calculate_stake_points_and_credits(
206206
#[cfg(test)]
207207
mod tests {
208208
use {
209-
super::*,
210-
solana_sdk::native_token::sol_to_lamports,
211-
solana_vote::alpenglow::{accounting::EpochCredit, state::VoteState as AlpenglowVoteState},
209+
super::*, solana_sdk::native_token::sol_to_lamports,
212210
solana_vote_program::vote_state::VoteState,
213211
};
214212

@@ -227,7 +225,6 @@ mod tests {
227225
#[test]
228226
fn test_stake_state_calculate_points_with_typical_values() {
229227
let mut vote_state = VoteState::default();
230-
let mut alpenglow_vote_state = AlpenglowVoteState::default();
231228

232229
// bootstrap means fully-vested stake at epoch 0 with
233230
// 10_000_000 SOL is a big but not unreasonable stake
@@ -244,8 +241,6 @@ mod tests {
244241
for _ in 0..epoch_slots {
245242
vote_state.increment_credits(0, 1);
246243
}
247-
// We give one credit for notarization and one for finalization, so we have 2 credits each slot.
248-
alpenglow_vote_state.set_epoch_credits(EpochCredit::new(0, vote_state.credits() * 2, 0));
249244

250245
// no overflow on points
251246
assert_eq!(
@@ -258,15 +253,5 @@ mod tests {
258253
None
259254
)
260255
);
261-
assert_eq!(
262-
u128::from(stake.delegation.stake) * epoch_slots * 2,
263-
calculate_stake_points(
264-
&stake,
265-
&VoteAccount::new_from_alpenglow_vote_state(&alpenglow_vote_state),
266-
&StakeHistory::default(),
267-
null_tracer(),
268-
None
269-
)
270-
);
271256
}
272257
}

0 commit comments

Comments
 (0)