Skip to content

Commit

Permalink
stub using feature flags
Browse files Browse the repository at this point in the history
set cu consumed
  • Loading branch information
ravyu-jump committed Jul 24, 2024
1 parent e8750ba commit ef9a17c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions program-runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,5 @@ frozen-abi = [
"solana-sdk/frozen-abi",
]
shuttle-test = ["solana-type-overrides/shuttle-test"]
stub-proc-instr = []

12 changes: 11 additions & 1 deletion program-runtime/src/invoke_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ use {
cell::RefCell,
fmt::{self, Debug},
rc::Rc,
},
}
};

pub type BuiltinFunctionWithContext = BuiltinFunction<InvokeContext<'static>>;
Expand Down Expand Up @@ -187,6 +187,8 @@ pub struct SerializedAccountMetadata {
pub vm_owner_addr: u64,
}



/// Main pipeline from runtime to program execution.
pub struct InvokeContext<'a> {
/// Information about the currently executing transaction.
Expand Down Expand Up @@ -455,10 +457,18 @@ impl<'a> InvokeContext<'a> {
timings: &mut ExecuteTimings,
) -> Result<(), InstructionError> {
*compute_units_consumed = 0;

// Stub out the processing of the instruction
if cfg!(feature = "stub-proc-instr"){
eprintln!("Stubbing out processing of instruction");
return Ok(());
}

self.transaction_context
.get_next_instruction_context()?
.configure(program_indices, instruction_accounts, instruction_data);
self.push()?;

self.process_executable_chain(compute_units_consumed, timings)
// MUST pop if and only if `push` succeeded, independent of `result`.
// Thus, the `.and()` instead of an `.and_then()`.
Expand Down

0 comments on commit ef9a17c

Please sign in to comment.