-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
[Fix] Set console caller and signer when executing closures. #2525
Draft
d0cd
wants to merge
4
commits into
ProvableHQ:staging
Choose a base branch
from
ProvableHQ:fix/caller-in-closure
base: staging
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
synthesizer/tests/expectations/vm/execute_and_finalize/self_caller_and_signer_in_closure.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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}"}' |
30 changes: 30 additions & 0 deletions
30
synthesizer/tests/tests/vm/execute_and_finalize/self_caller_and_signer_in_closure.aleo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you wrap the two new sets with
if let CallStack::Execute(..) = registers.call_stack()
just like we do below? Then we can keep theuse Eject
to just within the Execute blocks. I hope the tests still pass then O:)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we actually want to do that? In the corresponding logic in
execute_function
we set in all modes, not justCallStack::Execute
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm good call out. I guess we can leave the PR as is then.
I appended a diff to test if wrapping all of the console sets in
Execute
mode would work, and indeed the tests still pass (modulo requiring new expectations because I changed a test). Maybe this can inform a hypothetical future refactor ofexecute_{function, closure}
.diff.txt