Skip to content

Commit

Permalink
chore: remove special casing for pedersen_hash black box function (#…
Browse files Browse the repository at this point in the history
…3744)

# Description

## Problem\*

Resolves #3370 

## Summary\*

This PR removes the special case which says all backends support the
pedersen hash black box function.

## Additional Context



## Documentation\*

Check one:
- [x] No documentation needed.
- [ ] Documentation included in this PR.
- [ ] **[Exceptional Case]** Documentation to be submitted in a separate
PR.

# PR Checklist\*

- [x] I have tested the changes locally.
- [x] I have formatted the changes with [Prettier](https://prettier.io/)
and/or `cargo fmt` on default settings.
  • Loading branch information
hayleykwan authored Dec 10, 2023
1 parent 29f2cd9 commit 1c66b24
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 28 deletions.
17 changes: 2 additions & 15 deletions tooling/nargo/src/ops/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,22 +85,9 @@ pub fn compile_program(
}
};

// TODO: we say that pedersen hashing is supported by all backends for now
let is_opcode_supported_pedersen_hash = |opcode: &Opcode| -> bool {
if let Opcode::BlackBoxFuncCall(
acvm::acir::circuit::opcodes::BlackBoxFuncCall::PedersenHash { .. },
) = opcode
{
true
} else {
is_opcode_supported(opcode)
}
};

// Apply backend specific optimizations.
let optimized_program =
crate::ops::optimize_program(program, np_language, &is_opcode_supported_pedersen_hash)
.expect("Backend does not support an opcode that is in the IR");
let optimized_program = crate::ops::optimize_program(program, np_language, is_opcode_supported)
.expect("Backend does not support an opcode that is in the IR");

(context.file_manager, Ok((optimized_program, warnings)))
}
Expand Down
15 changes: 2 additions & 13 deletions tooling/nargo_cli/src/cli/compile_cmd.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::path::Path;

use acvm::acir::circuit::opcodes::BlackBoxFuncCall;
use acvm::acir::circuit::Opcode;
use acvm::Language;
use backend_interface::BackendOpcodeSupport;
Expand Down Expand Up @@ -213,19 +212,9 @@ fn compile_program(
}
};

// TODO: we say that pedersen hashing is supported by all backends for now
let is_opcode_supported_pedersen_hash = |opcode: &Opcode| -> bool {
if let Opcode::BlackBoxFuncCall(BlackBoxFuncCall::PedersenHash { .. }) = opcode {
true
} else {
is_opcode_supported(opcode)
}
};

// Apply backend specific optimizations.
let optimized_program =
nargo::ops::optimize_program(program, np_language, &is_opcode_supported_pedersen_hash)
.expect("Backend does not support an opcode that is in the IR");
let optimized_program = nargo::ops::optimize_program(program, np_language, is_opcode_supported)
.expect("Backend does not support an opcode that is in the IR");

save_program(optimized_program.clone(), package, &workspace.target_directory_path());

Expand Down

0 comments on commit 1c66b24

Please sign in to comment.