Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[zk-token-proof] Enable proof program to be invoked as an inner call #33045

Merged
merged 1 commit into from
Aug 30, 2023
Merged
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
12 changes: 7 additions & 5 deletions programs/zk-token-proof/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,6 @@ fn process_close_proof_context(invoke_context: &mut InvokeContext) -> Result<(),
}

declare_process_instruction!(process_instruction, 0, |invoke_context| {
if invoke_context.get_stack_height() != TRANSACTION_LEVEL_STACK_HEIGHT {
// Not supported as an inner instruction
return Err(InstructionError::UnsupportedProgramId);
}

// Consume compute units if feature `native_programs_consume_cu` is activated
let native_programs_consume_cu = invoke_context
.feature_set
Expand All @@ -130,6 +125,13 @@ declare_process_instruction!(process_instruction, 0, |invoke_context| {
let instruction = ProofInstruction::instruction_type(instruction_data)
.ok_or(InstructionError::InvalidInstructionData)?;

if invoke_context.get_stack_height() != TRANSACTION_LEVEL_STACK_HEIGHT
&& instruction != ProofInstruction::CloseContextState
{
// Proof verification instructions are not supported as an inner instruction
return Err(InstructionError::UnsupportedProgramId);
}

match instruction {
ProofInstruction::CloseContextState => {
ic_msg!(invoke_context, "CloseContextState");
Expand Down