diff --git a/Cargo.lock b/Cargo.lock index f859ba86145cf3..60a024281c7bb6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6665,13 +6665,18 @@ dependencies = [ [[package]] name = "spl-associated-token-account" -version = "1.0.5" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b013067447a1396303ddfc294f36e3d260a32f8a16c501c295bcdc7de39b490" +checksum = "16a33ecc83137583902c3e13c02f34151c8b2f2b74120f9c2b3ff841953e083d" dependencies = [ + "assert_matches", "borsh", + "num-derive", + "num-traits", "solana-program 1.10.33", "spl-token", + "spl-token-2022", + "thiserror", ] [[package]] @@ -6685,9 +6690,9 @@ dependencies = [ [[package]] name = "spl-token" -version = "3.3.1" +version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32d05653bed5932064a287340dbc8a3cb298ee717e5c7ec3353d7cdb9f8fb7e1" +checksum = "8e85e168a785e82564160dcb87b2a8e04cee9bfd1f4d488c729d53d6a4bd300d" dependencies = [ "arrayref", "bytemuck", diff --git a/account-decoder/Cargo.toml b/account-decoder/Cargo.toml index e37ae94a1c99fe..cd12c3859f2658 100644 --- a/account-decoder/Cargo.toml +++ b/account-decoder/Cargo.toml @@ -22,7 +22,7 @@ serde_json = "1.0.81" solana-config-program = { path = "../programs/config", version = "=1.11.6" } solana-sdk = { path = "../sdk", version = "=1.11.6" } solana-vote-program = { path = "../programs/vote", version = "=1.11.6" } -spl-token = { version = "=3.3.1", features = ["no-entrypoint"] } +spl-token = { version = "=3.5.0", features = ["no-entrypoint"] } spl-token-2022 = { version = "=0.4.2", features = ["no-entrypoint"] } thiserror = "1.0" zstd = "0.11.2" diff --git a/accounts-cluster-bench/Cargo.toml b/accounts-cluster-bench/Cargo.toml index a7b45f33f06e87..c08e17976bcf29 100644 --- a/accounts-cluster-bench/Cargo.toml +++ b/accounts-cluster-bench/Cargo.toml @@ -26,7 +26,7 @@ solana-sdk = { path = "../sdk", version = "=1.11.6" } solana-streamer = { path = "../streamer", version = "=1.11.6" } solana-transaction-status = { path = "../transaction-status", version = "=1.11.6" } solana-version = { path = "../version", version = "=1.11.6" } -spl-token = { version = "=3.3.1", features = ["no-entrypoint"] } +spl-token = { version = "=3.5.0", features = ["no-entrypoint"] } [dev-dependencies] solana-core = { path = "../core", version = "=1.11.6" } diff --git a/fetch-spl.sh b/fetch-spl.sh index 542da6af3f1a6f..e608b26a658208 100755 --- a/fetch-spl.sh +++ b/fetch-spl.sh @@ -38,10 +38,10 @@ fetch_program() { } -fetch_program token 3.3.0 TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA BPFLoader2111111111111111111111111111111111 +fetch_program token 3.5.0 TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA BPFLoader2111111111111111111111111111111111 fetch_program memo 1.0.0 Memo1UhkJRfHyvLMcVucJwxXeuD728EqVDDwQDxFMNo BPFLoader1111111111111111111111111111111111 fetch_program memo 3.0.0 MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr BPFLoader2111111111111111111111111111111111 -fetch_program associated-token-account 1.0.5 ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL BPFLoader2111111111111111111111111111111111 +fetch_program associated-token-account 1.1.1 ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL BPFLoader2111111111111111111111111111111111 fetch_program feature-proposal 1.0.0 Feat1YXHhH6t1juaWF74WLcfv4XoNocjXA6sPWHNgAse BPFLoader2111111111111111111111111111111111 echo "${genesis_args[@]}" > spl-genesis-args.sh diff --git a/program-test/src/programs.rs b/program-test/src/programs.rs index f2cfd0e05f07af..f7e2c7e14ec52a 100644 --- a/program-test/src/programs.rs +++ b/program-test/src/programs.rs @@ -18,7 +18,7 @@ mod spl_associated_token_account { } static SPL_PROGRAMS: &[(Pubkey, &[u8])] = &[ - (spl_token::ID, include_bytes!("programs/spl_token-3.3.0.so")), + (spl_token::ID, include_bytes!("programs/spl_token-3.5.0.so")), ( spl_memo_1_0::ID, include_bytes!("programs/spl_memo-1.0.0.so"), @@ -29,7 +29,7 @@ static SPL_PROGRAMS: &[(Pubkey, &[u8])] = &[ ), ( spl_associated_token_account::ID, - include_bytes!("programs/spl_associated_token_account-1.0.5.so"), + include_bytes!("programs/spl_associated_token_account-1.1.1.so"), ), ]; diff --git a/program-test/src/programs/spl_associated_token_account-1.0.5.so b/program-test/src/programs/spl_associated_token_account-1.0.5.so deleted file mode 100755 index 7b360e4cadc854..00000000000000 Binary files a/program-test/src/programs/spl_associated_token_account-1.0.5.so and /dev/null differ diff --git a/program-test/src/programs/spl_associated_token_account-1.1.1.so b/program-test/src/programs/spl_associated_token_account-1.1.1.so new file mode 100644 index 00000000000000..63c3958b2eb60b Binary files /dev/null and b/program-test/src/programs/spl_associated_token_account-1.1.1.so differ diff --git a/program-test/src/programs/spl_token-3.3.0.so b/program-test/src/programs/spl_token-3.3.0.so deleted file mode 100644 index 84098a6a6ac901..00000000000000 Binary files a/program-test/src/programs/spl_token-3.3.0.so and /dev/null differ diff --git a/program-test/src/programs/spl_token-3.5.0.so b/program-test/src/programs/spl_token-3.5.0.so new file mode 100644 index 00000000000000..60cbbeaf6b5542 Binary files /dev/null and b/program-test/src/programs/spl_token-3.5.0.so differ diff --git a/programs/bpf/Cargo.lock b/programs/bpf/Cargo.lock index d95ae7849c394d..6fc3d3c1b42c2c 100644 --- a/programs/bpf/Cargo.lock +++ b/programs/bpf/Cargo.lock @@ -5855,13 +5855,18 @@ dependencies = [ [[package]] name = "spl-associated-token-account" -version = "1.0.5" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b013067447a1396303ddfc294f36e3d260a32f8a16c501c295bcdc7de39b490" +checksum = "16a33ecc83137583902c3e13c02f34151c8b2f2b74120f9c2b3ff841953e083d" dependencies = [ + "assert_matches", "borsh", + "num-derive", + "num-traits", "solana-program 1.10.33", "spl-token", + "spl-token-2022", + "thiserror", ] [[package]] @@ -5875,9 +5880,9 @@ dependencies = [ [[package]] name = "spl-token" -version = "3.3.1" +version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32d05653bed5932064a287340dbc8a3cb298ee717e5c7ec3353d7cdb9f8fb7e1" +checksum = "8e85e168a785e82564160dcb87b2a8e04cee9bfd1f4d488c729d53d6a4bd300d" dependencies = [ "arrayref", "bytemuck", diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index 13afd4bfc177ee..b0b67faf2f60c2 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -49,7 +49,7 @@ solana-streamer = { path = "../streamer", version = "=1.11.6" } solana-transaction-status = { path = "../transaction-status", version = "=1.11.6" } solana-version = { path = "../version", version = "=1.11.6" } solana-vote-program = { path = "../programs/vote", version = "=1.11.6" } -spl-token = { version = "=3.3.1", features = ["no-entrypoint"] } +spl-token = { version = "=3.5.0", features = ["no-entrypoint"] } spl-token-2022 = { version = "=0.4.2", features = ["no-entrypoint"] } stream-cancel = "0.8.1" thiserror = "1.0" diff --git a/tokens/Cargo.toml b/tokens/Cargo.toml index bd72624ff4fcd1..90d43d54ec7082 100644 --- a/tokens/Cargo.toml +++ b/tokens/Cargo.toml @@ -27,8 +27,8 @@ solana-remote-wallet = { path = "../remote-wallet", version = "=1.11.6" } solana-sdk = { path = "../sdk", version = "=1.11.6" } solana-transaction-status = { path = "../transaction-status", version = "=1.11.6" } solana-version = { path = "../version", version = "=1.11.6" } -spl-associated-token-account = { version = "=1.0.5" } -spl-token = { version = "=3.3.1", features = ["no-entrypoint"] } +spl-associated-token-account = { version = "=1.1.1" } +spl-token = { version = "=3.5.0", features = ["no-entrypoint"] } tempfile = "3.3.0" thiserror = "1.0" diff --git a/tokens/src/spl_token.rs b/tokens/src/spl_token.rs index 9ea9d056512014..8d6f4be0a6cc4a 100644 --- a/tokens/src/spl_token.rs +++ b/tokens/src/spl_token.rs @@ -63,6 +63,7 @@ pub fn build_spl_token_instructions( &spl_token_pubkey(&args.fee_payer.pubkey()), &wallet_address, &spl_token_pubkey(&spl_token_args.mint), + &spl_token::id(), ); instructions.push(spl_token_instruction( create_associated_token_account_instruction, diff --git a/transaction-status/Cargo.toml b/transaction-status/Cargo.toml index c1115161dc379a..36798952bce202 100644 --- a/transaction-status/Cargo.toml +++ b/transaction-status/Cargo.toml @@ -26,9 +26,9 @@ solana-metrics = { path = "../metrics", version = "=1.11.6" } solana-runtime = { path = "../runtime", version = "=1.11.6" } solana-sdk = { path = "../sdk", version = "=1.11.6" } solana-vote-program = { path = "../programs/vote", version = "=1.11.6" } -spl-associated-token-account = { version = "=1.0.5", features = ["no-entrypoint"] } +spl-associated-token-account = { version = "=1.1.1", features = ["no-entrypoint"] } spl-memo = { version = "=3.0.1", features = ["no-entrypoint"] } -spl-token = { version = "=3.3.1", features = ["no-entrypoint"] } +spl-token = { version = "=3.5.0", features = ["no-entrypoint"] } spl-token-2022 = { version = "=0.4.2", features = ["no-entrypoint"] } thiserror = "1.0" diff --git a/transaction-status/src/parse_associated_token.rs b/transaction-status/src/parse_associated_token.rs index 955a2bc7a42bbe..1c2cd2c985ef7b 100644 --- a/transaction-status/src/parse_associated_token.rs +++ b/transaction-status/src/parse_associated_token.rs @@ -61,6 +61,35 @@ pub fn parse_associated_token( }), }) } + AssociatedTokenAccountInstruction::CreateIdempotent => { + check_num_associated_token_accounts(&instruction.accounts, 6)?; + Ok(ParsedInstructionEnum { + instruction_type: "createIdempotent".to_string(), + info: json!({ + "source": account_keys[instruction.accounts[0] as usize].to_string(), + "account": account_keys[instruction.accounts[1] as usize].to_string(), + "wallet": account_keys[instruction.accounts[2] as usize].to_string(), + "mint": account_keys[instruction.accounts[3] as usize].to_string(), + "systemProgram": account_keys[instruction.accounts[4] as usize].to_string(), + "tokenProgram": account_keys[instruction.accounts[5] as usize].to_string(), + }), + }) + } + AssociatedTokenAccountInstruction::RecoverNested => { + check_num_associated_token_accounts(&instruction.accounts, 7)?; + Ok(ParsedInstructionEnum { + instruction_type: "recoverNested".to_string(), + info: json!({ + "nestedSource": account_keys[instruction.accounts[0] as usize].to_string(), + "nestedMint": account_keys[instruction.accounts[1] as usize].to_string(), + "destination": account_keys[instruction.accounts[2] as usize].to_string(), + "nestedOwner": account_keys[instruction.accounts[3] as usize].to_string(), + "ownerMint": account_keys[instruction.accounts[4] as usize].to_string(), + "wallet": account_keys[instruction.accounts[5] as usize].to_string(), + "tokenProgram": account_keys[instruction.accounts[6] as usize].to_string(), + }), + }) + } } } } @@ -80,8 +109,11 @@ mod test { super::*, solana_account_decoder::parse_token::pubkey_from_spl_token, spl_associated_token_account::{ - get_associated_token_address, - instruction::create_associated_token_account, + get_associated_token_address, get_associated_token_address_with_program_id, + instruction::{ + create_associated_token_account, create_associated_token_account_idempotent, + recover_nested, + }, solana_program::{ instruction::CompiledInstruction as SplAssociatedTokenCompiledInstruction, message::Message, pubkey::Pubkey as SplAssociatedTokenPubkey, sysvar, @@ -112,7 +144,7 @@ mod test { } #[test] - fn test_parse_associated_token_deprecated() { + fn test_parse_create_deprecated() { let funder = Pubkey::new_unique(); let wallet_address = Pubkey::new_unique(); let mint = Pubkey::new_unique(); @@ -154,16 +186,21 @@ mod test { } #[test] - fn test_parse_associated_token() { + fn test_parse_create() { let funder = Pubkey::new_unique(); let wallet_address = Pubkey::new_unique(); let mint = Pubkey::new_unique(); - let associated_account_address = - get_associated_token_address(&convert_pubkey(wallet_address), &convert_pubkey(mint)); + let token_program_id = Pubkey::new_unique(); + let associated_account_address = get_associated_token_address_with_program_id( + &convert_pubkey(wallet_address), + &convert_pubkey(mint), + &convert_pubkey(token_program_id), + ); let create_ix = create_associated_token_account( &convert_pubkey(funder), &convert_pubkey(wallet_address), &convert_pubkey(mint), + &convert_pubkey(token_program_id), ); let message = Message::new(&[create_ix], None); let mut compiled_instruction = convert_compiled_instruction(&message.instructions[0]); @@ -181,7 +218,108 @@ mod test { "wallet": wallet_address.to_string(), "mint": mint.to_string(), "systemProgram": solana_sdk::system_program::id().to_string(), - "tokenProgram": spl_token::id().to_string(), + "tokenProgram": token_program_id.to_string(), + }) + } + ); + compiled_instruction.accounts.pop(); + assert!(parse_associated_token( + &compiled_instruction, + &AccountKeys::new(&convert_account_keys(&message), None) + ) + .is_err()); + } + + #[test] + fn test_parse_create_idempotent() { + let funder = Pubkey::new_unique(); + let wallet_address = Pubkey::new_unique(); + let mint = Pubkey::new_unique(); + let token_program_id = Pubkey::new_unique(); + let associated_account_address = get_associated_token_address_with_program_id( + &convert_pubkey(wallet_address), + &convert_pubkey(mint), + &convert_pubkey(token_program_id), + ); + let create_ix = create_associated_token_account_idempotent( + &convert_pubkey(funder), + &convert_pubkey(wallet_address), + &convert_pubkey(mint), + &convert_pubkey(token_program_id), + ); + let message = Message::new(&[create_ix], None); + let mut compiled_instruction = convert_compiled_instruction(&message.instructions[0]); + assert_eq!( + parse_associated_token( + &compiled_instruction, + &AccountKeys::new(&convert_account_keys(&message), None) + ) + .unwrap(), + ParsedInstructionEnum { + instruction_type: "createIdempotent".to_string(), + info: json!({ + "source": funder.to_string(), + "account": associated_account_address.to_string(), + "wallet": wallet_address.to_string(), + "mint": mint.to_string(), + "systemProgram": solana_sdk::system_program::id().to_string(), + "tokenProgram": token_program_id.to_string(), + }) + } + ); + compiled_instruction.accounts.pop(); + assert!(parse_associated_token( + &compiled_instruction, + &AccountKeys::new(&convert_account_keys(&message), None) + ) + .is_err()); + } + + #[test] + fn test_parse_recover_nested() { + let wallet_address = Pubkey::new_unique(); + let owner_mint = Pubkey::new_unique(); + let nested_mint = Pubkey::new_unique(); + let token_program_id = Pubkey::new_unique(); + let owner_associated_account_address = get_associated_token_address_with_program_id( + &convert_pubkey(wallet_address), + &convert_pubkey(owner_mint), + &convert_pubkey(token_program_id), + ); + let nested_associated_account_address = get_associated_token_address_with_program_id( + &owner_associated_account_address, + &convert_pubkey(nested_mint), + &convert_pubkey(token_program_id), + ); + let destination_associated_account_address = get_associated_token_address_with_program_id( + &convert_pubkey(wallet_address), + &convert_pubkey(nested_mint), + &convert_pubkey(token_program_id), + ); + let recover_ix = recover_nested( + &convert_pubkey(wallet_address), + &convert_pubkey(owner_mint), + &convert_pubkey(nested_mint), + &convert_pubkey(token_program_id), + ); + let message = Message::new(&[recover_ix], None); + let mut compiled_instruction = convert_compiled_instruction(&message.instructions[0]); + assert_eq!( + parse_associated_token( + &compiled_instruction, + &AccountKeys::new(&convert_account_keys(&message), None) + ) + .unwrap(), + ParsedInstructionEnum { + instruction_type: "recoverNested".to_string(), + info: json!({ + "nestedSource": nested_associated_account_address.to_string(), + "nestedMint": nested_mint.to_string(), + "destination": destination_associated_account_address.to_string(), + "nestedOwner": owner_associated_account_address.to_string(), + "ownerMint": owner_mint.to_string(), + "wallet": wallet_address.to_string(), + "tokenProgram": token_program_id.to_string(), }) } );