LiteSVM / litesvm

Apache License 2.0
68 stars 11 forks source link

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

Closed kevinheavey closed 5 months ago

kevinheavey commented 5 months ago

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);
        }
    }