Refactor: Unify SysvarCache (#22843)

* Unifies SysvarCache filling in the runtime and tests.
Removes new_mock_with_sysvars_and_features()
Removes mock_process_instruction_with_sysvars().
Replaces from_keyed_account() by SysvarCache in vote processor.

* Replaces from_keyed_account() by SysvarCache in BPF loader.
This commit is contained in:
Alexander Meißner
2022-01-31 17:53:50 +01:00
committed by GitHub
parent 6a0c45fa2e
commit bc800a8d5a
7 changed files with 246 additions and 239 deletions

View File

@@ -3,7 +3,7 @@
extern crate test;
use {
solana_program_runtime::{invoke_context::InvokeContext, sysvar_cache::SysvarCache},
solana_program_runtime::invoke_context::InvokeContext,
solana_sdk::{
account::{create_account_for_test, Account, AccountSharedData},
clock::{Clock, Slot},
@@ -148,10 +148,6 @@ fn do_bench_process_vote_instruction(bencher: &mut Bencher, feature: Option<Pubk
})
.collect::<Vec<_>>();
let mut sysvar_cache = SysvarCache::default();
sysvar_cache.set_clock(clock);
sysvar_cache.set_slot_hashes(slot_hashes);
bencher.iter(|| {
let mut transaction_context = TransactionContext::new(
vec![
@@ -174,12 +170,8 @@ fn do_bench_process_vote_instruction(bencher: &mut Bencher, feature: Option<Pubk
1,
);
let mut invoke_context = InvokeContext::new_mock_with_sysvars_and_features(
&mut transaction_context,
&sysvar_cache,
feature_set.clone(),
);
let mut invoke_context = InvokeContext::new_mock(&mut transaction_context, &[]);
invoke_context.feature_set = feature_set.clone();
invoke_context
.push(&instruction_accounts, &program_indices, &[])
.unwrap();