Skip to content

Commit

Permalink
Merge branch 'master' into gd/issue_4578
Browse files Browse the repository at this point in the history
  • Loading branch information
guipublic authored Apr 15, 2024
2 parents e25fed6 + 791f1c8 commit d447867
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
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 @@ -167,8 +167,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

0 comments on commit d447867

Please sign in to comment.