Skip to content

Commit

Permalink
fix one
Browse files Browse the repository at this point in the history
  • Loading branch information
2501babe committed Jan 15, 2025
1 parent f093e89 commit 0812607
Showing 1 changed file with 29 additions and 12 deletions.
41 changes: 29 additions & 12 deletions core/src/banking_stage/consume_worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,7 @@ mod tests {
solana_sdk::{
address_lookup_table::AddressLookupTableAccount,
clock::{Slot, MAX_PROCESSING_AGE},
feature_set,
genesis_config::GenesisConfig,
message::{
v0::{self, LoadedAddresses},
Expand All @@ -793,6 +794,7 @@ mod tests {
thread::JoinHandle,
},
tempfile::TempDir,
test_case::test_case,
};

// Helper struct to create tests that hold channels, files, etc.
Expand All @@ -812,7 +814,9 @@ mod tests {
consumed_receiver: Receiver<FinishedConsumeWork<RuntimeTransaction<SanitizedTransaction>>>,
}

fn setup_test_frame() -> (
fn setup_test_frame(
relax_intrabatch_account_locks: bool,
) -> (
TestFrame,
ConsumeWorker<RuntimeTransaction<SanitizedTransaction>>,
) {
Expand All @@ -821,7 +825,12 @@ mod tests {
mint_keypair,
..
} = create_slow_genesis_config(10_000);
let (bank, bank_forks) = Bank::new_no_wallclock_throttle_for_tests(&genesis_config);
let mut bank = Bank::new_for_tests(&genesis_config);
if !relax_intrabatch_account_locks {
bank.deactivate_feature(&feature_set::relax_intrabatch_account_locks::id());
}
bank.ns_per_slot = u128::MAX;
let (bank, bank_forks) = bank.wrap_with_bank_forks_for_tests();
// Warp to next epoch for MaxAge tests.
let bank = Arc::new(Bank::new_from_parent(
bank.clone(),
Expand Down Expand Up @@ -885,7 +894,7 @@ mod tests {

#[test]
fn test_worker_consume_no_bank() {
let (test_frame, worker) = setup_test_frame();
let (test_frame, worker) = setup_test_frame(true);
let TestFrame {
mint_keypair,
genesis_config,
Expand Down Expand Up @@ -929,7 +938,7 @@ mod tests {

#[test]
fn test_worker_consume_simple() {
let (test_frame, worker) = setup_test_frame();
let (test_frame, worker) = setup_test_frame(true);
let TestFrame {
mint_keypair,
genesis_config,
Expand Down Expand Up @@ -976,11 +985,10 @@ mod tests {
let _ = worker_thread.join().unwrap();
}

// HANA TODO this should be changed to not conflict with simd83
// its just testing the conflict behavior. slightly annoying to fix because the helper gives us Arc<Bank>
// #[test]
fn _test_worker_consume_self_conflicting() {
let (test_frame, worker) = setup_test_frame();
#[test_case(false; "old")]
#[test_case(true; "simd83")]
fn test_worker_consume_self_conflicting(relax_intrabatch_account_locks: bool) {
let (test_frame, worker) = setup_test_frame(relax_intrabatch_account_locks);
let TestFrame {
mint_keypair,
genesis_config,
Expand Down Expand Up @@ -1024,16 +1032,25 @@ mod tests {
assert_eq!(consumed.work.batch_id, bid);
assert_eq!(consumed.work.ids, vec![id1, id2]);
assert_eq!(consumed.work.max_ages, vec![max_age, max_age]);

// HANA here
assert_eq!(consumed.retryable_indexes, vec![1]); // id2 is retryable since lock conflict
// id2 succeeds with simd83, or is retryable due to lock conflict without simd83
assert_eq!(
consumed.retryable_indexes,
if relax_intrabatch_account_locks {
vec![]
} else {
vec![1]
}
);

drop(test_frame);
let _ = worker_thread.join().unwrap();
}

#[test]
fn test_worker_consume_multiple_messages() {
let (test_frame, worker) = setup_test_frame();
let (test_frame, worker) = setup_test_frame(true);
let TestFrame {
mint_keypair,
genesis_config,
Expand Down Expand Up @@ -1108,7 +1125,7 @@ mod tests {

#[test]
fn test_worker_ttl() {
let (test_frame, worker) = setup_test_frame();
let (test_frame, worker) = setup_test_frame(true);
let TestFrame {
mint_keypair,
genesis_config,
Expand Down

0 comments on commit 0812607

Please sign in to comment.