Refactor: move sysvar cache to new module

This commit is contained in:
Justin Starry
2022-01-12 11:19:11 +08:00
committed by Trent Nelson
parent b27333e52d
commit 7171c95bdd
12 changed files with 144 additions and 87 deletions

View File

@@ -5,6 +5,7 @@ use {
instruction_recorder::InstructionRecorder,
invoke_context::{BuiltinProgram, Executors, InvokeContext},
log_collector::LogCollector,
sysvar_cache::SysvarCache,
timings::ExecuteTimings,
},
solana_sdk::{
@@ -14,14 +15,13 @@ use {
hash::Hash,
message::SanitizedMessage,
precompiles::is_precompile,
pubkey::Pubkey,
rent::Rent,
saturating_add_assign,
sysvar::instructions,
transaction::TransactionError,
transaction_context::{InstructionAccount, TransactionContext},
},
std::{cell::RefCell, rc::Rc, sync::Arc},
std::{borrow::Cow, cell::RefCell, rc::Rc, sync::Arc},
};
#[derive(Debug, Default, Clone, Deserialize, Serialize)]
@@ -62,7 +62,7 @@ impl MessageProcessor {
feature_set: Arc<FeatureSet>,
compute_budget: ComputeBudget,
timings: &mut ExecuteTimings,
sysvars: &[(Pubkey, Vec<u8>)],
sysvar_cache: &SysvarCache,
blockhash: Hash,
lamports_per_signature: u64,
current_accounts_data_len: u64,
@@ -71,7 +71,7 @@ impl MessageProcessor {
transaction_context,
rent,
builtin_programs,
sysvars,
Cow::Borrowed(sysvar_cache),
log_collector,
compute_budget,
executors,
@@ -166,6 +166,7 @@ mod tests {
instruction::{AccountMeta, Instruction, InstructionError},
message::Message,
native_loader::{self, create_loadable_account_for_test},
pubkey::Pubkey,
secp256k1_instruction::new_secp256k1_instruction,
secp256k1_program,
},
@@ -257,6 +258,7 @@ mod tests {
)],
Some(transaction_context.get_key_of_account_at_index(0)),
));
let sysvar_cache = SysvarCache::default();
let result = MessageProcessor::process_message(
builtin_programs,
&message,
@@ -269,7 +271,7 @@ mod tests {
Arc::new(FeatureSet::all_enabled()),
ComputeBudget::new(),
&mut ExecuteTimings::default(),
&[],
&sysvar_cache,
Hash::default(),
0,
0,
@@ -310,7 +312,7 @@ mod tests {
Arc::new(FeatureSet::all_enabled()),
ComputeBudget::new(),
&mut ExecuteTimings::default(),
&[],
&sysvar_cache,
Hash::default(),
0,
0,
@@ -343,7 +345,7 @@ mod tests {
Arc::new(FeatureSet::all_enabled()),
ComputeBudget::new(),
&mut ExecuteTimings::default(),
&[],
&sysvar_cache,
Hash::default(),
0,
0,
@@ -457,6 +459,7 @@ mod tests {
)],
Some(transaction_context.get_key_of_account_at_index(0)),
));
let sysvar_cache = SysvarCache::default();
let result = MessageProcessor::process_message(
builtin_programs,
&message,
@@ -469,7 +472,7 @@ mod tests {
Arc::new(FeatureSet::all_enabled()),
ComputeBudget::new(),
&mut ExecuteTimings::default(),
&[],
&sysvar_cache,
Hash::default(),
0,
0,
@@ -503,7 +506,7 @@ mod tests {
Arc::new(FeatureSet::all_enabled()),
ComputeBudget::new(),
&mut ExecuteTimings::default(),
&[],
&sysvar_cache,
Hash::default(),
0,
0,
@@ -534,7 +537,7 @@ mod tests {
Arc::new(FeatureSet::all_enabled()),
ComputeBudget::new(),
&mut ExecuteTimings::default(),
&[],
&sysvar_cache,
Hash::default(),
0,
0,
@@ -595,6 +598,7 @@ mod tests {
],
None,
));
let sysvar_cache = SysvarCache::default();
let result = MessageProcessor::process_message(
builtin_programs,
&message,
@@ -607,7 +611,7 @@ mod tests {
Arc::new(FeatureSet::all_enabled()),
ComputeBudget::new(),
&mut ExecuteTimings::default(),
&[],
&sysvar_cache,
Hash::default(),
0,
0,