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
6 changes: 6 additions & 0 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ tag-message = "Publish {{crate_name}} v{{version}}"
consolidate-commits = false

[workspace.dependencies]
mollusk-svm = "0.4.0"
mollusk-svm-fuzz-fixture = "0.4.0"
num-traits = "0.2"
pinocchio = "0.9"
solana-instruction = "2.3.0"
Expand Down
6 changes: 6 additions & 0 deletions p-token/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,21 @@ pinocchio-log = { version = "0.5", default-features = false }
pinocchio-token-interface = { version = "^0", path = "../p-interface" }

[dev-dependencies]
agave-feature-set = "2.2.20"
assert_matches = "1.5.0"
mollusk-svm = { workspace = true }
mollusk-svm-fuzz-fixture = { workspace = true }
num-traits = { workspace = true }
solana-account = "2.2.1"
solana-instruction = { workspace = true }
solana-keypair = "2.2.3"
solana-program-error = { workspace = true }
solana-program-option = { workspace = true }
solana-program-pack = { workspace = true }
solana-program-test = "2.3.4"
solana-pubkey = { workspace = true }
solana-rent = "2.2.1"
solana-sdk-ids = "2.2.1"
solana-signature = "2.3.0"
solana-signer = "2.2.1"
solana-transaction = "2.2.3"
Expand Down
50 changes: 49 additions & 1 deletion p-token/src/processor/batch.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use {
crate::entrypoint::inner_process_instruction,
crate::{entrypoint::inner_process_instruction, processor::check_account_owner},
pinocchio::{account_info::AccountInfo, program_error::ProgramError, ProgramResult},
pinocchio_token_interface::error::TokenError,
};
Expand Down Expand Up @@ -46,6 +46,54 @@ pub fn process_batch(mut accounts: &[AccountInfo], mut instruction_data: &[u8])
)
};

// Few Instructions require specific account ownership checks when executed
// in a batch since ownership is only enforced by the runtime at the end of
// the batch processing.
//
// Instructions that do not appear in the list below do not require
// ownership checks since they either do not modify accounts or the ownership
// is already checked explicitly.
if let Some(&discriminator) = ix_data.first() {
match discriminator {
// 3 - Transfer
// 7 - MintTo
// 8 - Burn
// 14 - MintToChecked
// 15 - BurnChecked
3 | 7 | 8 | 14 | 15 => {
let [a0, a1, ..] = ix_accounts else {
return Err(ProgramError::NotEnoughAccountKeys);
};
check_account_owner(a0)?;
check_account_owner(a1)?;
}
// 12 - TransferChecked
12 => {
let [a0, _, a2, ..] = ix_accounts else {
return Err(ProgramError::NotEnoughAccountKeys);
};
check_account_owner(a0)?;
check_account_owner(a2)?;
}
// 4 - Approve
// 5 - Revoke
// 6 - SetAuthority
// 9 - CloseAccount
// 10 - FreezeAccount
// 11 - ThawAccount
// 13 - ApproveChecked
// 22 - InitializeImmutableOwner
// 38 - WithdrawExcessLamports
4..=13 | 22 | 38 => {
let [a0, ..] = ix_accounts else {
return Err(ProgramError::NotEnoughAccountKeys);
};
check_account_owner(a0)?;
}
_ => {}
}
}

inner_process_instruction(ix_accounts, ix_data)?;

if data_offset == instruction_data.len() {
Expand Down
Loading