Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
TomAFrench committed Nov 29, 2024
1 parent 7e33e2a commit 408df3e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
10 changes: 4 additions & 6 deletions tooling/nargo/src/foreign_calls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ impl<F: Default> DefaultForeignCallExecutor<F> {
RPCForeignCallExecutor::new(resolver_url, id, root_path, package_name)
});
DefaultForeignCallExecutor {

printer,
mocker: MockForeignCallExecutor::default(),
external: external_resolver,
Expand Down Expand Up @@ -122,17 +121,17 @@ impl<F: AcirField + Serialize + for<'a> Deserialize<'a>> ForeignCallExecutor<F>
// First check if there's any defined mock responses for this foreign call.
match self.mocker.execute(foreign_call) {
Err(ForeignCallError::NoHandler(_)) => (),
response_or_error => return response_or_error
response_or_error => return response_or_error,
};

if let Some(external_resolver) = &mut self.external {
// If the user has registered an external resolver then we forward any remaining oracle calls there.
match external_resolver.execute(foreign_call) {
Err(ForeignCallError::NoHandler(_)) => (),
response_or_error => return response_or_error
response_or_error => return response_or_error,
};
}
}

// If all executors have no handler for the given foreign call then we cannot
// return a correct response to the ACVM. The best we can do is to return an empty response,
// this allows us to ignore any foreign calls which exist solely to pass information from inside
Expand All @@ -141,7 +140,6 @@ impl<F: AcirField + Serialize + for<'a> Deserialize<'a>> ForeignCallExecutor<F>
// We optimistically return an empty response for all oracle calls as the ACVM will error
// should a response have been required.
Ok(ForeignCallResult::default())

}
}
}
Expand Down
6 changes: 4 additions & 2 deletions tooling/nargo/src/foreign_calls/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ mod tests {

let mut executor = RPCForeignCallExecutor::new(&url, 3, None, None);

let foreign_call: ForeignCallWaitInfo<FieldElement> = ForeignCallWaitInfo { function: "id".to_string(), inputs: Vec::new() };
let foreign_call: ForeignCallWaitInfo<FieldElement> =
ForeignCallWaitInfo { function: "id".to_string(), inputs: Vec::new() };

let result_1 = executor.execute(&foreign_call).unwrap();
let result_2 = executor.execute(&foreign_call).unwrap();
Expand All @@ -214,7 +215,8 @@ mod tests {
let mut executor_1 = RPCForeignCallExecutor::new(&url, 4, None, None);
let mut executor_2 = RPCForeignCallExecutor::new(&url, 5, None, None);

let foreign_call: ForeignCallWaitInfo<FieldElement> = ForeignCallWaitInfo { function: "id".to_string(), inputs: Vec::new() };
let foreign_call: ForeignCallWaitInfo<FieldElement> =
ForeignCallWaitInfo { function: "id".to_string(), inputs: Vec::new() };

let result_1 = executor_1.execute(&foreign_call).unwrap();
let result_2 = executor_2.execute(&foreign_call).unwrap();
Expand Down
6 changes: 1 addition & 5 deletions tooling/nargo_cli/tests/stdlib-props.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ use std::{cell::RefCell, collections::BTreeMap, path::Path};

use acvm::{acir::native_types::WitnessStack, AcirField, FieldElement};
use iter_extended::vecmap;
use nargo::{
ops::execute_program,
foreign_calls::DefaultForeignCallExecutor,
parse_all,
};
use nargo::{foreign_calls::DefaultForeignCallExecutor, ops::execute_program, parse_all};
use noirc_abi::input_parser::InputValue;
use noirc_driver::{
compile_main, file_manager_with_stdlib, prepare_crate, CompilationResult, CompileOptions,
Expand Down

0 comments on commit 408df3e

Please sign in to comment.