-
Notifications
You must be signed in to change notification settings - Fork 235
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: handle empty response foreign calls without an external resolver (
#4959) # Description ## Problem\* Resolves <!-- Link to GitHub Issue --> ## Summary\* I've modified the `DefaultForeignCallExecutor` so that rather than panicking on an unrecognised foreign call we return an empty response. This solves an issue experienced by @spalladino where `nargo test` was failing due to the use of a custom debugging oracle which doesn't return any values to the circuit. The only situation where these oracle calls not being handled would change the outcome of the test would be if they modify state in an external resolver such as to modify the response of a different oracle call (and so we'd still fail on those anyway). ## Additional Context I've cleared up some empty `Prover.toml` files as well. ## Documentation\* Check one: - [x] No documentation needed. - [ ] Documentation included in this PR. - [ ] **[For Experimental Features]** Documentation to be submitted in a separate PR. # PR Checklist\* - [x] I have tested the changes locally. - [x] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings. --------- Co-authored-by: jfecher <[email protected]>
- Loading branch information
1 parent
2e085b9
commit 0154bde
Showing
9 changed files
with
67 additions
and
31 deletions.
There are no files selected for viewing
Empty file.
Empty file.
Empty file.
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,7 @@ | ||
[package] | ||
name = "ignored_oracle" | ||
type = "bin" | ||
authors = [""] | ||
compiler_version = ">=0.23.0" | ||
|
||
[dependencies] |
23 changes: 23 additions & 0 deletions
23
test_programs/noir_test_success/ignored_oracle/src/main.nr
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,23 @@ | ||
// In `nargo test` we want to avoid the need for an external oracle resolver service to be required in the situation | ||
// where its existence doesn't affect whether the tests will pass or fail. We then want to be able to handle any | ||
// oracles which return zero field elements. | ||
|
||
// Note that this custom oracle doesn't return any new values into the program. | ||
// We can then safely continue execution even in the case where there is no oracle resolver to handle it. | ||
#[oracle(custom_debug)] | ||
unconstrained fn custom_debug() {} | ||
|
||
// However this oracle call should return a field element. We expect the ACVM to raise an error when it | ||
// doesn't receive this value. | ||
#[oracle(custom_getter)] | ||
unconstrained fn custom_getter() -> Field {} | ||
|
||
#[test] | ||
unconstrained fn unit_return_oracle_ignored() { | ||
custom_debug(); | ||
} | ||
|
||
#[test(should_fail_with = "0 output values were provided as a foreign call result for 1 destination slots")] | ||
unconstrained fn field_return_oracle_fails() { | ||
let _ = custom_getter(); | ||
} |
Empty file.
Empty file.
Empty file.
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