Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

v1.17: [zk-token-proof] Feature gate transfer with fee related proofs (backport of #34103) #34129

Merged
merged 2 commits into from
Nov 17, 2023
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
15 changes: 15 additions & 0 deletions programs/zk-token-proof/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ declare_process_instruction!(Entrypoint, 0, |invoke_context| {
let native_programs_consume_cu = invoke_context
.feature_set
.is_active(&feature_set::native_programs_consume_cu::id());

let enable_zk_transfer_with_fee = invoke_context
.feature_set
.is_active(&feature_set::enable_zk_transfer_with_fee::id());

let transaction_context = &invoke_context.transaction_context;
let instruction_context = transaction_context.get_current_instruction_context()?;
let instruction_data = instruction_context.get_instruction_data();
Expand Down Expand Up @@ -198,6 +203,11 @@ declare_process_instruction!(Entrypoint, 0, |invoke_context| {
process_verify_proof::<TransferData, TransferProofContext>(invoke_context)
}
ProofInstruction::VerifyTransferWithFee => {
// transfer with fee related proofs are not enabled
if !enable_zk_transfer_with_fee {
return Err(InstructionError::InvalidInstructionData);
}

if native_programs_consume_cu {
invoke_context
.consume_checked(VERIFY_TRANSFER_WITH_FEE_COMPUTE_UNITS)
Expand Down Expand Up @@ -291,6 +301,11 @@ declare_process_instruction!(Entrypoint, 0, |invoke_context| {
>(invoke_context)
}
ProofInstruction::VerifyFeeSigma => {
// transfer with fee related proofs are not enabled
if !enable_zk_transfer_with_fee {
return Err(InstructionError::InvalidInstructionData);
}

invoke_context
.consume_checked(VERIFY_FEE_SIGMA_COMPUTE_UNITS)
.map_err(|_| InstructionError::ComputationalBudgetExceeded)?;
Expand Down
5 changes: 5 additions & 0 deletions sdk/src/feature_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,10 @@ pub mod validate_fee_collector_account {
solana_sdk::declare_id!("prpFrMtgNmzaNzkPJg9o753fVvbHKqNrNTm76foJ2wm");
}

pub mod enable_zk_transfer_with_fee {
solana_sdk::declare_id!("zkNLP7EQALfC1TYeB3biDU7akDckj8iPkvh9y2Mt2K3");
}

lazy_static! {
/// Map of feature identifiers to user-visible description
pub static ref FEATURE_NAMES: HashMap<Pubkey, &'static str> = [
Expand Down Expand Up @@ -900,6 +904,7 @@ lazy_static! {
(update_hashes_per_tick5::id(), "Update desired hashes per tick to 9.2M"),
(update_hashes_per_tick6::id(), "Update desired hashes per tick to 10M"),
(validate_fee_collector_account::id(), "validate fee collector account #33888"),
(enable_zk_transfer_with_fee::id(), "enable Zk Token proof program transfer with fee"),
/*************** ADD NEW FEATURES HERE ***************/
]
.iter()
Expand Down