Skip to content

Commit

Permalink
SVM: API: drop builtin IDs from new_uninitialized (anza-xyz#3171)
Browse files Browse the repository at this point in the history
  • Loading branch information
buffalojoec authored Oct 17, 2024
1 parent 17d94c4 commit 47c439a
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 28 deletions.
4 changes: 2 additions & 2 deletions runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1050,7 +1050,7 @@ impl Bank {
};

bank.transaction_processor =
TransactionBatchProcessor::new_uninitialized(bank.slot, bank.epoch, HashSet::default());
TransactionBatchProcessor::new_uninitialized(bank.slot, bank.epoch);

let accounts_data_size_initial = bank.get_total_accounts_stats().unwrap().data_len as u64;
bank.accounts_data_size_initial = accounts_data_size_initial;
Expand Down Expand Up @@ -1704,7 +1704,7 @@ impl Bank {
};

bank.transaction_processor =
TransactionBatchProcessor::new_uninitialized(bank.slot, bank.epoch, HashSet::default());
TransactionBatchProcessor::new_uninitialized(bank.slot, bank.epoch);

let thread_pool = ThreadPoolBuilder::new()
.thread_name(|i| format!("solBnkNewFlds{i:02}"))
Expand Down
1 change: 0 additions & 1 deletion svm/examples/json-rpc/server/src/rpc_process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ impl JsonRpcRequestProcessor {
let batch_processor = TransactionBatchProcessor::<MockForkGraph>::new_uninitialized(
EXECUTION_SLOT,
EXECUTION_EPOCH,
HashSet::new(),
);

Self {
Expand Down
9 changes: 2 additions & 7 deletions svm/examples/paytube/src/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ use {
transaction_processor::TransactionBatchProcessor,
},
solana_system_program::system_processor,
std::{
collections::HashSet,
sync::{Arc, RwLock},
},
std::sync::{Arc, RwLock},
};

/// In order to use the `TransactionBatchProcessor`, another trait - Solana
Expand Down Expand Up @@ -51,9 +48,7 @@ pub(crate) fn create_transaction_batch_processor<CB: TransactionProcessingCallba
// See `solana_svm::program_loader::load_program_with_pubkey` for more
// details.
let processor = TransactionBatchProcessor::<PayTubeForkGraph>::new_uninitialized(
/* slot */ 1,
/* epoch */ 1,
/* builtin_program_ids */ HashSet::new(),
/* slot */ 1, /* epoch */ 1,
);

{
Expand Down
9 changes: 2 additions & 7 deletions svm/src/transaction_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,17 +198,12 @@ impl<FG: ForkGraph> TransactionBatchProcessor<FG> {
///
/// When using this method, it's advisable to call `set_fork_graph_in_program_cache`
/// as well as `add_builtin` to configure the cache before using the processor.
pub fn new_uninitialized(
slot: Slot,
epoch: Epoch,
builtin_program_ids: HashSet<Pubkey>,
) -> Self {
pub fn new_uninitialized(slot: Slot, epoch: Epoch) -> Self {
Self {
slot,
epoch,
sysvar_cache: RwLock::<SysvarCache>::default(),
program_cache: Arc::new(RwLock::new(ProgramCache::new(slot, epoch))),
builtin_program_ids: RwLock::new(builtin_program_ids),
..Self::default()
}
}

Expand Down
10 changes: 4 additions & 6 deletions svm/tests/concurrent_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use {
TransactionProcessingEnvironment,
},
},
std::collections::{HashMap, HashSet},
std::collections::HashMap,
};

mod mock_bank;
Expand All @@ -40,8 +40,7 @@ mod transaction_builder;

fn program_cache_execution(threads: usize) {
let mut mock_bank = MockBankCallback::default();
let batch_processor =
TransactionBatchProcessor::<MockForkGraph>::new_uninitialized(5, 5, HashSet::new());
let batch_processor = TransactionBatchProcessor::<MockForkGraph>::new_uninitialized(5, 5);
let fork_graph = Arc::new(RwLock::new(MockForkGraph {}));
batch_processor.program_cache.write().unwrap().fork_graph = Some(Arc::downgrade(&fork_graph));

Expand Down Expand Up @@ -127,9 +126,8 @@ fn test_program_cache_with_exhaustive_scheduler() {
// correctly.
fn svm_concurrent() {
let mock_bank = Arc::new(MockBankCallback::default());
let batch_processor = Arc::new(
TransactionBatchProcessor::<MockForkGraph>::new_uninitialized(5, 2, HashSet::new()),
);
let batch_processor =
Arc::new(TransactionBatchProcessor::<MockForkGraph>::new_uninitialized(5, 2));
let fork_graph = Arc::new(RwLock::new(MockForkGraph {}));

create_executable_environment(
Expand Down
3 changes: 1 addition & 2 deletions svm/tests/conformance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,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::<MockForkGraph>::new_uninitialized(42, 2, HashSet::new());
let batch_processor = TransactionBatchProcessor::<MockForkGraph>::new_uninitialized(42, 2);

let fork_graph = Arc::new(RwLock::new(MockForkGraph {}));
{
Expand Down
4 changes: 1 addition & 3 deletions svm/tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use {
},
solana_svm_transaction::svm_message::SVMMessage,
solana_type_overrides::sync::{Arc, RwLock},
std::collections::{HashMap, HashSet},
std::collections::HashMap,
test_case::test_case,
};

Expand Down Expand Up @@ -875,7 +875,6 @@ fn execute_test_entry(test_entry: SvmTestEntry) {
let batch_processor = TransactionBatchProcessor::<MockForkGraph>::new_uninitialized(
EXECUTION_SLOT,
EXECUTION_EPOCH,
HashSet::new(),
);

let fork_graph = Arc::new(RwLock::new(MockForkGraph {}));
Expand Down Expand Up @@ -1062,7 +1061,6 @@ fn svm_inspect_account() {
let batch_processor = TransactionBatchProcessor::<MockForkGraph>::new_uninitialized(
EXECUTION_SLOT,
EXECUTION_EPOCH,
HashSet::new(),
);

let fork_graph = Arc::new(RwLock::new(MockForkGraph {}));
Expand Down

0 comments on commit 47c439a

Please sign in to comment.