diff --git a/synthesizer/process/src/stack/execute.rs b/synthesizer/process/src/stack/execute.rs index 521619599e..9b91c95c5a 100644 --- a/synthesizer/process/src/stack/execute.rs +++ b/synthesizer/process/src/stack/execute.rs @@ -45,8 +45,15 @@ impl StackExecute for Stack { // Initialize the registers. let mut registers = Registers::new(call_stack, self.get_register_types(closure.name())?.clone()); + + use circuit::Eject; + + // Set the transaction signer. + registers.set_signer(signer.eject_value()); // Set the transition signer, as a circuit. registers.set_signer_circuit(signer); + // Set the transaction caller. + registers.set_caller(caller.eject_value()); // Set the transition caller, as a circuit. registers.set_caller_circuit(caller); // Set the transition view key, as a circuit. @@ -57,7 +64,6 @@ impl StackExecute for Stack { closure.inputs().iter().map(|i| i.register()).zip_eq(inputs).try_for_each(|(register, input)| { // If the circuit is in execute mode, then store the console input. if let CallStack::Execute(..) = registers.call_stack() { - use circuit::Eject; // Assign the console input to the register. registers.store(self, register, input.eject_value())?; } diff --git a/synthesizer/tests/expectations/vm/execute_and_finalize/self_caller_and_signer_in_closure.out b/synthesizer/tests/expectations/vm/execute_and_finalize/self_caller_and_signer_in_closure.out new file mode 100644 index 0000000000..4b4861ccbe --- /dev/null +++ b/synthesizer/tests/expectations/vm/execute_and_finalize/self_caller_and_signer_in_closure.out @@ -0,0 +1,24 @@ +errors: [] +outputs: +- verified: true + execute: + self_caller_in_closure.aleo/dummy: + outputs: + - '{"type":"private","id":"2216227416503041347433412034872956491846811102146440372685849103494739704020field","value":"ciphertext1qyqya6k83s309kj2l82tj5fr80n7e7w7t56ff72ug8ueqhqzevn2vys72rsev"}' + speculate: the execution was accepted + add_next_block: succeeded. +- verified: true + execute: + self_caller_in_closure.aleo/run_check: + outputs: [] + speculate: the execution was accepted + add_next_block: succeeded. +additional: +- child_outputs: + credits.aleo/fee_public: + outputs: + - '{"type":"future","id":"7718771598168275830568214808516419506185731287938173896061440207543931919734field","value":"{\n program_id: credits.aleo,\n function_name: fee_public,\n arguments: [\n aleo1gj8900ftrtm5gpjljk9tuv8tmr46m88s5dvugdx8hnmftvpfv5rqempqfd,\n 1334u64\n ]\n}"}' +- child_outputs: + credits.aleo/fee_public: + outputs: + - '{"type":"future","id":"3733678765361147903053791676426696003831360239303256048750709990852510369243field","value":"{\n program_id: credits.aleo,\n function_name: fee_public,\n arguments: [\n aleo1gj8900ftrtm5gpjljk9tuv8tmr46m88s5dvugdx8hnmftvpfv5rqempqfd,\n 1161u64\n ]\n}"}' diff --git a/synthesizer/tests/tests/vm/execute_and_finalize/self_caller_and_signer_in_closure.aleo b/synthesizer/tests/tests/vm/execute_and_finalize/self_caller_and_signer_in_closure.aleo new file mode 100644 index 0000000000..20f053b903 --- /dev/null +++ b/synthesizer/tests/tests/vm/execute_and_finalize/self_caller_and_signer_in_closure.aleo @@ -0,0 +1,30 @@ +/* +randomness: 63249871089234 +cases: + - program: self_caller_in_closure.aleo + function: dummy + inputs: [1u32, 2u32] + - program: self_caller_in_closure.aleo + function: run_check + inputs: [] +*/ + +program self_caller_in_closure.aleo; + +closure check_caller: + input r0 as address; + assert.eq self.caller r0; + +closure check_signer: + input r0 as address; + assert.eq self.signer r0; + +function run_check: + call check_caller self.caller; + call check_signer self.signer; + +function dummy: + input r0 as u32.public; + input r1 as u32.private; + add r0 r1 into r2; + output r2 as u32.private;