Refactor: move sysvar cache to new module (backport #22448) (#22461)

* Refactor: move sysvar cache to new module

(cherry picked from commit 7171c95bdd)

# Conflicts:
#	Cargo.lock
#	program-runtime/Cargo.toml
#	program-runtime/src/invoke_context.rs
#	programs/bpf/Cargo.lock
#	programs/bpf_loader/src/syscalls.rs
#	programs/stake/src/stake_instruction.rs
#	programs/vote/src/vote_instruction.rs
#	runtime/src/message_processor.rs

* resolve conflicts

Co-authored-by: Justin Starry <justin@solana.com>
This commit is contained in:
mergify[bot]
2022-01-14 08:43:26 +00:00
committed by GitHub
parent 9d69f2b324
commit a6b7a3b7ff
12 changed files with 153 additions and 90 deletions

View File

@ -449,7 +449,9 @@ mod tests {
use {
super::*,
bincode::serialize,
solana_program_runtime::invoke_context::mock_process_instruction,
solana_program_runtime::{
invoke_context::mock_process_instruction, sysvar_cache::SysvarCache,
},
solana_sdk::{
account::{self, Account, AccountSharedData},
rent::Rent,
@ -509,14 +511,15 @@ mod tests {
.map(|(meta, account)| (meta.is_signer, meta.is_writable, meta.pubkey, account))
.collect();
let mut sysvar_cache = SysvarCache::default();
let rent = Rent::default();
let rent_sysvar = (sysvar::rent::id(), bincode::serialize(&rent).unwrap());
sysvar_cache.push_entry(sysvar::rent::id(), bincode::serialize(&rent).unwrap());
solana_program_runtime::invoke_context::mock_process_instruction_with_sysvars(
&id(),
Vec::new(),
&instruction.data,
&keyed_accounts,
&[rent_sysvar],
&sysvar_cache,
super::process_instruction,
)
}