You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(simulator): Fetch return values at circuit execution (#5642)
We were deserializing a `Program` twice in the simulator. Once to
execute the circuit and again to fetch the return witness. Every call to
`executeCircuitWithBlackBoxSolver` is followed by a call to
`getReturnWitness` in the simulator. We should just pass the return
witness right away as to not cross the WASM boundary a second time and
as to avoid a second deserialization.
I settled on a new ACVM method rather than using abi decoding as the
return witnesses are stripped from the ABI. We can have a method that
returns both the fully solved witness and the return witness based upon
the circuit. This allows us to both avoid storing duplicate return
witness information and an unnecessary deserialization.
/// Executes an ACIR circuit to generate the solved witness from the initial witness.
63
+
/// This method also extracts the public return values from the solved witness into its own return witness.
64
+
///
65
+
/// @param {&WasmBlackBoxFunctionSolver} solver - A black box solver.
66
+
/// @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
67
+
/// @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
68
+
/// @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
69
+
/// @returns {SolvedAndReturnWitness} The solved witness calculated by executing the circuit on the provided inputs, as well as the return witness indices as specified by the circuit.
let program:Program = Program::deserialize_program(&program)
80
+
.map_err(|_| JsExecutionError::new("Failed to deserialize circuit. This is likely due to differing serialization formats between ACVM_JS and your compiler".to_string(),None))?;
let program:Program = Program::deserialize_program(&program)
128
167
.map_err(|_| JsExecutionError::new("Failed to deserialize circuit. This is likely due to differing serialization formats between ACVM_JS and your compiler".to_string(),None))?;
0 commit comments