Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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
nickfrosty pushed a commit to nickfrosty/solana that referenced this pull request Mar 12, 2023
…-labs#30614)

* Removes first_instruction_account from process_loader_upgradeable_instruction(), process_loader_instruction() and write_program_data().

* Removes first_instruction_account from process_instruction_common().

* Removes get_index_in_transaction() and try_borrow_account().
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants