1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
use {
    super::Bank,
    crate::accounts_db::LoadZeroLamports,
    solana_address_lookup_table_program::error::AddressLookupError,
    solana_sdk::{
        feature_set::return_none_for_zero_lamport_accounts,
        message::{
            v0::{LoadedAddresses, MessageAddressTableLookup},
            AddressLoaderError,
        },
        transaction::AddressLoader,
    },
};

impl AddressLoader for &Bank {
    fn load_addresses(
        self,
        address_table_lookups: &[MessageAddressTableLookup],
    ) -> Result<LoadedAddresses, AddressLoaderError> {
        if !self.versioned_tx_message_enabled() {
            return Err(AddressLoaderError::Disabled);
        }

        let load_zero_lamports = if self
            .feature_set
            .is_active(&return_none_for_zero_lamport_accounts::id())
        {
            LoadZeroLamports::None
        } else {
            LoadZeroLamports::SomeWithZeroLamportAccount
        };

        let slot_hashes = self
            .sysvar_cache
            .read()
            .unwrap()
            .get_slot_hashes()
            .map_err(|_| AddressLoaderError::SlotHashesSysvarNotFound)?;

        Ok(address_table_lookups
            .iter()
            .map(|address_table_lookup| {
                self.rc.accounts.load_lookup_table_addresses(
                    &self.ancestors,
                    address_table_lookup,
                    &slot_hashes,
                    load_zero_lamports,
                )
            })
            .collect::<Result<_, AddressLookupError>>()?)
    }
}