Skip to content

Commit

Permalink
Merge branch 'master' into tf/deduplicate-wasm-compiler
Browse files Browse the repository at this point in the history
* master:
  chore(ci): prevent msrv checks from blocking PRs (#4414)
  feat: expose separate functions to compile programs vs contracts in `noir_wasm` (#4413)
  chore: do not panic when dividing by zero (#4424)
  chore: remove unwanted prints (#4419)
  fix: remove print from monomorphization pass (#4417)
  chore(ssa): Remove mem2reg run before flattening (#4415)
  feat: Add HashMap to the stdlib (#4242)
  • Loading branch information
TomAFrench committed Feb 26, 2024
2 parents 853cf36 + 176fab4 commit 845d92d
Show file tree
Hide file tree
Showing 30 changed files with 1,267 additions and 229 deletions.
13 changes: 13 additions & 0 deletions .github/ACVM_NOT_PUBLISHABLE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
title: "ACVM crates are not publishable"
assignees: TomAFrench kevaundray savio-sou
---


The ACVM crates are currently unpublishable, making a release will NOT push our crates to crates.io.

This is likely due to a crate we depend on bumping its MSRV above our own. Our lockfile is not taken into account when publishing to crates.io (as people downloading our crate don't use it) so we need to be able to use the most up to date versions of our dependencies (including transient dependencies) specified.

Check the [MSRV check]({{env.WORKFLOW_URL}}) workflow for details.

This issue was raised by the workflow `{{env.WORKFLOW_NAME}}`
37 changes: 25 additions & 12 deletions .github/workflows/test-rust-workspace-msrv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ name: Test (MSRV check)
# We must then always be able to build the workspace using the latest versions of all of our dependencies, so we explicitly update them and build in this workflow.

on:
pull_request:
merge_group:
schedule:
# Run a nightly check at 2 AM UTC
- cron: "0 2 * * *"
push:
branches:
- master
Expand Down Expand Up @@ -100,13 +101,25 @@ jobs:
- run-tests

steps:
- name: Report overall success
run: |
if [[ $FAIL == true ]]; then
exit 1
else
exit 0
fi
env:
# We treat any cancelled, skipped or failing jobs as a failure for the workflow as a whole.
FAIL: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') || contains(needs.*.result, 'skipped') }}
- name: Report overall success
run: |
if [[ $FAIL == true ]]; then
exit 1
else
exit 0
fi
env:
# We treat any cancelled, skipped or failing jobs as a failure for the workflow as a whole.
FAIL: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') || contains(needs.*.result, 'skipped') }}

# Raise an issue if the tests failed
- name: Alert on failed publish
uses: JasonEtco/create-an-issue@v2
if: ${{ failure() }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WORKFLOW_NAME: ${{ github.workflow }}
WORKFLOW_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
with:
update_existing: true
filename: .github/JS_PUBLISH_FAILED.md
20 changes: 10 additions & 10 deletions .github/workflows/test-rust-workspace.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ jobs:
- run-tests

steps:
- name: Report overall success
run: |
if [[ $FAIL == true ]]; then
exit 1
else
exit 0
fi
env:
# We treat any cancelled, skipped or failing jobs as a failure for the workflow as a whole.
FAIL: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') || contains(needs.*.result, 'skipped') }}
- name: Report overall success
run: |
if [[ $FAIL == true ]]; then
exit 1
else
exit 0
fi
env:
# We treat any cancelled, skipped or failing jobs as a failure for the workflow as a whole.
FAIL: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') || contains(needs.*.result, 'skipped') }}
12 changes: 7 additions & 5 deletions acvm-repo/brillig_vm/src/arithmetic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,20 @@ pub(crate) fn evaluate_binary_bigint_op(
BinaryIntOp::UnsignedDiv => {
let b_mod = b % bit_modulo;
if b_mod.is_zero() {
return Err("Division by zero".to_owned());
BigUint::zero()
} else {
(a % bit_modulo) / b_mod
}
(a % bit_modulo) / b_mod
}
// Perform signed division by first converting a and b to signed integers and then back to unsigned after the operation.
BinaryIntOp::SignedDiv => {
let b_signed = to_big_signed(b, bit_size);
if b_signed.is_zero() {
return Err("Division by zero".to_owned());
BigUint::zero()
} else {
let signed_div = to_big_signed(a, bit_size) / b_signed;
to_big_unsigned(signed_div, bit_size)
}
let signed_div = to_big_signed(a, bit_size) / b_signed;
to_big_unsigned(signed_div, bit_size)
}
// Perform a == operation, returning 0 or 1
BinaryIntOp::Equals => {
Expand Down
5 changes: 0 additions & 5 deletions compiler/noirc_evaluator/src/ssa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,6 @@ pub(crate) fn optimize_into_acir(
.try_run_pass(Ssa::evaluate_assert_constant, "After Assert Constant:")?
.try_run_pass(Ssa::unroll_loops, "After Unrolling:")?
.run_pass(Ssa::simplify_cfg, "After Simplifying:")
// Run mem2reg before flattening to handle any promotion
// of values that can be accessed after loop unrolling.
// If there are slice mergers uncovered by loop unrolling
// and this pass is missed, slice merging will fail inside of flattening.
.run_pass(Ssa::mem2reg, "After Mem2Reg:")
.run_pass(Ssa::flatten_cfg, "After Flattening:")
.run_pass(Ssa::remove_bit_shifts, "After Removing Bit Shifts:")
// Run mem2reg once more with the flattened CFG to catch any remaining loads/stores
Expand Down
3 changes: 0 additions & 3 deletions compiler/noirc_evaluator/src/ssa/ssa_gen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ impl<'a> FunctionContext<'a> {
}

fn codegen_expression(&mut self, expr: &Expression) -> Result<Values, RuntimeError> {
eprintln!("Codegen {expr}");
match expr {
Expression::Ident(ident) => Ok(self.codegen_ident(ident)),
Expression::Literal(literal) => self.codegen_literal(literal),
Expand Down Expand Up @@ -348,10 +347,8 @@ impl<'a> FunctionContext<'a> {
}

fn codegen_binary(&mut self, binary: &ast::Binary) -> Result<Values, RuntimeError> {
eprintln!("Start binary");
let lhs = self.codegen_non_tuple_expression(&binary.lhs)?;
let rhs = self.codegen_non_tuple_expression(&binary.rhs)?;
eprintln!("Insert binary");
Ok(self.insert_binary(lhs, binary.operator, rhs, binary.location))
}

Expand Down
Loading

0 comments on commit 845d92d

Please sign in to comment.