Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.
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 @@ -728,6 +728,10 @@ pub mod disable_rent_fees_collection {
solana_sdk::declare_id!("CJzY83ggJHqPGDq8VisV3U91jDJLuEaALZooBrXtnnLU");
}

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 @@ -905,6 +909,7 @@ lazy_static! {
(update_hashes_per_tick6::id(), "Update desired hashes per tick to 10M"),
(validate_fee_collector_account::id(), "validate fee collector account #33888"),
(disable_rent_fees_collection::id(), "Disable rent fees collection #33945"),
(enable_zk_transfer_with_fee::id(), "enable Zk Token proof program transfer with fee"),
/*************** ADD NEW FEATURES HERE ***************/
]
.iter()
Expand Down