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

svm: AccountLoader mutability refactor #4680

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

2501babe
Copy link
Member

@2501babe 2501babe commented Jan 29, 2025

TODO my pr situation is getting messy but this is the first half of a new approach for fixing filter_executable_program_accounts() once and for all that handles some code hairball issues much better than previous attempts (#4553 and #4576)

first attempt was use a per-tx local program cache, moving its creation after tx loading, using AccountLoader as-is. this has issues:

  • a few callees of replenish_program_cache() are used in Bank which has no awareness of AccountLoader, so we would need to break up things like load_program_with_pubkey() in weird ways, eg providing a lambda to get loaderv3 programdata and providing two interfaces (callback and loader) over the core parsing/loader discrimination logic
  • as-written, per-tx program cache creation does not preserve the delayed visibilty invariant because local changes are not propagated to the global program cache until commit stage, and the creation logic does not check modification slot, it just relies on the global program cache and carryover since the local program cache is typically reused for all transactions. theres an existing mechanism to check modification slot but it forks the global program cache and thus cannot be used

second attempt was to keep the per-batch local program cache and use AccountLoader for the filter step, leaving replenish for another day. however we cannot do this for the same reason we moved away from batched account loading in the first place, it allows loading arbitrarily large accounts with no early abort to size transaction data size checks

the new idea is:

  • change account_cache to a RwLock
  • remove &mut from all methods
  • impl TransactionProcessingCallback for AccountLoader

this lets us change filter_executable_program_accounts() and replenish_program_cache() as we please while preserving bank-friendly type signatures on shared functions

Problem

Summary of Changes

Fixes #

@2501babe 2501babe self-assigned this Jan 29, 2025
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.

1 participant