Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Refactor - Remove first_instruction_account in bpf_loader #30614

Conversation

Lichtso
Copy link
Contributor

@Lichtso Lichtso commented Mar 6, 2023

Problem

The logic in process_instruction_common() is quite complex and hard to understand. Additionally, we want to get rid of program_indices and try_borrow_program_account, so their usage in the BPF loader needs to be minimized.

There are five cases of what program_account inputs process_instruction_common() needs to handle:

  • Program Management Instruction: [Loader]
  • Transaction Level Instruction: [Loader, Program]
  • Transaction Level Instruction: [Loader, Programdata, Program]
  • Cross Program Invocation: [Program]
  • Cross Program Invocation: [Programdata, Program]

From that we can tell, that we only need to look at the last program in the chain, and only in case of the upgradeable loader also need the second last (the programdata account).

Summary of Changes

  • Removes first_instruction_account from process_instruction_common(), process_loader_upgradeable_instruction(), process_loader_instruction() and write_program_data().
  • Removes get_index_in_transaction() and try_borrow_account().

@Lichtso Lichtso requested a review from pgarg66 March 6, 2023 17:04
@Lichtso Lichtso force-pushed the refactor/remove_first_instruction_account_in_bpf_loader branch from cbd4b63 to 7b86646 Compare March 6, 2023 20:19
@Lichtso Lichtso merged commit d2fc2e5 into solana-labs:master Mar 8, 2023
@Lichtso Lichtso deleted the refactor/remove_first_instruction_account_in_bpf_loader branch March 8, 2023 15:54
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants