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

Update the program cache whenever an executable account is created/updated #19

Merged
merged 3 commits into from
Mar 14, 2024

Conversation

kevinheavey
Copy link
Collaborator

Turned out to be trickier than I expected because of an edge case with bpf_loader_upgradeable that forced me to do this:

    pub(crate) fn sync_accounts(&mut self, mut accounts: Vec<(Pubkey, AccountSharedData)>) {
        // need to add programdata accounts first if there are any
        itertools::partition(&mut accounts, |x| {
            x.1.owner() == &bpf_loader_upgradeable::id()
                && x.1.data().get(0).map_or(false, |byte| *byte == 3)
        });
        for (pubkey, acc) in accounts {
            self.add_account(pubkey, acc);
        }
    }

@kevinheavey kevinheavey requested a review from Aursen March 11, 2024 21:12
Copy link
Collaborator

@Aursen Aursen left a comment

Choose a reason for hiding this comment

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

Thanks for the PR. We can discuss more about on Discord if you need

Cargo.toml Show resolved Hide resolved

let owner = program_account.owner();
let program_runtime_v1 = self.programs_cache.environments.program_runtime_v1.clone();
let clock_acc = self.get_account(&sysvar::clock::ID);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why are you using the clock here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

To get the current slot which is needed further down

Copy link
Collaborator

Choose a reason for hiding this comment

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

You can't get it from the bank?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We don't have access to the bank in this method

src/accounts_db.rs Show resolved Hide resolved
@kevinheavey kevinheavey merged commit 41ff997 into master Mar 14, 2024
2 checks passed
@kevinheavey kevinheavey deleted the handle-program-upgrades branch March 14, 2024 20:30
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