From c2b15a053cc5b083d27bfad4e8c7038074fcda0c Mon Sep 17 00:00:00 2001 From: Jack May Date: Fri, 14 Jan 2022 17:21:09 -0800 Subject: [PATCH] rename --- program-runtime/src/invoke_context.rs | 6 +++--- programs/bpf/rust/sibling_instruction/src/lib.rs | 12 ++++++------ programs/bpf_loader/src/syscalls.rs | 9 +++++---- runtime/src/bank.rs | 9 +++++---- sdk/program/src/instruction.rs | 14 +++++++------- sdk/program/src/program_stubs.rs | 9 ++++++--- 6 files changed, 32 insertions(+), 27 deletions(-) diff --git a/program-runtime/src/invoke_context.rs b/program-runtime/src/invoke_context.rs index 7fcf67d9868576..36db6cd30cc1e1 100644 --- a/program-runtime/src/invoke_context.rs +++ b/program-runtime/src/invoke_context.rs @@ -1017,12 +1017,12 @@ impl<'a> InvokeContext<'a> { } // Push a sibling instruction - pub fn add_sibling_instruction(&mut self, instruction: Instruction) { + pub fn add_processed_sibling_instruction(&mut self, instruction: Instruction) { self.sibling_instructions.push(instruction); } - /// Get a sibling instruction, reverse ordered or last added is index 0 - pub fn get_sibling_instruction(&self, index: usize) -> Option<&Instruction> { + /// Get a sibling instruction, reverse ordered list, where last added is index 0 + pub fn get_processed_sibling_instruction(&self, index: usize) -> Option<&Instruction> { let index = self .sibling_instructions .len() diff --git a/programs/bpf/rust/sibling_instruction/src/lib.rs b/programs/bpf/rust/sibling_instruction/src/lib.rs index a0e871dce759e5..58bcbcb25bfe84 100644 --- a/programs/bpf/rust/sibling_instruction/src/lib.rs +++ b/programs/bpf/rust/sibling_instruction/src/lib.rs @@ -6,7 +6,7 @@ use solana_program::{ account_info::AccountInfo, entrypoint, entrypoint::ProgramResult, - instruction::{get_sibling_instruction, AccountMeta, Instruction}, + instruction::{get_processed_sibling_instruction, AccountMeta, Instruction}, msg, program::invoke, pubkey::Pubkey, @@ -51,11 +51,11 @@ fn process_instruction( invoke(&instruction1, accounts)?; invoke(&instruction0, accounts)?; - assert_eq!(Some(instruction0), get_sibling_instruction(0)); - assert_eq!(Some(instruction1), get_sibling_instruction(1)); - assert_eq!(Some(instruction2), get_sibling_instruction(2)); - assert_eq!(Some(instruction3), get_sibling_instruction(3)); - assert!(get_sibling_instruction(4).is_none()); + assert_eq!(Some(instruction0), get_processed_sibling_instruction(0)); + assert_eq!(Some(instruction1), get_processed_sibling_instruction(1)); + assert_eq!(Some(instruction2), get_processed_sibling_instruction(2)); + assert_eq!(Some(instruction3), get_processed_sibling_instruction(3)); + assert!(get_processed_sibling_instruction(4).is_none()); Ok(()) } diff --git a/programs/bpf_loader/src/syscalls.rs b/programs/bpf_loader/src/syscalls.rs index 12c12375967fc7..f4f5cca1285249 100644 --- a/programs/bpf_loader/src/syscalls.rs +++ b/programs/bpf_loader/src/syscalls.rs @@ -227,7 +227,7 @@ pub fn register_syscalls( .is_active(&add_get_sibling_instruction_syscall::id()) { syscall_registry.register_syscall_by_name( - b"sol_get_sibling_instruction", + b"sol_get_processed_sibling_instruction", SyscallGetSiblingInstruction::call, )?; } @@ -2591,8 +2591,8 @@ fn check_authorized_program( return Err(SyscallError::ProgramNotSupported(*program_id).into()); } Ok(()) -} +} /// Call process instruction, common to both Rust and C fn call<'a, 'b: 'a>( syscall: &mut dyn SyscallInvokeSigned<'a, 'b>, @@ -2659,7 +2659,7 @@ fn call<'a, 'b: 'a>( ) .map_err(SyscallError::InstructionError)?; - invoke_context.add_sibling_instruction(instruction); + invoke_context.add_processed_sibling_instruction(instruction); // Copy results back to caller for (callee_account_index, caller_account) in accounts.iter_mut() { @@ -2975,7 +2975,8 @@ impl<'a, 'b> SyscallObject for SyscallGetSiblingInstruction<'a, 'b> { result ); - if let Some(instruction) = invoke_context.get_sibling_instruction(index as usize) { + if let Some(instruction) = invoke_context.get_processed_sibling_instruction(index as usize) + { let SiblingLengths { data_len, accounts_len, diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index 0e2e1f69e1c15e..0375674472283b 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -3666,13 +3666,14 @@ impl Bank { let pre_account_state_info = self.get_transaction_account_state_info(&transaction_context, tx.message()); - let instruction_recorder = if enable_cpi_recording { + let instruction_recorder = //if enable_cpi_recording { Some(InstructionRecorder::new_ref( tx.message().instructions().len(), )) - } else { - None - }; + // } else { + // None + // } + ; let log_collector = if enable_log_recording { Some(LogCollector::new_ref()) diff --git a/sdk/program/src/instruction.rs b/sdk/program/src/instruction.rs index 2de72749044e95..06890500ccf955 100644 --- a/sdk/program/src/instruction.rs +++ b/sdk/program/src/instruction.rs @@ -659,18 +659,18 @@ pub struct SiblingLengths { /// /// The Sibling instruction list is a reverse-ordered list of successfully /// processed inner instructions. For example, given the call flow: -/// ``` +/// /// A /// B -> C -> D /// B -> E /// B -> F -/// ``` +/// /// Then B's sibling instruction list is: [F, E, D, C] -pub fn get_sibling_instruction(index: usize) -> Option { +pub fn get_processed_sibling_instruction(index: usize) -> Option { #[cfg(target_arch = "bpf")] { extern "C" { - fn sol_get_sibling_instruction( + fn sol_get_processed_sibling_instruction( index: u64, lengths: *mut SiblingLengths, program_id: *mut Pubkey, @@ -683,7 +683,7 @@ pub fn get_sibling_instruction(index: usize) -> Option { let mut program_id = Pubkey::default(); if 1 == unsafe { - sol_get_sibling_instruction( + sol_get_processed_sibling_instruction( index as u64, &mut lengths, &mut program_id, @@ -697,7 +697,7 @@ pub fn get_sibling_instruction(index: usize) -> Option { accounts.resize_with(lengths.accounts_len as usize, AccountMeta::default); let _ = unsafe { - sol_get_sibling_instruction( + sol_get_processed_sibling_instruction( index as u64, &mut lengths, &mut program_id, @@ -713,7 +713,7 @@ pub fn get_sibling_instruction(index: usize) -> Option { } #[cfg(not(target_arch = "bpf"))] - crate::program_stubs::get_sibling_instruction(index) + crate::program_stubs::get_processed_sibling_instruction(index) } #[test] diff --git a/sdk/program/src/program_stubs.rs b/sdk/program/src/program_stubs.rs index 88a0f1ffb753f9..83e842c78def4d 100644 --- a/sdk/program/src/program_stubs.rs +++ b/sdk/program/src/program_stubs.rs @@ -91,7 +91,7 @@ pub trait SyscallStubs: Sync + Send { fn sol_log_data(&self, fields: &[&[u8]]) { println!("data: {}", fields.iter().map(base64::encode).join(" ")); } - fn get_sibling_instruction(&self, _index: usize) -> Option { + fn get_processed_sibling_instruction(&self, _index: usize) -> Option { None } } @@ -180,8 +180,11 @@ pub(crate) fn sol_log_data(data: &[&[u8]]) { SYSCALL_STUBS.read().unwrap().sol_log_data(data) } -pub(crate) fn get_sibling_instruction(index: usize) -> Option { - SYSCALL_STUBS.read().unwrap().get_sibling_instruction(index) +pub(crate) fn get_processed_sibling_instruction(index: usize) -> Option { + SYSCALL_STUBS + .read() + .unwrap() + .get_processed_sibling_instruction(index) } /// Check that two regions do not overlap.