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(cli): Log and replay oracle transcript #7417

Open
wants to merge 86 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
fd4ab05
Add artifact_cli
aakoshh Feb 12, 2025
1fb81c6
Turn artifact_cli into a library/binary combo
aakoshh Feb 13, 2025
9558618
Port fs from acvm_cli
aakoshh Feb 13, 2025
aac1b0f
Remove fs from acvm_cli
aakoshh Feb 13, 2025
10fbcb0
Parse inputs
aakoshh Feb 14, 2025
a568cce
Execute the circuit
aakoshh Feb 14, 2025
88ce449
Show diagnostic
aakoshh Feb 14, 2025
65ed320
Save the witness
aakoshh Feb 14, 2025
aea18c3
Add command docs
aakoshh Feb 14, 2025
7878c25
Merge branch 'master' into 7132-artifact-cli
aakoshh Feb 14, 2025
236e5f1
Reset indent size in Cargo.toml
aakoshh Feb 14, 2025
d36f2b9
Merge branch '7132-artifact-cli' of github.com:noir-lang/noir into 71…
aakoshh Feb 14, 2025
8bf7e61
Normalize paths
aakoshh Feb 14, 2025
ef090a4
Use Artifact in inspector print-acir
aakoshh Feb 14, 2025
7ceee2a
Filter by name in print-acir
aakoshh Feb 14, 2025
5f7c87d
Make inspector info work on Artifact
aakoshh Feb 14, 2025
98850a4
Use PathBuf in profiler
aakoshh Feb 14, 2025
2066359
Update profiler to use noir_artifact_cli::fs
aakoshh Feb 14, 2025
7d820ca
Update profiler to use noir_artifact_cli::fs
aakoshh Feb 14, 2025
1ae7d45
Use artifact_cli::fs in criterion benchmarks
aakoshh Feb 14, 2025
adc71a3
Use artifact_cli::fs in nargo
aakoshh Feb 14, 2025
ce6b763
Remove fs from nargo
aakoshh Feb 14, 2025
642b9b3
Merge branch '7381-use-artifact-fs' of github.com:noir-lang/noir into…
aakoshh Feb 14, 2025
cedb107
Return error if bincode serialization fails
aakoshh Feb 17, 2025
7317a63
Fully qualify call to exec
aakoshh Feb 17, 2025
8c707c2
Use CompiledProgram instead of Circuit
aakoshh Feb 17, 2025
ac3b5ea
Move execution methods into their own module
aakoshh Feb 17, 2025
e19c4b7
Call artifact_cli::execution from nargo
aakoshh Feb 17, 2025
c1ad32b
Use as_deref
aakoshh Feb 17, 2025
66bcf73
Create and run the ExecuteCommand as-is
aakoshh Feb 17, 2025
4ec10a9
Merge branch 'master' into 7132-artifact-cli
aakoshh Feb 17, 2025
6c00259
Merge branch '7132-artifact-cli' into 7381-use-artifact-fs
aakoshh Feb 17, 2025
0615070
Merge branch '7381-use-artifact-fs' into 7380-nargo-exec-fwd
aakoshh Feb 17, 2025
47c7ade
Move ACVM CLI witness functions back
aakoshh Feb 17, 2025
51b1bd7
Remove --oracle-file for now
aakoshh Feb 17, 2025
cff69fa
Add Format::from_ext
aakoshh Feb 17, 2025
98cfd77
Try to make read_inputs_from_file easier to read
aakoshh Feb 17, 2025
c18bb19
Rename to artifact_path
aakoshh Feb 17, 2025
9c2c3d4
Rename binary to noir-executor with no subcommand
aakoshh Feb 17, 2025
6f27ebf
Noir program with oracles
aakoshh Feb 18, 2025
543f6df
Support printing oracle transcript from test
aakoshh Feb 18, 2025
0afd653
Add example and capture oracle transcript
aakoshh Feb 18, 2025
4989921
Move logger to nargo lib
aakoshh Feb 18, 2025
87068a6
Rename to artifact_path
aakoshh Feb 18, 2025
d463395
Rename to Logging
aakoshh Feb 18, 2025
0dc7fef
Add TranscriptForeignCallExecutor
aakoshh Feb 18, 2025
7022c77
Rename script
aakoshh Feb 18, 2025
97abe75
Make --oracle-file public
aakoshh Feb 18, 2025
93a889b
Add the example to CI
aakoshh Feb 18, 2025
cb301b2
Build the noir-execute binary and use it in the script
aakoshh Feb 18, 2025
5f89660
.
TomAFrench Feb 18, 2025
85bdd85
.
TomAFrench Feb 18, 2025
817df4a
.
TomAFrench Feb 18, 2025
51f2e2d
Switch to bin/execute.rs
aakoshh Feb 18, 2025
780cde3
Merge branch '7132-artifact-cli' of github.com:noir-lang/noir into 71…
aakoshh Feb 18, 2025
8a30ce5
Merge branch 'master' into 7132-artifact-cli
aakoshh Feb 18, 2025
3429365
Merge branch '7132-artifact-cli' into 7381-use-artifact-fs
aakoshh Feb 18, 2025
4502655
Merge branch '7381-use-artifact-fs' into 7380-nargo-exec-fwd
aakoshh Feb 18, 2025
c5d993a
Comment about ordering
aakoshh Feb 18, 2025
a7b09c7
Merge remote-tracking branch 'origin/7380-nargo-exec-fwd' into 7379-e…
aakoshh Feb 18, 2025
48556ac
Merge branch 'master' into 7132-artifact-cli
aakoshh Feb 18, 2025
17bed50
Merge remote-tracking branch 'origin/7132-artifact-cli' into 7381-use…
aakoshh Feb 18, 2025
416b563
Merge remote-tracking branch 'origin/7381-use-artifact-fs' into 7380-…
aakoshh Feb 18, 2025
6c16f10
Merge remote-tracking branch 'origin/7380-nargo-exec-fwd' into 7379-e…
aakoshh Feb 18, 2025
474e366
Fix action name
aakoshh Feb 18, 2025
5535321
Use cd
aakoshh Feb 18, 2025
69e64bc
Rename logging to transcript
aakoshh Feb 18, 2025
ba3d6d6
Add `hash` to contract function artifacts
aakoshh Feb 19, 2025
0196e1a
Just use default empty names, the info command won't work on such con…
aakoshh Feb 19, 2025
40dc505
Merge branch '7381-use-artifact-fs' into 7380-nargo-exec-fwd
aakoshh Feb 19, 2025
14fa101
Add ContractFunctionArtifact::into_compiled_program
aakoshh Feb 19, 2025
6c519d0
Add hash? to NoirFunctionEntry
aakoshh Feb 19, 2025
f5592bc
Use string to serialize hash
aakoshh Feb 19, 2025
537b1d9
Fix the Wasm compiler to use deterministic file IDs
aakoshh Feb 19, 2025
c6ed3e0
Merge branch '7381-use-artifact-fs' into 7380-nargo-exec-fwd
aakoshh Feb 19, 2025
2b2e99c
Delete hash for contracts before comparison
aakoshh Feb 19, 2025
49ed538
Backwards compatible parsing of hash in noirc_artifacts
aakoshh Feb 19, 2025
4d61e75
Comments about why the hash doesn't match when there are dependencies
aakoshh Feb 19, 2025
9f5e8d6
Merge remote-tracking branch 'origin/master' into 7381-use-artifact-fs
aakoshh Feb 19, 2025
7f44036
Merge branch '7381-use-artifact-fs' into 7380-nargo-exec-fwd
aakoshh Feb 19, 2025
d078b44
Merge branch '7380-nargo-exec-fwd' into 7379-exec-oracle-transcript
aakoshh Feb 19, 2025
330a07e
Merge remote-tracking branch 'origin/master' into 7380-nargo-exec-fwd
aakoshh Feb 26, 2025
52fb48d
Merge branch '7380-nargo-exec-fwd' into 7379-exec-oracle-transcript
aakoshh Feb 26, 2025
9756837
Fix clippy
aakoshh Feb 26, 2025
3013b0e
Merge remote-tracking branch 'origin/master' into 7379-exec-oracle-tr…
aakoshh Feb 28, 2025
b232e85
Fix formatting
aakoshh Feb 28, 2025
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
18 changes: 18 additions & 0 deletions .github/actions/download-noir-execute/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Download noir-execute
description: Downloads the noir-execute binary from an artifact and adds it to the path

runs:
using: composite
steps:
- name: Download noir-execute binary
uses: actions/download-artifact@v4
with:
name: noir-execute
path: ./noir-execute

- name: Set noir-execute on PATH
shell: bash
run: |
noir_binary="${{ github.workspace }}/noir-execute/noir-execute"
chmod +x $noir_binary
echo "$(dirname $noir_binary)" >> $GITHUB_PATH
42 changes: 41 additions & 1 deletion .github/workflows/test-js-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,39 @@ jobs:
path: ./dist/*
retention-days: 3

build-noir-execute:
runs-on: ubuntu-22.04
timeout-minutes: 30

steps:
- name: Checkout Noir repo
uses: actions/checkout@v4

- name: Setup toolchain
uses: dtolnay/[email protected]

- uses: Swatinem/rust-cache@v2
with:
key: x86_64-unknown-linux-gnu
cache-on-failure: true
save-if: ${{ github.event_name != 'merge_group' }}

- name: Build noir-execute
run: cargo build --package noir_artifact_cli --release

- name: Package artifacts
run: |
mkdir dist
cp ./target/release/noir-execute ./dist/noir-execute
7z a -ttar -so -an ./dist/* | 7z a -si ./noir-execute-x86_64-unknown-linux-gnu.tar.gz

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: noir-execute
path: ./dist/*
retention-days: 3

build-noirc-abi:
runs-on: ubuntu-22.04
timeout-minutes: 30
Expand Down Expand Up @@ -457,7 +490,7 @@ jobs:
test-examples:
name: Example scripts
runs-on: ubuntu-22.04
needs: [build-nargo]
needs: [build-nargo, build-noir-execute]
timeout-minutes: 30

steps:
Expand All @@ -477,6 +510,9 @@ jobs:
- name: Download nargo binary
uses: ./.github/actions/download-nargo

- name: Download noir-execute binary
uses: ./.github/actions/download-noir-execute

- name: Run `prove_and_verify`
working-directory: ./examples/prove_and_verify
run: ./test.sh
Expand All @@ -485,6 +521,10 @@ jobs:
working-directory: ./examples/codegen_verifier
run: ./test.sh

- name: Run `oracle_transcript`
working-directory: ./examples/oracle_transcript
run: ./test.sh

external-repo-checks:
needs: [build-nargo, critical-library-list]
runs-on: ubuntu-22.04
Expand Down
7 changes: 7 additions & 0 deletions examples/oracle_transcript/Nargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "oracle_transcript"
type = "bin"
authors = [""]
compiler_version = ">=0.23.0"

[dependencies]
5 changes: 5 additions & 0 deletions examples/oracle_transcript/Oracle.jsonl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{"call":{"function":"void_field","inputs":[]},"result":{"values":["000000000000000000000000000000000000000000000000000000000000000a"]}}
{"call":{"function":"void_field","inputs":[]},"result":{"values":["0000000000000000000000000000000000000000000000000000000000000014"]}}
{"call":{"function":"field_field","inputs":["0000000000000000000000000000000000000000000000000000000000000002"]},"result":{"values":["000000000000000000000000000000000000000000000000000000000000001e"]}}
{"call":{"function":"field_field","inputs":["0000000000000000000000000000000000000000000000000000000000000003"]},"result":{"values":["0000000000000000000000000000000000000000000000000000000000000028"]}}
{"call":{"function":"struct_field","inputs":["000000000000000000000000000000000000000000000000000000000000012c","0000000000000000000000000000000000000000000000000000000000000320",["000000000000000000000000000000000000000000000000000000000000000a","0000000000000000000000000000000000000000000000000000000000000014","000000000000000000000000000000000000000000000000000000000000001e","0000000000000000000000000000000000000000000000000000000000000028"]]},"result":{"values":["0000000000000000000000000000000000000000000000000000000000000064"]}}
20 changes: 20 additions & 0 deletions examples/oracle_transcript/Oracle.test.jsonl
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{"call":{"function":"create_mock","inputs":[["0000000000000000000000000000000000000000000000000000000000000076","000000000000000000000000000000000000000000000000000000000000006f","0000000000000000000000000000000000000000000000000000000000000069","0000000000000000000000000000000000000000000000000000000000000064","000000000000000000000000000000000000000000000000000000000000005f","0000000000000000000000000000000000000000000000000000000000000066","0000000000000000000000000000000000000000000000000000000000000069","0000000000000000000000000000000000000000000000000000000000000065","000000000000000000000000000000000000000000000000000000000000006c","0000000000000000000000000000000000000000000000000000000000000064"]]},"result":{"values":["0000000000000000000000000000000000000000000000000000000000000000"]}}
{"call":{"function":"set_mock_returns","inputs":["0000000000000000000000000000000000000000000000000000000000000000","000000000000000000000000000000000000000000000000000000000000000a"]},"result":{"values":[]}}
{"call":{"function":"set_mock_times","inputs":["0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000001"]},"result":{"values":[]}}
{"call":{"function":"create_mock","inputs":[["0000000000000000000000000000000000000000000000000000000000000076","000000000000000000000000000000000000000000000000000000000000006f","0000000000000000000000000000000000000000000000000000000000000069","0000000000000000000000000000000000000000000000000000000000000064","000000000000000000000000000000000000000000000000000000000000005f","0000000000000000000000000000000000000000000000000000000000000066","0000000000000000000000000000000000000000000000000000000000000069","0000000000000000000000000000000000000000000000000000000000000065","000000000000000000000000000000000000000000000000000000000000006c","0000000000000000000000000000000000000000000000000000000000000064"]]},"result":{"values":["0000000000000000000000000000000000000000000000000000000000000001"]}}
{"call":{"function":"set_mock_returns","inputs":["0000000000000000000000000000000000000000000000000000000000000001","0000000000000000000000000000000000000000000000000000000000000014"]},"result":{"values":[]}}
{"call":{"function":"set_mock_times","inputs":["0000000000000000000000000000000000000000000000000000000000000001","0000000000000000000000000000000000000000000000000000000000000001"]},"result":{"values":[]}}
{"call":{"function":"create_mock","inputs":[["0000000000000000000000000000000000000000000000000000000000000066","0000000000000000000000000000000000000000000000000000000000000069","0000000000000000000000000000000000000000000000000000000000000065","000000000000000000000000000000000000000000000000000000000000006c","0000000000000000000000000000000000000000000000000000000000000064","000000000000000000000000000000000000000000000000000000000000005f","0000000000000000000000000000000000000000000000000000000000000066","0000000000000000000000000000000000000000000000000000000000000069","0000000000000000000000000000000000000000000000000000000000000065","000000000000000000000000000000000000000000000000000000000000006c","0000000000000000000000000000000000000000000000000000000000000064"]]},"result":{"values":["0000000000000000000000000000000000000000000000000000000000000002"]}}
{"call":{"function":"set_mock_params","inputs":["0000000000000000000000000000000000000000000000000000000000000002","0000000000000000000000000000000000000000000000000000000000000002"]},"result":{"values":[]}}
{"call":{"function":"set_mock_returns","inputs":["0000000000000000000000000000000000000000000000000000000000000002","000000000000000000000000000000000000000000000000000000000000001e"]},"result":{"values":[]}}
{"call":{"function":"create_mock","inputs":[["0000000000000000000000000000000000000000000000000000000000000066","0000000000000000000000000000000000000000000000000000000000000069","0000000000000000000000000000000000000000000000000000000000000065","000000000000000000000000000000000000000000000000000000000000006c","0000000000000000000000000000000000000000000000000000000000000064","000000000000000000000000000000000000000000000000000000000000005f","0000000000000000000000000000000000000000000000000000000000000066","0000000000000000000000000000000000000000000000000000000000000069","0000000000000000000000000000000000000000000000000000000000000065","000000000000000000000000000000000000000000000000000000000000006c","0000000000000000000000000000000000000000000000000000000000000064"]]},"result":{"values":["0000000000000000000000000000000000000000000000000000000000000003"]}}
{"call":{"function":"set_mock_params","inputs":["0000000000000000000000000000000000000000000000000000000000000003","0000000000000000000000000000000000000000000000000000000000000003"]},"result":{"values":[]}}
{"call":{"function":"set_mock_returns","inputs":["0000000000000000000000000000000000000000000000000000000000000003","0000000000000000000000000000000000000000000000000000000000000028"]},"result":{"values":[]}}
{"call":{"function":"create_mock","inputs":[["0000000000000000000000000000000000000000000000000000000000000073","0000000000000000000000000000000000000000000000000000000000000074","0000000000000000000000000000000000000000000000000000000000000072","0000000000000000000000000000000000000000000000000000000000000075","0000000000000000000000000000000000000000000000000000000000000063","0000000000000000000000000000000000000000000000000000000000000074","000000000000000000000000000000000000000000000000000000000000005f","0000000000000000000000000000000000000000000000000000000000000066","0000000000000000000000000000000000000000000000000000000000000069","0000000000000000000000000000000000000000000000000000000000000065","000000000000000000000000000000000000000000000000000000000000006c","0000000000000000000000000000000000000000000000000000000000000064"]]},"result":{"values":["0000000000000000000000000000000000000000000000000000000000000004"]}}
{"call":{"function":"set_mock_params","inputs":["0000000000000000000000000000000000000000000000000000000000000004","000000000000000000000000000000000000000000000000000000000000012c","0000000000000000000000000000000000000000000000000000000000000320",["000000000000000000000000000000000000000000000000000000000000000a","0000000000000000000000000000000000000000000000000000000000000014","000000000000000000000000000000000000000000000000000000000000001e","0000000000000000000000000000000000000000000000000000000000000028"]]},"result":{"values":[]}}
{"call":{"function":"set_mock_returns","inputs":["0000000000000000000000000000000000000000000000000000000000000004","0000000000000000000000000000000000000000000000000000000000000064"]},"result":{"values":[]}}
{"call":{"function":"void_field","inputs":[]},"result":{"values":["000000000000000000000000000000000000000000000000000000000000000a"]}}
{"call":{"function":"void_field","inputs":[]},"result":{"values":["0000000000000000000000000000000000000000000000000000000000000014"]}}
{"call":{"function":"field_field","inputs":["0000000000000000000000000000000000000000000000000000000000000002"]},"result":{"values":["000000000000000000000000000000000000000000000000000000000000001e"]}}
{"call":{"function":"field_field","inputs":["0000000000000000000000000000000000000000000000000000000000000003"]},"result":{"values":["0000000000000000000000000000000000000000000000000000000000000028"]}}
{"call":{"function":"struct_field","inputs":["000000000000000000000000000000000000000000000000000000000000012c","0000000000000000000000000000000000000000000000000000000000000320",["000000000000000000000000000000000000000000000000000000000000000a","0000000000000000000000000000000000000000000000000000000000000014","000000000000000000000000000000000000000000000000000000000000001e","0000000000000000000000000000000000000000000000000000000000000028"]]},"result":{"values":["0000000000000000000000000000000000000000000000000000000000000064"]}}
6 changes: 6 additions & 0 deletions examples/oracle_transcript/Prover.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

[input]
x = 2
y = 3

return = 100
22 changes: 22 additions & 0 deletions examples/oracle_transcript/log_and_exec_transcript.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash
set -eu

cd $(dirname $0)

# Execute the test to capture oracle calls.
NARGO_TEST_FOREIGN_CALL_LOG=Oracle.test.jsonl nargo test

# Get rid of the mock setup calls
cat Oracle.test.jsonl \
| jq --slurp -r -c '.[] | select(.call.function | contains("mock") | not)' \
> Oracle.jsonl

# Execute `main` with the Prover.toml and Oracle.jsonl files.
nargo execute --skip-underconstrained-check --oracle-file Oracle.jsonl

# Also execute through `noir-execute`
noir-execute \
--artifact-path target/oracle_transcript.json \
--oracle-file Oracle.jsonl \
--prover-file Prover.toml \
--output-dir target
63 changes: 63 additions & 0 deletions examples/oracle_transcript/src/main.nr
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
use std::test::OracleMock;

struct Point {
x: Field,
y: Field,
}

impl Eq for Point {
fn eq(self, other: Point) -> bool {
(self.x == other.x) & (self.y == other.y)
}
}

#[oracle(void_field)]
unconstrained fn void_field_oracle() -> Field {}

unconstrained fn void_field() -> Field {
void_field_oracle()
}

#[oracle(field_field)]
unconstrained fn field_field_oracle(_x: Field) -> Field {}

unconstrained fn field_field(x: Field) -> Field {
field_field_oracle(x)
}

#[oracle(struct_field)]
unconstrained fn struct_field_oracle(_point: Point, _array: [Field; 4]) -> Field {}

unconstrained fn struct_field(point: Point, array: [Field; 4]) -> Field {
struct_field_oracle(point, array)
}

fn main(input: Point) -> pub Field {
// Safety: testing context
unsafe {
let a = void_field();
let b = void_field();
let c = field_field(input.x);
let d = field_field(input.y);
let p = Point { x: a * c, y: b * d };
struct_field(p, [a, b, c, d])
}
}

/// This test is used to capture an oracle transcript, which can then be replayed
/// during execution.
#[test]
fn test_main() {
// Safety: testing context
unsafe {
let _ = OracleMock::mock("void_field").returns(10).times(1);
let _ = OracleMock::mock("void_field").returns(20).times(1);
let _ = OracleMock::mock("field_field").with_params((2,)).returns(30);
let _ = OracleMock::mock("field_field").with_params((3,)).returns(40);
let _ = OracleMock::mock("struct_field")
.with_params((Point { x: 300, y: 800 }, [10, 20, 30, 40]))
.returns(100);
}
let output = main(Point { x: 2, y: 3 });
assert_eq(output, 100)
}
10 changes: 10 additions & 0 deletions examples/oracle_transcript/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
set -eu

cd $(dirname $0)

# This file is used for Noir CI and is not required.

rm -f ./Oracle.*

./log_and_exec_transcript.sh
33 changes: 29 additions & 4 deletions tooling/artifact_cli/src/commands/execute_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ use crate::{
errors::CliError,
execution::{self, ExecutionResults},
};
use nargo::{PrintOutput, foreign_calls::DefaultForeignCallBuilder};
use nargo::{
PrintOutput,
foreign_calls::{DefaultForeignCallBuilder, layers, transcript::ReplayForeignCallExecutor},
};
use noirc_driver::CompiledProgram;

use super::parse_and_normalize_path;
Expand Down Expand Up @@ -40,10 +43,27 @@ pub struct ExecuteCommand {
#[clap(long)]
pub contract_fn: Option<String>,

/// Path to the oracle transcript that is to be replayed during the
/// execution in response to foreign calls. The format is expected
/// to be JSON Lines, with each request/response on a separate line.
///
/// Note that a transcript might be invalid if the inputs change and
/// the circuit takes a different path during execution.
#[clap(long, conflicts_with = "oracle_resolver")]
pub oracle_file: Option<PathBuf>,

/// JSON RPC url to solve oracle calls.
#[clap(long)]
#[clap(long, conflicts_with = "oracle_file")]
pub oracle_resolver: Option<String>,

/// Root directory for the RPC oracle resolver.
#[clap(long, value_parser = parse_and_normalize_path)]
pub oracle_root_dir: Option<PathBuf>,

/// Package name for the RPC oracle resolver
#[clap(long)]
pub oracle_package_name: Option<String>,

/// Use pedantic ACVM solving, i.e. double-check some black-box function assumptions when solving.
#[clap(long, default_value_t = false)]
pub pedantic_solving: bool,
Expand Down Expand Up @@ -92,18 +112,23 @@ pub fn run(args: ExecuteCommand) -> Result<(), CliError> {

/// Execute a circuit and return the output witnesses.
fn execute(circuit: &CompiledProgram, args: &ExecuteCommand) -> Result<ExecutionResults, CliError> {
// TODO: Build a custom foreign call executor that reads from the Oracle transcript,
// Build a custom foreign call executor that replays the Oracle transcript,
// and use it as a base for the default executor. Using it as the innermost rather
// than top layer so that any extra `print` added for debugging is handled by the
// default, rather than trying to match it to the transcript.
let transcript_executor = match args.oracle_file {
Some(ref path) => layers::Either::Left(ReplayForeignCallExecutor::from_file(path)?),
None => layers::Either::Right(layers::Empty),
};

let mut foreign_call_executor = DefaultForeignCallBuilder {
output: PrintOutput::Stdout,
enable_mocks: false,
resolver_url: args.oracle_resolver.clone(),
root_path: None,
package_name: None,
}
.build();
.build_with_base(transcript_executor);

let blackbox_solver = Bn254BlackBoxSolver(args.pedantic_solving);

Expand Down
6 changes: 5 additions & 1 deletion tooling/artifact_cli/src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use acir::FieldElement;
use nargo::NargoError;
use nargo::{NargoError, foreign_calls::transcript::TranscriptError};
use noirc_abi::{
AbiReturnType,
errors::{AbiError, InputParserError},
Expand Down Expand Up @@ -39,6 +39,10 @@ pub enum CliError {
#[error("Failed to deserialize inputs")]
InputDeserializationError(#[from] InputParserError),

/// Error related to oracle transcript deserialization
#[error(transparent)]
TranscriptError(#[from] TranscriptError),

/// Error related to ABI encoding
#[error(transparent)]
AbiError(#[from] AbiError),
Expand Down
4 changes: 4 additions & 0 deletions tooling/nargo/src/foreign_calls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use thiserror::Error;
pub mod layers;
pub mod mocker;
pub mod print;
pub mod transcript;

pub mod default;
#[cfg(feature = "rpc")]
Expand Down Expand Up @@ -83,4 +84,7 @@ pub enum ForeignCallError {

#[error("Assert message resolved after an unsatisfied constrain. {0}")]
ResolvedAssertMessage(String),

#[error("Failed to replay oracle transcript: {0}")]
TranscriptError(String),
}
1 change: 1 addition & 0 deletions tooling/nargo/src/foreign_calls/print.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub enum PrintOutput<'a> {
String(&'a mut String),
}

/// Handle `println` calls.
#[derive(Debug, Default)]
pub struct PrintForeignCallExecutor<'a> {
output: PrintOutput<'a>,
Expand Down
Loading
Loading