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

feat: add NARGO_FOREIGN_CALL_TIMEOUT environment variable #4780

Merged
merged 4 commits into from
Apr 15, 2024
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
8 changes: 8 additions & 0 deletions docs/docs/noir/concepts/oracles.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ keywords:
sidebar_position: 6
---

:::note

This is an experimental feature that is not fully documented. If you notice any outdated information or potential improvements to this page, pull request contributions are very welcome: https://github.com/noir-lang/noir

:::

Noir has support for Oracles via RPC calls. This means Noir will make an RPC call and use the return value for proof generation.

Since Oracles are not resolved by Noir, they are [`unconstrained` functions](./unconstrained.md)
Expand All @@ -21,3 +27,5 @@ You can declare an Oracle through the `#[oracle(<name>)]` flag. Example:
#[oracle(get_number_sequence)]
unconstrained fn get_number_sequence(_size: Field) -> [Field] {}
```

The timeout for when using an external RPC oracle resolver can be set with the `NARGO_FOREIGN_CALL_TIMEOUT` environment variable. This timeout is in units of milliseconds.
9 changes: 8 additions & 1 deletion tooling/nargo/src/ops/foreign_calls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,15 @@ pub struct DefaultForeignCallExecutor {
impl DefaultForeignCallExecutor {
pub fn new(show_output: bool, resolver_url: Option<&str>) -> Self {
let oracle_resolver = resolver_url.map(|resolver_url| {
let transport_builder =
let mut transport_builder =
Builder::new().url(resolver_url).expect("Invalid oracle resolver URL");

if let Some(Ok(timeout)) =
std::env::var("NARGO_FOREIGN_CALL_TIMEOUT").ok().map(|timeout| timeout.parse())
{
let timeout_duration = std::time::Duration::from_millis(timeout);
transport_builder = transport_builder.timeout(timeout_duration);
};
Client::with_transport(transport_builder.build())
});
DefaultForeignCallExecutor {
Expand Down
Loading