Skip to content
This repository has been archived by the owner on Apr 9, 2024. It is now read-only.

chore(acvm): rename remaining references to gadget calls #76

Merged
merged 1 commit into from
Feb 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 8 additions & 6 deletions acvm/src/compiler/fallback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,13 @@ pub fn fallback(acir: Circuit, is_supported: IsBlackBoxSupported) -> Result<Circ
}

fn opcode_fallback(
gc: &BlackBoxFuncCall,
bb_func_call: &BlackBoxFuncCall,
current_witness_idx: u32,
) -> Result<(u32, Vec<Opcode>), CompileError> {
let (updated_witness_index, opcodes_fallback) = match gc.name {
let (updated_witness_index, opcodes_fallback) = match bb_func_call.name {
BlackBoxFunc::AND => {
let (lhs, rhs, result, num_bits) = crate::pwg::logic::extract_input_output(gc);
let (lhs, rhs, result, num_bits) =
crate::pwg::logic::extract_input_output(bb_func_call);
stdlib::fallback::and(
Expression::from(&lhs),
Expression::from(&rhs),
Expand All @@ -66,7 +67,8 @@ fn opcode_fallback(
)
}
BlackBoxFunc::XOR => {
let (lhs, rhs, result, num_bits) = crate::pwg::logic::extract_input_output(gc);
let (lhs, rhs, result, num_bits) =
crate::pwg::logic::extract_input_output(bb_func_call);
stdlib::fallback::xor(
Expression::from(&lhs),
Expression::from(&rhs),
Expand All @@ -78,7 +80,7 @@ fn opcode_fallback(
BlackBoxFunc::RANGE => {
// TODO: add consistency checks in one place
// TODO: we aren't checking that range gate should have one input
let input = &gc.inputs[0];
let input = &bb_func_call.inputs[0];
// Note there are no outputs because range produces no outputs
stdlib::fallback::range(
Expression::from(&input.witness),
Expand All @@ -87,7 +89,7 @@ fn opcode_fallback(
)
}
_ => {
return Err(CompileError::UnsupportedBlackBox(gc.name));
return Err(CompileError::UnsupportedBlackBox(bb_func_call.name));
}
};

Expand Down
10 changes: 6 additions & 4 deletions acvm/src/pwg/logic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,12 @@ impl LogicSolver {
}
// TODO: Is there somewhere else that we can put this?
// TODO: extraction methods are needed for some opcodes like logic and range
pub(crate) fn extract_input_output(gc: &BlackBoxFuncCall) -> (Witness, Witness, Witness, u32) {
let a = &gc.inputs[0];
let b = &gc.inputs[1];
let result = &gc.outputs[0];
pub(crate) fn extract_input_output(
bb_func_call: &BlackBoxFuncCall,
) -> (Witness, Witness, Witness, u32) {
let a = &bb_func_call.inputs[0];
let b = &bb_func_call.inputs[1];
let result = &bb_func_call.outputs[0];

// The num_bits variable should be the same for all witnesses
assert_eq!(
Expand Down