Skip to content

Commit

Permalink
Removes Cow from InvokeContext::sysvar_cache.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lichtso committed Apr 3, 2023
1 parent 37ad09e commit 6287879
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
13 changes: 6 additions & 7 deletions program-runtime/src/invoke_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ use {
},
std::{
alloc::Layout,
borrow::Cow,
cell::RefCell,
fmt::{self, Debug},
rc::Rc,
Expand Down Expand Up @@ -116,7 +115,7 @@ pub struct InvokeContext<'a> {
rent: Rent,
pre_accounts: Vec<PreAccount>,
builtin_programs: &'a [BuiltinProgram],
pub sysvar_cache: Cow<'a, SysvarCache>,
pub sysvar_cache: &'a SysvarCache,
pub trace_log_stack: Vec<TraceLogStackFrame>,
log_collector: Option<Rc<RefCell<LogCollector>>>,
compute_budget: ComputeBudget,
Expand All @@ -138,7 +137,7 @@ impl<'a> InvokeContext<'a> {
transaction_context: &'a mut TransactionContext,
rent: Rent,
builtin_programs: &'a [BuiltinProgram],
sysvar_cache: Cow<'a, SysvarCache>,
sysvar_cache: &'a SysvarCache,
log_collector: Option<Rc<RefCell<LogCollector>>>,
compute_budget: ComputeBudget,
tx_executor_cache: Rc<RefCell<TransactionExecutorCache>>,
Expand Down Expand Up @@ -852,7 +851,7 @@ macro_rules! with_mock_invoke_context {
account::ReadableAccount, feature_set::FeatureSet, hash::Hash, sysvar::rent::Rent,
transaction_context::TransactionContext,
},
std::{borrow::Cow, cell::RefCell, rc::Rc, sync::Arc},
std::{cell::RefCell, rc::Rc, sync::Arc},
$crate::{
compute_budget::ComputeBudget, executor_cache::TransactionExecutorCache,
invoke_context::InvokeContext, log_collector::LogCollector,
Expand Down Expand Up @@ -889,9 +888,9 @@ macro_rules! with_mock_invoke_context {
&mut $transaction_context,
Rent::default(),
&[],
Cow::Owned(sysvar_cache),
&sysvar_cache,
Some(LogCollector::new_ref()),
ComputeBudget::default(),
compute_budget,
Rc::new(RefCell::new(TransactionExecutorCache::default())),
Arc::new(FeatureSet::all_enabled()),
Hash::default(),
Expand Down Expand Up @@ -941,7 +940,7 @@ pub fn mock_process_instruction(
transaction_accounts.push((*loader_id, processor_account));
with_mock_invoke_context!(invoke_context, transaction_context, transaction_accounts);
if let Some(sysvar_cache) = sysvar_cache_override {
invoke_context.sysvar_cache = Cow::Borrowed(sysvar_cache);
invoke_context.sysvar_cache = &sysvar_cache;
}
if let Some(feature_set) = feature_set_override {
invoke_context.feature_set = feature_set;
Expand Down
2 changes: 1 addition & 1 deletion programs/bpf_loader/src/syscalls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3300,7 +3300,7 @@ mod tests {
sysvar_cache.set_rent(src_rent);

prepare_mockup!(invoke_context, program_id, bpf_loader::id());
invoke_context.sysvar_cache = Cow::Owned(sysvar_cache);
invoke_context.sysvar_cache = &sysvar_cache;

// Test clock sysvar
{
Expand Down
4 changes: 2 additions & 2 deletions runtime/src/message_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use {
transaction::TransactionError,
transaction_context::{IndexOfAccount, InstructionAccount, TransactionContext},
},
std::{borrow::Cow, cell::RefCell, rc::Rc, sync::Arc},
std::{cell::RefCell, rc::Rc, sync::Arc},
};

#[derive(Debug, Default, Clone, Deserialize, Serialize)]
Expand Down Expand Up @@ -71,7 +71,7 @@ impl MessageProcessor {
transaction_context,
rent,
builtin_programs,
Cow::Borrowed(sysvar_cache),
sysvar_cache,
log_collector,
compute_budget,
tx_executor_cache,
Expand Down

0 comments on commit 6287879

Please sign in to comment.