diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index e89d4678166756..18aafe957d01ef 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -1004,12 +1004,8 @@ impl Bank { transaction_account_lock_limit: None, }; - bank.transaction_processor = TransactionBatchProcessor::new( - bank.slot, - bank.epoch, - bank.epoch_schedule.clone(), - HashSet::default(), - ); + bank.transaction_processor = + TransactionBatchProcessor::new(bank.slot, bank.epoch, HashSet::default()); let accounts_data_size_initial = bank.get_total_accounts_stats().unwrap().data_len as u64; bank.accounts_data_size_initial = accounts_data_size_initial; @@ -1281,12 +1277,17 @@ impl Bank { } }); + let (_epoch, slot_index) = new.epoch_schedule.get_epoch_and_slot_index(new.slot); + let slots_in_epoch = new.epoch_schedule.get_slots_in_epoch(new.epoch); + let (_, cache_preparation_time_us) = measure_us!(new .transaction_processor .prepare_program_cache_for_upcoming_feature_set( &new, &new.compute_active_feature_set(true).0, &new.compute_budget.unwrap_or_default(), + slot_index, + slots_in_epoch, )); // Update sysvars before processing transactions @@ -1639,12 +1640,8 @@ impl Bank { transaction_account_lock_limit: runtime_config.transaction_account_lock_limit, }; - bank.transaction_processor = TransactionBatchProcessor::new( - bank.slot, - bank.epoch, - bank.epoch_schedule.clone(), - HashSet::default(), - ); + bank.transaction_processor = + TransactionBatchProcessor::new(bank.slot, bank.epoch, HashSet::default()); let thread_pool = ThreadPoolBuilder::new() .thread_name(|i| format!("solBnkNewFlds{i:02}")) @@ -2969,7 +2966,6 @@ impl Bank { self.slots_per_year = genesis_config.slots_per_year(); self.epoch_schedule = genesis_config.epoch_schedule.clone(); - self.transaction_processor.epoch_schedule = genesis_config.epoch_schedule.clone(); self.inflation = Arc::new(RwLock::new(genesis_config.inflation)); @@ -7163,14 +7159,7 @@ impl Bank { let environments = self .transaction_processor .get_environments_for_epoch(effective_epoch)?; - load_program_with_pubkey( - self, - &environments, - pubkey, - self.slot(), - self.epoch_schedule(), - reload, - ) + load_program_with_pubkey(self, &environments, pubkey, self.slot(), reload) } } diff --git a/runtime/src/bank/tests.rs b/runtime/src/bank/tests.rs index 46d36d38310049..836705e37b1bb2 100644 --- a/runtime/src/bank/tests.rs +++ b/runtime/src/bank/tests.rs @@ -9116,10 +9116,7 @@ fn test_epoch_schedule_from_genesis_config() { Arc::default(), )); - assert_eq!( - &bank.transaction_processor.epoch_schedule, - &genesis_config.epoch_schedule - ); + assert_eq!(bank.epoch_schedule(), &genesis_config.epoch_schedule); } fn check_stake_vote_account_validity(check_owner_change: bool, load_vote_and_stake_accounts: F) diff --git a/svm/src/program_loader.rs b/svm/src/program_loader.rs index 6060e8bb3db453..b6d7b7d9c28186 100644 --- a/svm/src/program_loader.rs +++ b/svm/src/program_loader.rs @@ -13,7 +13,6 @@ use { bpf_loader, bpf_loader_deprecated, bpf_loader_upgradeable::UpgradeableLoaderState, clock::Slot, - epoch_schedule::EpochSchedule, instruction::InstructionError, loader_v4::{self, LoaderV4State, LoaderV4Status}, pubkey::Pubkey, @@ -126,7 +125,6 @@ pub fn load_program_with_pubkey( environments: &ProgramRuntimeEnvironments, pubkey: &Pubkey, slot: Slot, - _epoch_schedule: &EpochSchedule, reload: bool, ) -> Option> { let mut load_program_metrics = LoadProgramMetrics { @@ -494,7 +492,6 @@ mod tests { &batch_processor.get_environments_for_epoch(50).unwrap(), &key, 500, - &batch_processor.epoch_schedule, false, ); assert!(result.is_none()); @@ -517,7 +514,6 @@ mod tests { &batch_processor.get_environments_for_epoch(20).unwrap(), &key, 0, // Slot 0 - &batch_processor.epoch_schedule, false, ); @@ -552,7 +548,6 @@ mod tests { &batch_processor.get_environments_for_epoch(20).unwrap(), &key, 200, - &batch_processor.epoch_schedule, false, ); let loaded_program = ProgramCacheEntry::new_tombstone( @@ -580,7 +575,6 @@ mod tests { &batch_processor.get_environments_for_epoch(20).unwrap(), &key, 200, - &batch_processor.epoch_schedule, false, ); @@ -634,7 +628,6 @@ mod tests { &batch_processor.get_environments_for_epoch(0).unwrap(), &key1, 0, - &batch_processor.epoch_schedule, false, ); let loaded_program = ProgramCacheEntry::new_tombstone( @@ -672,7 +665,6 @@ mod tests { &batch_processor.get_environments_for_epoch(20).unwrap(), &key1, 200, - &batch_processor.epoch_schedule, false, ); @@ -722,7 +714,6 @@ mod tests { &batch_processor.get_environments_for_epoch(0).unwrap(), &key, 0, - &batch_processor.epoch_schedule, false, ); let loaded_program = ProgramCacheEntry::new_tombstone( @@ -756,7 +747,6 @@ mod tests { &batch_processor.get_environments_for_epoch(20).unwrap(), &key, 200, - &batch_processor.epoch_schedule, false, ); @@ -807,7 +797,6 @@ mod tests { .unwrap(), &key, 200, - &batch_processor.epoch_schedule, false, ) .unwrap(); diff --git a/svm/src/transaction_processor.rs b/svm/src/transaction_processor.rs index cc0cbcdac5775e..afac18b61e8dca 100644 --- a/svm/src/transaction_processor.rs +++ b/svm/src/transaction_processor.rs @@ -38,7 +38,6 @@ use { solana_sdk::{ account::{AccountSharedData, ReadableAccount, PROGRAM_OWNERS}, clock::{Epoch, Slot}, - epoch_schedule::EpochSchedule, feature_set::{ include_loaded_accounts_data_size_in_fee_calculation, remove_rounding_in_fee_calculation, FeatureSet, @@ -146,9 +145,6 @@ pub struct TransactionBatchProcessor { /// Bank epoch epoch: Epoch, - /// initialized from genesis - pub epoch_schedule: EpochSchedule, - /// Transaction fee structure pub fee_structure: FeeStructure, @@ -169,7 +165,6 @@ impl Debug for TransactionBatchProcessor { f.debug_struct("TransactionBatchProcessor") .field("slot", &self.slot) .field("epoch", &self.epoch) - .field("epoch_schedule", &self.epoch_schedule) .field("fee_structure", &self.fee_structure) .field("sysvar_cache", &self.sysvar_cache) .field("program_cache", &self.program_cache) @@ -182,7 +177,6 @@ impl Default for TransactionBatchProcessor { Self { slot: Slot::default(), epoch: Epoch::default(), - epoch_schedule: EpochSchedule::default(), fee_structure: FeeStructure::default(), sysvar_cache: RwLock::::default(), program_cache: Arc::new(RwLock::new(ProgramCache::new( @@ -195,16 +189,10 @@ impl Default for TransactionBatchProcessor { } impl TransactionBatchProcessor { - pub fn new( - slot: Slot, - epoch: Epoch, - epoch_schedule: EpochSchedule, - builtin_program_ids: HashSet, - ) -> Self { + pub fn new(slot: Slot, epoch: Epoch, builtin_program_ids: HashSet) -> Self { Self { slot, epoch, - epoch_schedule, fee_structure: FeeStructure::default(), sysvar_cache: RwLock::::default(), program_cache: Arc::new(RwLock::new(ProgramCache::new(slot, epoch))), @@ -216,7 +204,6 @@ impl TransactionBatchProcessor { Self { slot, epoch, - epoch_schedule: self.epoch_schedule.clone(), fee_structure: self.fee_structure.clone(), sysvar_cache: RwLock::::default(), program_cache: self.program_cache.clone(), @@ -589,7 +576,6 @@ impl TransactionBatchProcessor { &program_cache.get_environments_for_epoch(self.epoch), &key, self.slot, - &self.epoch_schedule, false, ) .expect("called load_program_with_pubkey() with nonexistent account"); @@ -637,10 +623,10 @@ impl TransactionBatchProcessor { callbacks: &CB, upcoming_feature_set: &FeatureSet, compute_budget: &ComputeBudget, + slot_index: u64, + slots_in_epoch: u64, ) { // Recompile loaded programs one at a time before the next epoch hits - let (_epoch, slot_index) = self.epoch_schedule.get_epoch_and_slot_index(self.slot); - let slots_in_epoch = self.epoch_schedule.get_slots_in_epoch(self.epoch); let slots_in_recompilation_phase = (solana_program_runtime::loaded_programs::MAX_LOADED_ENTRY_COUNT as u64) .min(slots_in_epoch) @@ -661,7 +647,6 @@ impl TransactionBatchProcessor { &environments_for_epoch, &key, self.slot, - &self.epoch_schedule, false, ) { recompiled @@ -1010,6 +995,7 @@ mod tests { bpf_loader, bpf_loader_upgradeable::{self, UpgradeableLoaderState}, compute_budget::ComputeBudgetInstruction, + epoch_schedule::EpochSchedule, feature_set::FeatureSet, fee::FeeDetails, fee_calculator::FeeCalculator, @@ -1856,12 +1842,7 @@ mod tests { #[test] fn fast_concur_test() { let mut mock_bank = MockBankCallback::default(); - let batch_processor = TransactionBatchProcessor::::new( - 5, - 5, - EpochSchedule::default(), - HashSet::new(), - ); + let batch_processor = TransactionBatchProcessor::::new(5, 5, HashSet::new()); batch_processor.program_cache.write().unwrap().fork_graph = Some(Arc::new(RwLock::new(TestForkGraph {}))); diff --git a/svm/tests/conformance.rs b/svm/tests/conformance.rs index ec5bbe0c9fd529..c0baeaef96e538 100644 --- a/svm/tests/conformance.rs +++ b/svm/tests/conformance.rs @@ -21,7 +21,6 @@ use { solana_sdk::{ account::{AccountSharedData, ReadableAccount, WritableAccount}, bpf_loader_upgradeable, - epoch_schedule::EpochSchedule, feature_set::{FeatureSet, FEATURE_NAMES}, hash::Hash, instruction::AccountMeta, @@ -247,12 +246,7 @@ fn run_fixture(fixture: InstrFixture, filename: OsString, execute_as_instr: bool create_program_runtime_environment_v1(&feature_set, &compute_budget, false, false).unwrap(); mock_bank.override_feature_set(feature_set); - let batch_processor = TransactionBatchProcessor::::new( - 42, - 2, - EpochSchedule::default(), - HashSet::new(), - ); + let batch_processor = TransactionBatchProcessor::::new(42, 2, HashSet::new()); { let mut program_cache = batch_processor.program_cache.write().unwrap(); @@ -445,7 +439,6 @@ fn execute_fixture_as_instr( &batch_processor.get_environments_for_epoch(2).unwrap(), &program_id, 42, - &batch_processor.epoch_schedule, false, ) .unwrap(); diff --git a/svm/tests/integration_test.rs b/svm/tests/integration_test.rs index 9816d41cbc4dae..c47ce03af9b5a1 100644 --- a/svm/tests/integration_test.rs +++ b/svm/tests/integration_test.rs @@ -21,7 +21,6 @@ use { account::{AccountSharedData, ReadableAccount, WritableAccount}, bpf_loader_upgradeable::{self, UpgradeableLoaderState}, clock::{Clock, Epoch, Slot, UnixTimestamp}, - epoch_schedule::EpochSchedule, hash::Hash, instruction::AccountMeta, pubkey::Pubkey, @@ -445,7 +444,6 @@ fn svm_integration() { let batch_processor = TransactionBatchProcessor::::new( EXECUTION_SLOT, EXECUTION_EPOCH, - EpochSchedule::default(), HashSet::new(), );