From 408df3e52853caed5be8b8ece2756c4801bee46d Mon Sep 17 00:00:00 2001 From: TomAFrench Date: Fri, 29 Nov 2024 19:28:52 +0000 Subject: [PATCH] . --- tooling/nargo/src/foreign_calls/mod.rs | 10 ++++------ tooling/nargo/src/foreign_calls/rpc.rs | 6 ++++-- tooling/nargo_cli/tests/stdlib-props.rs | 6 +----- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/tooling/nargo/src/foreign_calls/mod.rs b/tooling/nargo/src/foreign_calls/mod.rs index 5e14757e24..0ef3247ee5 100644 --- a/tooling/nargo/src/foreign_calls/mod.rs +++ b/tooling/nargo/src/foreign_calls/mod.rs @@ -85,7 +85,6 @@ impl DefaultForeignCallExecutor { RPCForeignCallExecutor::new(resolver_url, id, root_path, package_name) }); DefaultForeignCallExecutor { - printer, mocker: MockForeignCallExecutor::default(), external: external_resolver, @@ -122,17 +121,17 @@ impl Deserialize<'a>> ForeignCallExecutor // 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 @@ -141,7 +140,6 @@ impl Deserialize<'a>> ForeignCallExecutor // We optimistically return an empty response for all oracle calls as the ACVM will error // should a response have been required. Ok(ForeignCallResult::default()) - } } } diff --git a/tooling/nargo/src/foreign_calls/rpc.rs b/tooling/nargo/src/foreign_calls/rpc.rs index b9ee7119d6..dab64819b5 100644 --- a/tooling/nargo/src/foreign_calls/rpc.rs +++ b/tooling/nargo/src/foreign_calls/rpc.rs @@ -198,7 +198,8 @@ mod tests { let mut executor = RPCForeignCallExecutor::new(&url, 3, None, None); - let foreign_call: ForeignCallWaitInfo = ForeignCallWaitInfo { function: "id".to_string(), inputs: Vec::new() }; + let foreign_call: ForeignCallWaitInfo = + ForeignCallWaitInfo { function: "id".to_string(), inputs: Vec::new() }; let result_1 = executor.execute(&foreign_call).unwrap(); let result_2 = executor.execute(&foreign_call).unwrap(); @@ -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 = ForeignCallWaitInfo { function: "id".to_string(), inputs: Vec::new() }; + let foreign_call: ForeignCallWaitInfo = + 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(); diff --git a/tooling/nargo_cli/tests/stdlib-props.rs b/tooling/nargo_cli/tests/stdlib-props.rs index 12d14bb305..370d2c0405 100644 --- a/tooling/nargo_cli/tests/stdlib-props.rs +++ b/tooling/nargo_cli/tests/stdlib-props.rs @@ -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,