-
Notifications
You must be signed in to change notification settings - Fork 261
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
runtime: simplify account saver filter #2992
Conversation
honestly i thought it was a me problem for a bit that i needed to write out in words what this did every time i read it, but then i remembered a conversation a couple weeks ago where myself and the other person discussed this function for several minutes only to realize we both had it backwards |
runtime/src/account_saver.rs
Outdated
} | ||
}) | ||
{ | ||
for (i, (address, account)) in transaction_accounts.iter().enumerate() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to limit the iteration to transaction.account_keys().len()
because transaction_accounts
includes some appended program accounts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
youre right, thank you for catching that
unrelated to this pr, but do you know a reason i might have missed re: why we would need to append them? the extra loaders added in load_transaction_accounts()
, which i believe is the only place accounts are added. i forgot we do it because i havent been doing it in my new account loader, and it doesnt seem to cause any problems in testing. ProgramCacheForTxBatch
is populated with all builtins and as best i can tell invoke context always gets loaders from there
(to be clear i still count them against data size limits)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not exactly sure at this point whether it's necessary to append them or not. The program cache came later so it's very possible it alleviates the need to do this unintuitive appending behavior.
Problem
negation inside a bracketed OR makes the filter predicate used to select what accounts need to be saved unusually difficult to understand for what is essentially one line of code
Summary of Changes
rewrite in a more straightforward imperative style. the logic itself is unchanged