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

Index loaders / executable accounts #19469

Merged

Conversation

Lichtso
Copy link
Contributor

@Lichtso Lichtso commented Aug 27, 2021

Problem

Continuation of #17898 which unified account_deps and accounts.
Loaders / executable accounts are still separate and need to be unified with the normal accounts.
Then, all three kinds of accounts can be indexed transaction wide,
which is necessary for inter-operation between the current ABI and the new one (#19191).

Left for another PR:
Fill executable account gaps with the real deal directly instead of concatenating them at the end.
That requires them to be read-only and might need a feature gate.

Summary of Changes

  • Replaces loaders by executable_indices.
  • Concatenates loaders at the end of the normal accounts in transaction loading.
  • Preparation for the next steps: Collect executable_indices directly in load_executable_accounts().
  • Moves MessageProcessor::create_keyed_accounts() into InvokeContext::push(), which is required for resolving the executable_indices.

@Lichtso Lichtso force-pushed the refactor/merge_executables_into_accounts branch 4 times, most recently from 537ffc8 to ba5b5ad Compare September 3, 2021 07:32
@codecov
Copy link

codecov bot commented Sep 3, 2021

Codecov Report

Merging #19469 (f042892) into master (8489ee7) will increase coverage by 0.0%.
The diff coverage is 82.3%.

@@           Coverage Diff           @@
##           master   #19469   +/-   ##
=======================================
  Coverage    82.6%    82.6%           
=======================================
  Files         471      471           
  Lines      132557   132549    -8     
=======================================
+ Hits       109509   109522   +13     
+ Misses      23048    23027   -21     

@Lichtso Lichtso force-pushed the refactor/merge_executables_into_accounts branch 4 times, most recently from 49f8c9c to d5b4a3d Compare September 6, 2021 15:36
@Lichtso Lichtso requested a review from jackcmay September 6, 2021 17:28
@Lichtso Lichtso force-pushed the refactor/merge_executables_into_accounts branch 2 times, most recently from 375d1b5 to 5eb2697 Compare September 8, 2021 10:24
@Lichtso Lichtso force-pushed the refactor/merge_executables_into_accounts branch from 5eb2697 to f042892 Compare September 9, 2021 08:42
@Lichtso
Copy link
Contributor Author

Lichtso commented Sep 9, 2021

@CriesofCarrots While resolving merge conflicts I touched some of your recent changes. A quick assessment if the three tests (see last commit) are still correct suffices.

Copy link
Contributor

@CriesofCarrots CriesofCarrots left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests in last commit look correct to me. Thanks!

@Lichtso Lichtso merged commit 88c1b8f into solana-labs:master Sep 10, 2021
@Lichtso Lichtso deleted the refactor/merge_executables_into_accounts branch September 10, 2021 06:36
@jstarry
Copy link
Member

jstarry commented Sep 11, 2021

@Lichtso I don't understand what problem this change fixed. Can you explain?

.map(|instruction| {
self.load_executable_accounts(
ancestors,
&mut accounts,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to add executable accounts to accounts here? Couldn't we add them above?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is a preparation for the next step:
Currently we leave gaps for the executable accounts (so that the indices stay correct) and then load them for each instruction. Thus, they are loaded duplicate if multiple instructions use the same executable. And that could be avoided here, once we can make sure that accounts used as programs are not writable. (see #19629)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah that is tricky. Someone could update program and then call it later within the same transaction, thanks for the explanation

@Lichtso
Copy link
Contributor Author

Lichtso commented Sep 11, 2021

@Lichtso I don't understand what problem this change fixed. Can you explain?

You are right, the PR description was not particularly insightful.
I updated it and added some details, hope it is easier to understand now.

@jstarry
Copy link
Member

jstarry commented Sep 12, 2021

Ah yeah that makes sense. I like that all accounts can be indexed in the same way but I think it would be nice to have a wrapper type which keeps account inputs and account deps separate internally but implements the index trait. This way the code is more straightforward and no one has to remember what is actually in the accounts vec

@Lichtso Lichtso mentioned this pull request Sep 30, 2021
dankelleher pushed a commit to identity-com/solana that referenced this pull request Nov 24, 2021
* Appends loaders / executable_accounts to accounts in transaction loading.

* Adds indices to loaders / executable_accounts.

* Moves MessageProcessor::create_keyed_accounts() into InvokeContext::push().

* Removes "executable_accounts",
now referenced by transaction wide index into "accounts".

* Removes create_pre_accounts() from InstructionProcessor,
as it is already in MessageProcessor.

* Collect program account indices directly in load_executable_accounts().
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.

3 participants