From 9fffdf96b6f9d022ab6c149c3872a4ccf020a4df Mon Sep 17 00:00:00 2001 From: TomAFrench Date: Thu, 11 Apr 2024 11:24:11 +0000 Subject: [PATCH 1/4] feat: add `NARGO_FOREIGN_CALL_TIMEOUT` environment variable --- tooling/nargo/src/ops/foreign_calls.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tooling/nargo/src/ops/foreign_calls.rs b/tooling/nargo/src/ops/foreign_calls.rs index ea67f17af2a..5ebbb05a090 100644 --- a/tooling/nargo/src/ops/foreign_calls.rs +++ b/tooling/nargo/src/ops/foreign_calls.rs @@ -161,8 +161,16 @@ 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| u64::from_str_radix(&timeout, 10)) + { + let timeout_duration = std::time::Duration::from_millis(timeout); + transport_builder = transport_builder.timeout(timeout_duration); + }; Client::with_transport(transport_builder.build()) }); DefaultForeignCallExecutor { From 167c01920a4b6819b2dd9a7d684498eedee145ef Mon Sep 17 00:00:00 2001 From: TomAFrench Date: Thu, 11 Apr 2024 12:14:51 +0000 Subject: [PATCH 2/4] chore: clippy --- tooling/nargo/src/ops/foreign_calls.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tooling/nargo/src/ops/foreign_calls.rs b/tooling/nargo/src/ops/foreign_calls.rs index 5ebbb05a090..8aded6390b9 100644 --- a/tooling/nargo/src/ops/foreign_calls.rs +++ b/tooling/nargo/src/ops/foreign_calls.rs @@ -166,7 +166,7 @@ impl DefaultForeignCallExecutor { if let Some(Ok(timeout)) = std::env::var("NARGO_FOREIGN_CALL_TIMEOUT") .ok() - .map(|timeout| u64::from_str_radix(&timeout, 10)) + .map(|timeout| timeout.parse()) { let timeout_duration = std::time::Duration::from_millis(timeout); transport_builder = transport_builder.timeout(timeout_duration); From c1fcea12325a9824c2647d7f92237bc82212c5bc Mon Sep 17 00:00:00 2001 From: Tom French Date: Fri, 12 Apr 2024 10:46:39 +0100 Subject: [PATCH 3/4] chore: cargo fmt --- tooling/nargo/src/ops/foreign_calls.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tooling/nargo/src/ops/foreign_calls.rs b/tooling/nargo/src/ops/foreign_calls.rs index 8aded6390b9..6e815e7de17 100644 --- a/tooling/nargo/src/ops/foreign_calls.rs +++ b/tooling/nargo/src/ops/foreign_calls.rs @@ -164,9 +164,8 @@ impl DefaultForeignCallExecutor { 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()) + 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); From cad1b35685ec9ced6aee81fd10f0ab10c8f57d07 Mon Sep 17 00:00:00 2001 From: Tom French Date: Mon, 15 Apr 2024 12:07:30 +0100 Subject: [PATCH 4/4] chore: update docs --- docs/docs/noir/concepts/oracles.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/docs/noir/concepts/oracles.md b/docs/docs/noir/concepts/oracles.md index 2e6a6818d48..aa380b5f7b8 100644 --- a/docs/docs/noir/concepts/oracles.md +++ b/docs/docs/noir/concepts/oracles.md @@ -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) @@ -21,3 +27,5 @@ You can declare an Oracle through the `#[oracle()]` 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.