Refactor: process_instruction() (#20448)
* Adds first_instruction_account parameter to process_instruction(). * Removes InvokeContext::remove_first_keyed_account() from all BPF loaders. * Removes InvokeContext::remove_first_keyed_account() from all builtin programs. * Removes InvokeContext::remove_first_keyed_account() from all mock ups. * Deprecates InvokeContext::remove_first_keyed_account(). * Documents index base of keyed_account_at_index(). * Adds dynamic offset to call sites of "keyed_account_at_index()".
This commit is contained in:
committed by
GitHub
parent
a6a4cfda89
commit
4e65487d2f
@ -101,6 +101,7 @@ fn get_invoke_context<'a>() -> &'a mut dyn InvokeContext {
|
||||
pub fn builtin_process_instruction(
|
||||
process_instruction: solana_sdk::entrypoint::ProcessInstruction,
|
||||
program_id: &Pubkey,
|
||||
_first_instruction_account: usize,
|
||||
input: &[u8],
|
||||
invoke_context: &mut dyn InvokeContext,
|
||||
) -> Result<(), InstructionError> {
|
||||
@ -109,7 +110,8 @@ pub fn builtin_process_instruction(
|
||||
let logger = invoke_context.get_logger();
|
||||
stable_log::program_invoke(&logger, program_id, invoke_context.invoke_depth());
|
||||
|
||||
let keyed_accounts = invoke_context.get_keyed_accounts()?;
|
||||
// Skip the processor account
|
||||
let keyed_accounts = &invoke_context.get_keyed_accounts()?[1..];
|
||||
|
||||
// Copy all the accounts into a HashMap to ensure there are no duplicates
|
||||
let mut accounts: HashMap<Pubkey, Account> = keyed_accounts
|
||||
@ -183,11 +185,13 @@ macro_rules! processor {
|
||||
($process_instruction:expr) => {
|
||||
Some(
|
||||
|program_id: &Pubkey,
|
||||
first_instruction_account: usize,
|
||||
input: &[u8],
|
||||
invoke_context: &mut dyn solana_sdk::process_instruction::InvokeContext| {
|
||||
$crate::builtin_process_instruction(
|
||||
$process_instruction,
|
||||
program_id,
|
||||
first_instruction_account,
|
||||
input,
|
||||
invoke_context,
|
||||
)
|
||||
|
Reference in New Issue
Block a user