forked from solana-labs/solana
-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Manually add lookup table addresses instead of sanitizing (solana-lab…
- Loading branch information
Showing
5 changed files
with
110 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
use { | ||
bincode::deserialize, | ||
lazy_static::lazy_static, | ||
solana_sdk::{ | ||
address_lookup_table::{self, instruction::ProgramInstruction}, | ||
pubkey::Pubkey, | ||
sdk_ids::SDK_IDS, | ||
transaction::SanitizedVersionedTransaction, | ||
}, | ||
std::collections::HashSet, | ||
}; | ||
|
||
lazy_static! { | ||
static ref SDK_IDS_SET: HashSet<Pubkey> = SDK_IDS.iter().cloned().collect(); | ||
} | ||
|
||
pub struct ScannedLookupTableExtensions { | ||
pub possibly_incomplete: bool, | ||
pub accounts: Vec<Pubkey>, // empty if no extensions found | ||
} | ||
|
||
pub fn scan_transaction( | ||
transaction: &SanitizedVersionedTransaction, | ||
) -> ScannedLookupTableExtensions { | ||
// Accumulate accounts from account lookup table extension instructions | ||
let mut accounts = Vec::new(); | ||
let mut native_only = true; | ||
for (program_id, instruction) in transaction.get_message().program_instructions_iter() { | ||
if address_lookup_table::program::check_id(program_id) { | ||
if let Ok(ProgramInstruction::ExtendLookupTable { new_addresses }) = | ||
deserialize::<ProgramInstruction>(&instruction.data) | ||
{ | ||
accounts.extend(new_addresses); | ||
} | ||
} else { | ||
native_only &= SDK_IDS_SET.contains(program_id); | ||
} | ||
} | ||
|
||
ScannedLookupTableExtensions { | ||
possibly_incomplete: !native_only, | ||
accounts, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters