Skip to content

svm: Add placeholder to AccountLoader for accounts-db miss #7451

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

2501babe
Copy link
Member

Problem

if a transaction loads a non-existant account as read-only, we can store a placeholder in AccountLoader so that future transactions dont have to go to accounts-db again

Summary of Changes

do so. in practice this is not likely to happen much, since in most cases the transaction will want to create it. but it is a small optimization with negligible downside

@2501babe 2501babe self-assigned this Aug 11, 2025
@codecov-commenter
Copy link

codecov-commenter commented Aug 11, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (master@453a73f). Learn more about missing BASE report.

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #7451   +/-   ##
=========================================
  Coverage          ?    83.3%           
=========================================
  Files             ?      801           
  Lines             ?   362825           
  Branches          ?        0           
=========================================
  Hits              ?   302305           
  Misses            ?    60520           
  Partials          ?        0           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@2501babe 2501babe marked this pull request as ready for review August 11, 2025 18:00
@2501babe 2501babe requested a review from a team as a code owner August 11, 2025 18:00
@2501babe 2501babe requested a review from jstarry August 11, 2025 18:00
Lichtso
Lichtso previously approved these changes Aug 11, 2025
Comment on lines 245 to 247
// Does not exist in AccountLoader or accounts-db.
// Insert a placeholder so we don't need to check again.
(None, false) => {
Copy link

Choose a reason for hiding this comment

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

Subsequent calls to load_account for the same non-existent account will always insert a new placeholder. I think the returned bool should indicate "whether an accounts-db load was performed" rather than "whether the account came from accounts-db" and then the impossible branch below becomes the insert branch and this (None, false) branch just returns None as before

Copy link

Choose a reason for hiding this comment

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

That means we are missing a test that the same inputs should result in aliasing outputs.

@2501babe 2501babe marked this pull request as draft August 12, 2025 09:57
@2501babe 2501babe force-pushed the 20250811_skiploadmiss branch from b36f440 to f5fa522 Compare August 12, 2025 10:07
account_loader.load_account(&miss_address);
let actual_miss_account = account_loader.loaded_accounts.get(&hit_address);

assert_eq!(actual_miss_account, Some(&expected_miss_account));
Copy link

Choose a reason for hiding this comment

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

It should probably use Arc::ptr_eq otherwise you just test if the content is the same, not if they are the same object.

@2501babe 2501babe force-pushed the 20250811_skiploadmiss branch from 5a1dfac to a88cf94 Compare August 12, 2025 12:16
Lichtso
Lichtso previously approved these changes Aug 12, 2025
@2501babe
Copy link
Member Author

will rebase again after #7466

@2501babe 2501babe force-pushed the 20250811_skiploadmiss branch from a88cf94 to 4d40722 Compare August 12, 2025 14:03
@2501babe 2501babe marked this pull request as ready for review August 12, 2025 14:54
@2501babe 2501babe requested a review from jstarry August 12, 2025 15:30
jstarry
jstarry previously approved these changes Aug 13, 2025
@2501babe 2501babe dismissed stale reviews from jstarry and Lichtso via 28ff720 August 13, 2025 08:17
@2501babe 2501babe force-pushed the 20250811_skiploadmiss branch from 4d40722 to 28ff720 Compare August 13, 2025 08:17
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.

4 participants