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
@@ -14,13 +14,21 @@ use solana_frozen_abi::abi_example::AbiExample;
|
||||
fn process_instruction_with_program_logging(
|
||||
process_instruction: ProcessInstructionWithContext,
|
||||
program_id: &Pubkey,
|
||||
first_instruction_account: usize,
|
||||
instruction_data: &[u8],
|
||||
invoke_context: &mut dyn InvokeContext,
|
||||
) -> Result<(), InstructionError> {
|
||||
debug_assert_eq!(first_instruction_account, 1);
|
||||
|
||||
let logger = invoke_context.get_logger();
|
||||
stable_log::program_invoke(&logger, program_id, invoke_context.invoke_depth());
|
||||
|
||||
let result = process_instruction(program_id, instruction_data, invoke_context);
|
||||
let result = process_instruction(
|
||||
program_id,
|
||||
first_instruction_account,
|
||||
instruction_data,
|
||||
invoke_context,
|
||||
);
|
||||
|
||||
match &result {
|
||||
Ok(()) => stable_log::program_success(&logger, program_id),
|
||||
@@ -31,10 +39,14 @@ fn process_instruction_with_program_logging(
|
||||
|
||||
macro_rules! with_program_logging {
|
||||
($process_instruction:expr) => {
|
||||
|program_id: &Pubkey, instruction_data: &[u8], invoke_context: &mut dyn InvokeContext| {
|
||||
|program_id: &Pubkey,
|
||||
first_instruction_account: usize,
|
||||
instruction_data: &[u8],
|
||||
invoke_context: &mut dyn InvokeContext| {
|
||||
process_instruction_with_program_logging(
|
||||
$process_instruction,
|
||||
program_id,
|
||||
first_instruction_account,
|
||||
instruction_data,
|
||||
invoke_context,
|
||||
)
|
||||
@@ -82,7 +94,7 @@ impl AbiExample for Builtin {
|
||||
Self {
|
||||
name: String::default(),
|
||||
id: Pubkey::default(),
|
||||
process_instruction_with_context: |_, _, _| Ok(()),
|
||||
process_instruction_with_context: |_, _, _, _| Ok(()),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -130,6 +142,7 @@ fn genesis_builtins() -> Vec<Builtin> {
|
||||
/// place holder for secp256k1, remove when the precompile program is deactivated via feature activation
|
||||
fn dummy_process_instruction(
|
||||
_program_id: &Pubkey,
|
||||
_first_instruction_account: usize,
|
||||
_data: &[u8],
|
||||
_invoke_context: &mut dyn InvokeContext,
|
||||
) -> Result<(), InstructionError> {
|
||||
|
Reference in New Issue
Block a user