Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 18 additions & 15 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ members = [
"geyser-plugin-interface",
"geyser-plugin-manager",
"gossip",
"inline-spl",
"install",
"keygen",
"lattice-hash",
Expand Down Expand Up @@ -450,7 +449,6 @@ solana-gossip = { path = "gossip", version = "=2.3.0" }
solana-hard-forks = "2.2.1"
solana-hash = "2.2.1"
solana-inflation = "2.2.1"
solana-inline-spl = { path = "inline-spl", version = "=2.3.0" }
solana-instruction = "2.2.1"
solana-instructions-sysvar = "2.2.1"
solana-keccak-hasher = "2.2.1"
Expand Down Expand Up @@ -577,6 +575,7 @@ solana-zk-sdk = { path = "zk-sdk", version = "=2.3.0" }
solana-zk-token-proof-program = { path = "programs/zk-token-proof", version = "=2.3.0" }
solana-zk-token-sdk = { path = "zk-token-sdk", version = "=2.3.0" }
spl-associated-token-account = "=6.0.0"
spl-generic-token = "1.0.1"
spl-instruction-padding = "0.3"
spl-memo = "=6.0.0"
spl-pod = "=0.5.1"
Expand Down
1 change: 1 addition & 0 deletions account-decoder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ solana-slot-history = { workspace = true }
solana-stake-interface = { workspace = true }
solana-sysvar = { workspace = true }
solana-vote-interface = { workspace = true, features = ["bincode"] }
spl-generic-token = { workspace = true }
spl-token = { workspace = true, features = ["no-entrypoint"] }
spl-token-2022 = { workspace = true, features = ["no-entrypoint"] }
spl-token-group-interface = { workspace = true }
Expand Down
21 changes: 7 additions & 14 deletions account-decoder/src/parse_token.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
pub use solana_account_decoder_client_types::token::{
real_number_string, real_number_string_trimmed, TokenAccountType, UiAccountState, UiMint,
UiMultisig, UiTokenAccount, UiTokenAmount,
};
use {
crate::{
parse_account_data::{
Expand All @@ -19,16 +15,13 @@ use {
},
std::str::FromStr,
};

// Returns all known SPL Token program ids
pub fn spl_token_ids() -> Vec<Pubkey> {
vec![spl_token::id(), spl_token_2022::id()]
}

// Check if the provided program id as a known SPL Token program id
pub fn is_known_spl_token_id(program_id: &Pubkey) -> bool {
*program_id == spl_token::id() || *program_id == spl_token_2022::id()
}
pub use {
solana_account_decoder_client_types::token::{
real_number_string, real_number_string_trimmed, TokenAccountType, UiAccountState, UiMint,
UiMultisig, UiTokenAccount, UiTokenAmount,
},
spl_generic_token::{is_known_spl_token_id, spl_token_ids},
};
Comment on lines +18 to +24
Copy link
Member Author

Choose a reason for hiding this comment

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

we pub use these to avoid a breaking change because solana-account-decoder is a crate that (unlike solana-inline-spl) is very reasonable for downstream projects to include


#[deprecated(since = "2.0.0", note = "Use `parse_token_v3` instead")]
#[allow(deprecated)]
Expand Down
2 changes: 1 addition & 1 deletion accounts-cluster-bench/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ solana-clap-utils = { workspace = true }
solana-cli-config = { workspace = true }
solana-client = { workspace = true }
solana-gossip = { workspace = true }
solana-inline-spl = { workspace = true }
solana-logger = { workspace = true }
solana-measure = { workspace = true }
solana-net-utils = { workspace = true }
Expand All @@ -29,6 +28,7 @@ solana-sdk = { workspace = true }
solana-streamer = { workspace = true }
solana-transaction-status = { workspace = true }
solana-version = { workspace = true }
spl-generic-token = { workspace = true }
spl-token = { workspace = true, features = ["no-entrypoint"] }

[dev-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion accounts-cluster-bench/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ use {
rpc_request::MAX_GET_CONFIRMED_BLOCKS_RANGE, transaction_executor::TransactionExecutor,
},
solana_gossip::gossip_service::discover,
solana_inline_spl::token,
solana_measure::measure::Measure,
solana_rpc_client::rpc_client::RpcClient,
solana_rpc_client_api::request::TokenAccountsFilter,
Expand All @@ -31,6 +30,7 @@ use {
},
solana_streamer::socket::SocketAddrSpace,
solana_transaction_status::UiTransactionEncoding,
spl_generic_token::token,
spl_token::state::Account,
std::{
cmp::min,
Expand Down
2 changes: 1 addition & 1 deletion accounts-db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ solana-frozen-abi-macro = { workspace = true, optional = true, features = [
] }
solana-genesis-config = { workspace = true, features = ["serde"] }
solana-hash = { workspace = true, features = ["serde"] }
solana-inline-spl = { workspace = true }
solana-keypair = { workspace = true, optional = true }
solana-lattice-hash = { workspace = true }
solana-measure = { workspace = true }
Expand All @@ -76,6 +75,7 @@ solana-transaction = { workspace = true }
solana-transaction-context = { workspace = true }
solana-transaction-error = { workspace = true }
solana-vote-program = { workspace = true, optional = true }
spl-generic-token = { workspace = true }
static_assertions = { workspace = true }
tar = { workspace = true }
tempfile = { workspace = true }
Expand Down
8 changes: 5 additions & 3 deletions accounts-db/src/accounts_db/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1848,15 +1848,17 @@ fn test_clean_old_with_both_normal_and_zero_lamport_accounts() {
let pubkey2 = solana_pubkey::new_rand();

// Set up account to be added to secondary index
const SPL_TOKEN_INITIALIZED_OFFSET: usize = 108;
let mint_key = Pubkey::new_unique();
let mut account_data_with_mint = vec![0; solana_inline_spl::token::Account::get_packed_len()];
let mut account_data_with_mint = vec![0; spl_generic_token::token::Account::get_packed_len()];
account_data_with_mint[..PUBKEY_BYTES].clone_from_slice(&(mint_key.to_bytes()));
account_data_with_mint[SPL_TOKEN_INITIALIZED_OFFSET] = 1;

let mut normal_account = AccountSharedData::new(1, 0, AccountSharedData::default().owner());
normal_account.set_owner(solana_inline_spl::token::id());
normal_account.set_owner(spl_generic_token::token::id());
normal_account.set_data(account_data_with_mint.clone());
let mut zero_account = AccountSharedData::new(0, 0, AccountSharedData::default().owner());
zero_account.set_owner(solana_inline_spl::token::id());
zero_account.set_owner(spl_generic_token::token::id());
zero_account.set_data(account_data_with_mint);

//store an account
Expand Down
32 changes: 15 additions & 17 deletions accounts-db/src/accounts_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1219,7 +1219,7 @@ impl<T: IndexValue, U: DiskIndexValue + From<T> + Into<T>> AccountsIndex<T, U> {
.unwrap_or(0)
}

fn update_spl_token_secondary_indexes<G: solana_inline_spl::token::GenericTokenAccount>(
fn update_spl_token_secondary_indexes<G: spl_generic_token::token::GenericTokenAccount>(
Copy link
Member Author

Choose a reason for hiding this comment

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

@brooksprumo we talked about this in dms and agreed its fine from a consensus perspective since it only affects rpc but if you could sign off on this

specifically, the new token account parser is more strict and requires token accounts to have been initialized (ie initialized or frozen states). the changed tests show the effect this has. this is a straightforward bugfix, so this is correct to do, and correct to do with no feature gate if the secondary indexes are not used for runtime account loading

Choose a reason for hiding this comment

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

Looks good to me, thanks for the fix!

&self,
token_id: &Pubkey,
pubkey: &Pubkey,
Expand Down Expand Up @@ -1310,15 +1310,15 @@ impl<T: IndexValue, U: DiskIndexValue + From<T> + Into<T>> AccountsIndex<T, U> {
// (as persisted tombstone for snapshots). This will then ultimately be
// filtered out by post-scan filters, like in `get_filtered_spl_token_accounts_by_owner()`.

self.update_spl_token_secondary_indexes::<solana_inline_spl::token::Account>(
&solana_inline_spl::token::id(),
self.update_spl_token_secondary_indexes::<spl_generic_token::token::Account>(
&spl_generic_token::token::id(),
pubkey,
account_owner,
account_data,
account_indexes,
);
self.update_spl_token_secondary_indexes::<solana_inline_spl::token_2022::Account>(
&solana_inline_spl::token_2022::id(),
self.update_spl_token_secondary_indexes::<spl_generic_token::token_2022::Account>(
&spl_generic_token::token_2022::id(),
pubkey,
account_owner,
account_data,
Expand Down Expand Up @@ -1752,19 +1752,14 @@ pub mod tests {
crate::bucket_map_holder::{AtomicAge, BucketMapHolder},
account_map_entry::AccountMapEntryMeta,
solana_account::{AccountSharedData, WritableAccount},
solana_inline_spl::token::SPL_TOKEN_ACCOUNT_OWNER_OFFSET,
solana_pubkey::PUBKEY_BYTES,
spl_generic_token::{spl_token_ids, token::SPL_TOKEN_ACCOUNT_OWNER_OFFSET},
std::ops::{
Bound::{Excluded, Included, Unbounded},
RangeInclusive,
},
};

const SPL_TOKENS: &[Pubkey] = &[
solana_inline_spl::token::id(),
solana_inline_spl::token_2022::id(),
];

pub enum SecondaryIndexTypes<'a> {
RwLock(&'a SecondaryIndex<RwLockSecondaryIndexEntry>),
DashMap(&'a SecondaryIndex<DashMapSecondaryIndexEntry>),
Expand Down Expand Up @@ -3055,7 +3050,10 @@ pub mod tests {
}

fn make_empty_token_account_data() -> Vec<u8> {
vec![0; solana_inline_spl::token::Account::get_packed_len()]
const SPL_TOKEN_INITIALIZED_OFFSET: usize = 108;
let mut data = vec![0; spl_generic_token::token::Account::get_packed_len()];
data[SPL_TOKEN_INITIALIZED_OFFSET] = 1;
data
}

fn run_test_purge_exact_secondary_index<
Expand Down Expand Up @@ -3085,7 +3083,7 @@ pub mod tests {
&AccountSharedData::create(
0,
account_data.to_vec(),
solana_inline_spl::token::id(),
spl_generic_token::token::id(),
false,
0,
),
Expand Down Expand Up @@ -3347,7 +3345,7 @@ pub mod tests {
fn test_spl_token_mint_secondary_index() {
let (key_start, key_end, secondary_indexes) = create_spl_token_mint_secondary_index_state();
let index = AccountsIndex::<bool, bool>::default_for_tests();
for token_id in SPL_TOKENS {
for token_id in &spl_token_ids() {
run_test_spl_token_secondary_indexes(
token_id,
&index,
Expand All @@ -3364,7 +3362,7 @@ pub mod tests {
let (key_start, key_end, secondary_indexes) =
create_spl_token_owner_secondary_index_state();
let index = AccountsIndex::<bool, bool>::default_for_tests();
for token_id in SPL_TOKENS {
for token_id in &spl_token_ids() {
run_test_spl_token_secondary_indexes(
token_id,
&index,
Expand Down Expand Up @@ -3469,7 +3467,7 @@ pub mod tests {
fn test_spl_token_mint_secondary_index_same_slot_and_forks() {
let (key_start, key_end, account_index) = create_spl_token_mint_secondary_index_state();
let index = AccountsIndex::<bool, bool>::default_for_tests();
for token_id in SPL_TOKENS {
for token_id in &spl_token_ids() {
run_test_secondary_indexes_same_slot_and_forks(
token_id,
&index,
Expand All @@ -3485,7 +3483,7 @@ pub mod tests {
fn test_rwlock_secondary_index_same_slot_and_forks() {
let (key_start, key_end, account_index) = create_spl_token_owner_secondary_index_state();
let index = AccountsIndex::<bool, bool>::default_for_tests();
for token_id in SPL_TOKENS {
for token_id in &spl_token_ids() {
run_test_secondary_indexes_same_slot_and_forks(
token_id,
&index,
Expand Down
Loading
Loading