Skip to content

Commit

Permalink
feat: add optional oracle resolver url in acvm_cli (#7630)
Browse files Browse the repository at this point in the history
Co-authored-by: Michael J Klein <[email protected]>
  • Loading branch information
TomAFrench and michaeljklein authored Mar 7, 2025
1 parent e3f8398 commit a9de769
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions tooling/acvm_cli/src/cli/execute_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ pub(crate) struct ExecuteCommand {
#[clap(long, short, action)]
print: bool,

/// JSON RPC url to resolve oracle calls
#[clap(long)]
oracle_resolver: Option<String>,

/// Use pedantic ACVM solving, i.e. double-check some black-box function
/// assumptions when solving.
/// This is disabled by default.
Expand All @@ -48,8 +52,12 @@ pub(crate) struct ExecuteCommand {
fn run_command(args: ExecuteCommand) -> Result<String, CliError> {
let bytecode = read_bytecode_from_file(&args.working_directory, &args.bytecode)?;
let input_witness = read_witness_from_file(&args.working_directory.join(&args.input_witness))?;
let output_witness =
execute_program_from_witness(input_witness, &bytecode, args.pedantic_solving)?;
let output_witness = execute_program_from_witness(
input_witness,
&bytecode,
args.pedantic_solving,
args.oracle_resolver,
)?;
assert_eq!(output_witness.length(), 1, "ACVM CLI only supports a witness stack of size 1");
let output_witness_string = create_output_witness_string(
&output_witness.peek().expect("Should have a witness stack item").witness,
Expand Down Expand Up @@ -77,6 +85,7 @@ pub(crate) fn execute_program_from_witness(
inputs_map: WitnessMap<FieldElement>,
bytecode: &[u8],
pedantic_solving: bool,
resolver_url: Option<String>,
) -> Result<WitnessStack<FieldElement>, CliError> {
let program: Program<FieldElement> =
Program::deserialize_program(bytecode).map_err(CliError::CircuitDeserializationError)?;
Expand All @@ -88,6 +97,7 @@ pub(crate) fn execute_program_from_witness(
&mut DefaultForeignCallBuilder {
output: PrintOutput::Stdout,
enable_mocks: false,
resolver_url,
..Default::default()
}
.build(),
Expand Down

0 comments on commit a9de769

Please sign in to comment.