diff --git a/.github/workflows/publish-noir-js.yml b/.github/workflows/publish-noir-js.yml index 75999bb087d..4614390e053 100644 --- a/.github/workflows/publish-noir-js.yml +++ b/.github/workflows/publish-noir-js.yml @@ -23,11 +23,6 @@ jobs: source $HOME/.cargo/env cargo install -f wasm-bindgen-cli --version 0.2.86 - - name: Install toml2json - run: | - source $HOME/.cargo/env - cargo install toml2json - - name: Install wasm-opt run: | npm i wasm-opt -g diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index 09e54b288dc..ebc2136f514 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -202,11 +202,6 @@ jobs: with: tool: wasm-bindgen-cli@0.2.86 - - name: Install toml2json - uses: taiki-e/install-action@v2 - with: - tool: toml2json@1.3.1 - - name: Install wasm-opt run: | npm i wasm-opt -g diff --git a/.github/workflows/test-noir-js.yml b/.github/workflows/test-noir-js.yml index 3a4868f4b1c..1dac0200027 100644 --- a/.github/workflows/test-noir-js.yml +++ b/.github/workflows/test-noir-js.yml @@ -38,11 +38,6 @@ jobs: with: tool: wasm-bindgen-cli@0.2.86 - - name: Install toml2json - uses: taiki-e/install-action@v2 - with: - tool: toml2json@1.3.1 - - name: Install wasm-opt run: | npm i wasm-opt -g diff --git a/.release-please-manifest.json b/.release-please-manifest.json index ca85da28fb0..baa3067f372 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,4 +1,4 @@ { - ".": "0.14.0", - "acvm-repo": "0.27.2" + ".": "0.14.1", + "acvm-repo": "0.27.3" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index b9aa0af38df..8be4206c9c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## [0.14.1](https://github.com/noir-lang/noir/compare/v0.14.0...v0.14.1) (2023-09-27) + + +### Bug Fixes + +* Remove cast for field comparisons in brillig ([#2874](https://github.com/noir-lang/noir/issues/2874)) ([1fc1fdb](https://github.com/noir-lang/noir/commit/1fc1fdb4e15d2ce625ea79d458c5346fab418e49)) +* Remove duplication of code to load stdlib files ([#2868](https://github.com/noir-lang/noir/issues/2868)) ([b694aab](https://github.com/noir-lang/noir/commit/b694aab87c4665a3a89715c9d4096eeb3efb9944)) + ## [0.14.0](https://github.com/noir-lang/noir/compare/v0.13.0...v0.14.0) (2023-09-26) diff --git a/Cargo.lock b/Cargo.lock index 1e9753f9b62..da6ac2b91e7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,13 +4,12 @@ version = 3 [[package]] name = "acir" -version = "0.27.2" +version = "0.27.3" dependencies = [ "acir_field", "bincode", "brillig", "flate2", - "rmp-serde", "serde", "serde_json", "strum", @@ -20,7 +19,7 @@ dependencies = [ [[package]] name = "acir_field" -version = "0.27.2" +version = "0.27.3" dependencies = [ "ark-bls12-381", "ark-bn254", @@ -33,7 +32,7 @@ dependencies = [ [[package]] name = "acvm" -version = "0.27.2" +version = "0.27.3" dependencies = [ "acir", "acvm_blackbox_solver", @@ -50,7 +49,7 @@ dependencies = [ [[package]] name = "acvm_blackbox_solver" -version = "0.27.2" +version = "0.27.3" dependencies = [ "acir", "blake2", @@ -63,7 +62,7 @@ dependencies = [ [[package]] name = "acvm_js" -version = "0.27.2" +version = "0.27.3" dependencies = [ "acvm", "barretenberg_blackbox_solver", @@ -84,7 +83,7 @@ dependencies = [ [[package]] name = "acvm_stdlib" -version = "0.27.2" +version = "0.27.3" dependencies = [ "acir", ] @@ -208,7 +207,7 @@ dependencies = [ [[package]] name = "arena" -version = "0.14.0" +version = "0.14.1" dependencies = [ "generational-arena", ] @@ -440,7 +439,7 @@ dependencies = [ [[package]] name = "barretenberg_blackbox_solver" -version = "0.27.2" +version = "0.27.3" dependencies = [ "acir", "acvm_blackbox_solver", @@ -562,7 +561,7 @@ dependencies = [ [[package]] name = "brillig" -version = "0.27.2" +version = "0.27.3" dependencies = [ "acir_field", "serde", @@ -570,7 +569,7 @@ dependencies = [ [[package]] name = "brillig_vm" -version = "0.27.2" +version = "0.27.3" dependencies = [ "acir", "acvm_blackbox_solver", @@ -1503,7 +1502,7 @@ dependencies = [ [[package]] name = "fm" -version = "0.14.0" +version = "0.14.1" dependencies = [ "cfg-if", "codespan-reporting", @@ -2036,7 +2035,7 @@ dependencies = [ [[package]] name = "iter-extended" -version = "0.14.0" +version = "0.14.1" [[package]] name = "itertools" @@ -2237,7 +2236,7 @@ checksum = "7843ec2de400bcbc6a6328c958dc38e5359da6e93e72e37bc5246bf1ae776389" [[package]] name = "nargo" -version = "0.14.0" +version = "0.14.1" dependencies = [ "acvm", "base64", @@ -2256,7 +2255,7 @@ dependencies = [ [[package]] name = "nargo_cli" -version = "0.14.0" +version = "0.14.1" dependencies = [ "acvm", "assert_cmd", @@ -2302,7 +2301,7 @@ dependencies = [ [[package]] name = "nargo_toml" -version = "0.14.0" +version = "0.14.1" dependencies = [ "dirs", "fm", @@ -2328,7 +2327,7 @@ dependencies = [ [[package]] name = "noir_lsp" -version = "0.14.0" +version = "0.14.1" dependencies = [ "acvm", "async-lsp", @@ -2351,7 +2350,7 @@ dependencies = [ [[package]] name = "noir_wasm" -version = "0.14.0" +version = "0.14.1" dependencies = [ "acvm", "build-data", @@ -2370,7 +2369,7 @@ dependencies = [ [[package]] name = "noirc_abi" -version = "0.14.0" +version = "0.14.1" dependencies = [ "acvm", "iter-extended", @@ -2387,7 +2386,7 @@ dependencies = [ [[package]] name = "noirc_abi_wasm" -version = "0.14.0" +version = "0.14.1" dependencies = [ "acvm", "build-data", @@ -2404,7 +2403,7 @@ dependencies = [ [[package]] name = "noirc_driver" -version = "0.14.0" +version = "0.14.1" dependencies = [ "acvm", "base64", @@ -2420,7 +2419,7 @@ dependencies = [ [[package]] name = "noirc_errors" -version = "0.14.0" +version = "0.14.1" dependencies = [ "acvm", "chumsky", @@ -2433,7 +2432,7 @@ dependencies = [ [[package]] name = "noirc_evaluator" -version = "0.14.0" +version = "0.14.1" dependencies = [ "acvm", "fxhash", @@ -2448,7 +2447,7 @@ dependencies = [ [[package]] name = "noirc_frontend" -version = "0.14.0" +version = "0.14.1" dependencies = [ "acvm", "arena", @@ -2469,7 +2468,7 @@ dependencies = [ [[package]] name = "noirc_printable_type" -version = "0.14.0" +version = "0.14.1" dependencies = [ "acvm", "iter-extended", @@ -3122,28 +3121,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "rmp" -version = "0.8.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f9860a6cc38ed1da53456442089b4dfa35e7cedaa326df63017af88385e6b20" -dependencies = [ - "byteorder", - "num-traits", - "paste", -] - -[[package]] -name = "rmp-serde" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bffea85eea980d8a74453e5d02a8d93028f3c34725de143085a844ebe953258a" -dependencies = [ - "byteorder", - "rmp", - "serde", -] - [[package]] name = "rust-embed" version = "6.8.1" diff --git a/Cargo.toml b/Cargo.toml index cfce632e762..f87f3b3d01a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,7 +36,7 @@ resolver = "2" [workspace.package] # x-release-please-start-version -version = "0.14.0" +version = "0.14.1" # x-release-please-end authors = ["The Noir Team "] edition = "2021" diff --git a/acvm-repo/.github/actions/setup/action.yml b/acvm-repo/.github/actions/setup/action.yml deleted file mode 100644 index aaffe2f5a3f..00000000000 --- a/acvm-repo/.github/actions/setup/action.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: Yarn Cache and Install -description: Installs dependencies and caches them - -inputs: - working-directory: - default: ./ - required: false - -runs: - using: composite - steps: - - name: Cache - uses: actions/cache@v3 - id: cache - with: - path: "**/node_modules" - key: yarn-v1-${{ hashFiles('**/yarn.lock') }} - - name: Install - working-directory: ${{ inputs.working-directory }} - run: yarn --immutable - shell: bash - if: steps.cache.outputs.cache-hit != 'true' diff --git a/acvm-repo/.github/workflows/deny.yml b/acvm-repo/.github/workflows/deny.yml deleted file mode 100644 index 1a6af18e7c5..00000000000 --- a/acvm-repo/.github/workflows/deny.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: deny - -on: - push: - branches: [master] - paths: [Cargo.lock, deny.toml] - pull_request: - branches: [master] - paths: [Cargo.lock, deny.toml] - merge_group: - -env: - RUSTFLAGS: -D warnings - CARGO_TERM_COLOR: always - -concurrency: deny-${{ github.head_ref || github.run_id }} - -jobs: - deny: - name: deny - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: EmbarkStudios/cargo-deny-action@v1 - with: - command: check all diff --git a/acvm-repo/.github/workflows/pull-request.yml b/acvm-repo/.github/workflows/pull-request.yml deleted file mode 100644 index 4b8a626a94e..00000000000 --- a/acvm-repo/.github/workflows/pull-request.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: Pull Request - -on: - merge_group: - pull_request_target: - types: - - opened - - reopened - - edited - - synchronize - -permissions: - pull-requests: read - -jobs: - conventional-title: - name: Validate PR title is Conventional Commit - runs-on: ubuntu-latest - steps: - - name: Check title - if: github.event_name == 'pull_request_target' - uses: amannn/action-semantic-pull-request@v5 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - types: | - fix - feat - chore diff --git a/acvm-repo/.github/workflows/spellcheck.yml b/acvm-repo/.github/workflows/spellcheck.yml deleted file mode 100644 index 6df9b22b850..00000000000 --- a/acvm-repo/.github/workflows/spellcheck.yml +++ /dev/null @@ -1,13 +0,0 @@ -name: Spellcheck - -on: [push] - -# This will cancel previous runs when a branch or PR is updated -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.ref || github.run_id }} - cancel-in-progress: true - -jobs: - spellcheck: - name: Spellcheck - uses: noir-lang/.github/.github/workflows/spellcheck.yml@main diff --git a/acvm-repo/.github/workflows/typescript.yml b/acvm-repo/.github/workflows/typescript.yml deleted file mode 100644 index 147bd356351..00000000000 --- a/acvm-repo/.github/workflows/typescript.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Typescript - -on: [push, pull_request] - -# This will cancel previous runs when a branch or PR is updated -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.ref || github.run_id }} - cancel-in-progress: true - -jobs: - eslint: - name: Eslint - runs-on: ubuntu-latest - - steps: - - name: Checkout sources - uses: actions/checkout@v4 - - - name: Install dependencies - uses: ./.github/actions/setup - with: - working-directory: ./acvm_js - - - name: Run eslint - working-directory: ./acvm_js - run: yarn lint diff --git a/acvm-repo/.gitignore b/acvm-repo/.gitignore deleted file mode 100644 index e6cd42a8496..00000000000 --- a/acvm-repo/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/target -.DS_Store -.vscode -# Cargo.lock -result -outputs/ diff --git a/acvm-repo/.release-please-manifest.json b/acvm-repo/.release-please-manifest.json deleted file mode 100644 index 1a52d4cb55a..00000000000 --- a/acvm-repo/.release-please-manifest.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - ".": "0.27.0", - "acir": "0.27.0", - "acir_field": "0.27.0", - "acvm": "0.27.0", - "acvm_js": "0.27.0", - "stdlib": "0.27.0", - "brillig": "0.27.0", - "brillig_vm": "0.27.0", - "blackbox_solver": "0.27.0", - "barretenberg_blackbox_solver": "0.27.0" -} diff --git a/acvm-repo/.rustfmt.toml b/acvm-repo/.rustfmt.toml deleted file mode 100644 index c13d3e328d4..00000000000 --- a/acvm-repo/.rustfmt.toml +++ /dev/null @@ -1,2 +0,0 @@ -edition = "2018" -use_small_heuristics = "Max" diff --git a/acvm-repo/CHANGELOG.md b/acvm-repo/CHANGELOG.md index 9e5b514991a..681e9119543 100644 --- a/acvm-repo/CHANGELOG.md +++ b/acvm-repo/CHANGELOG.md @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.27.3](https://github.com/noir-lang/noir/compare/v0.27.2...v0.27.3) (2023-09-27) + + +### Bug Fixes + +* **acvm:** Return false rather than panicking on invalid ECDSA signatures ([#2783](https://github.com/noir-lang/noir/issues/2783)) ([155abc0](https://github.com/noir-lang/noir/commit/155abc0d99fff41c79163c16bf297d41e5dff0fa)) + ## [0.27.2](https://github.com/noir-lang/noir/compare/v0.27.1...v0.27.2) (2023-09-27) diff --git a/acvm-repo/LICENSE-APACHE b/acvm-repo/LICENSE-APACHE deleted file mode 100644 index 261eeb9e9f8..00000000000 --- a/acvm-repo/LICENSE-APACHE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/acvm-repo/LICENSE-MIT b/acvm-repo/LICENSE-MIT deleted file mode 100644 index 61cc2f7f5e6..00000000000 --- a/acvm-repo/LICENSE-MIT +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - - Copyright (c) 2023 noir-lang - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. \ No newline at end of file diff --git a/acvm-repo/acir/Cargo.toml b/acvm-repo/acir/Cargo.toml index 9033ebe299e..a7c55b3d8ac 100644 --- a/acvm-repo/acir/Cargo.toml +++ b/acvm-repo/acir/Cargo.toml @@ -2,7 +2,7 @@ name = "acir" description = "ACIR is the IR that the VM processes, it is analogous to LLVM IR" # x-release-please-start-version -version = "0.27.2" +version = "0.27.3" # x-release-please-end authors.workspace = true edition.workspace = true @@ -17,7 +17,6 @@ acir_field.workspace = true brillig.workspace = true serde.workspace = true thiserror.workspace = true -rmp-serde = { version = "1.1.0", optional = true } flate2 = "1.0.24" bincode.workspace = true @@ -30,4 +29,3 @@ strum_macros = "0.24" default = ["bn254"] bn254 = ["acir_field/bn254", "brillig/bn254"] bls12_381 = ["acir_field/bls12_381", "brillig/bls12_381"] -serialize-messagepack = ["rmp-serde"] diff --git a/acvm-repo/acir/src/circuit/mod.rs b/acvm-repo/acir/src/circuit/mod.rs index d03240af2c3..eef5a5fb6bc 100644 --- a/acvm-repo/acir/src/circuit/mod.rs +++ b/acvm-repo/acir/src/circuit/mod.rs @@ -125,24 +125,6 @@ impl Circuit { PublicInputs(public_inputs) } - #[cfg(feature = "serialize-messagepack")] - pub fn write(&self, writer: W) -> std::io::Result<()> { - let buf = rmp_serde::to_vec(&self).unwrap(); - let mut deflater = flate2::write::DeflateEncoder::new(writer, Compression::best()); - deflater.write_all(&buf).unwrap(); - - Ok(()) - } - #[cfg(feature = "serialize-messagepack")] - pub fn read(reader: R) -> std::io::Result { - let mut deflater = flate2::read::DeflateDecoder::new(reader); - let mut buf_d = Vec::new(); - deflater.read_to_end(&mut buf_d).unwrap(); - let circuit = rmp_serde::from_slice(buf_d.as_slice()).unwrap(); - Ok(circuit) - } - - #[cfg(not(feature = "serialize-messagepack"))] pub fn write(&self, writer: W) -> std::io::Result<()> { let buf = bincode::serialize(&self).unwrap(); let mut encoder = flate2::write::GzEncoder::new(writer, Compression::default()); @@ -151,7 +133,6 @@ impl Circuit { Ok(()) } - #[cfg(not(feature = "serialize-messagepack"))] pub fn read(reader: R) -> std::io::Result { let mut gz_decoder = flate2::read::GzDecoder::new(reader); let mut buf_d = Vec::new(); diff --git a/acvm-repo/acir/src/native_types/witness_map.rs b/acvm-repo/acir/src/native_types/witness_map.rs index 400e0a8ca1a..1734b0b907f 100644 --- a/acvm-repo/acir/src/native_types/witness_map.rs +++ b/acvm-repo/acir/src/native_types/witness_map.rs @@ -13,20 +13,6 @@ use thiserror::Error; use crate::native_types::Witness; -#[cfg(feature = "serialize-messagepack")] -#[derive(Debug, Error)] -enum SerializationError { - #[error(transparent)] - MsgpackEncode(#[from] rmp_serde::encode::Error), - - #[error(transparent)] - MsgpackDecode(#[from] rmp_serde::decode::Error), - - #[error(transparent)] - Deflate(#[from] std::io::Error), -} - -#[cfg(not(feature = "serialize-messagepack"))] #[derive(Debug, Error)] enum SerializationError { #[error(transparent)] @@ -92,20 +78,6 @@ impl From> for WitnessMap { } } -#[cfg(feature = "serialize-messagepack")] -impl TryFrom for Vec { - type Error = WitnessMapError; - - fn try_from(val: WitnessMap) -> Result { - let buf = rmp_serde::to_vec(&val).map_err(|err| WitnessMapError(err.into()))?; - let mut deflater = flate2::write::DeflateEncoder::new(buf.as_slice(), Compression::best()); - let mut buf_c = Vec::new(); - deflater.read_to_end(&mut buf_c).map_err(|err| WitnessMapError(err.into()))?; - Ok(buf_c) - } -} - -#[cfg(not(feature = "serialize-messagepack"))] impl TryFrom for Vec { type Error = WitnessMapError; @@ -118,21 +90,6 @@ impl TryFrom for Vec { } } -#[cfg(feature = "serialize-messagepack")] -impl TryFrom<&[u8]> for WitnessMap { - type Error = WitnessMapError; - - fn try_from(bytes: &[u8]) -> Result { - let mut deflater = flate2::bufread::DeflateDecoder::new(bytes); - let mut buf_d = Vec::new(); - deflater.read_to_end(&mut buf_d).map_err(|err| WitnessMapError(err.into()))?; - let witness_map = - rmp_serde::from_slice(buf_d.as_slice()).map_err(|err| WitnessMapError(err.into()))?; - Ok(Self(witness_map)) - } -} - -#[cfg(not(feature = "serialize-messagepack"))] impl TryFrom<&[u8]> for WitnessMap { type Error = WitnessMapError; diff --git a/acvm-repo/acir_field/Cargo.toml b/acvm-repo/acir_field/Cargo.toml index 7a5533b0fc5..40f4abc8a07 100644 --- a/acvm-repo/acir_field/Cargo.toml +++ b/acvm-repo/acir_field/Cargo.toml @@ -2,7 +2,7 @@ name = "acir_field" description = "The field implementation being used by ACIR." # x-release-please-start-version -version = "0.27.2" +version = "0.27.3" # x-release-please-end authors.workspace = true edition.workspace = true diff --git a/acvm-repo/acvm/Cargo.toml b/acvm-repo/acvm/Cargo.toml index b404d76b321..19535607390 100644 --- a/acvm-repo/acvm/Cargo.toml +++ b/acvm-repo/acvm/Cargo.toml @@ -2,7 +2,7 @@ name = "acvm" description = "The virtual machine that processes ACIR given a backend/proof system." # x-release-please-start-version -version = "0.27.2" +version = "0.27.3" # x-release-please-end authors.workspace = true edition.workspace = true diff --git a/acvm-repo/acvm/src/compiler/transformers/csat.rs b/acvm-repo/acvm/src/compiler/transformers/csat.rs index 8976778547c..9f89ac4671a 100644 --- a/acvm-repo/acvm/src/compiler/transformers/csat.rs +++ b/acvm-repo/acvm/src/compiler/transformers/csat.rs @@ -235,8 +235,8 @@ impl CSatTransformer { opcode.mul_terms = remaining_mul_terms; // Add the rest of the elements back into the new_opcode - new_opcode.mul_terms.extend(opcode.mul_terms.clone()); - new_opcode.linear_combinations.extend(opcode.linear_combinations.clone()); + new_opcode.mul_terms.extend(opcode.mul_terms); + new_opcode.linear_combinations.extend(opcode.linear_combinations); new_opcode.q_c = opcode.q_c; new_opcode.sort(); new_opcode @@ -332,7 +332,7 @@ impl CSatTransformer { // 2. Create Intermediate variables for the multiplication opcodes let mut remaining_mul_terms = Vec::with_capacity(opcode.mul_terms.len()); - for mul_term in opcode.mul_terms.clone().into_iter() { + for mul_term in opcode.mul_terms { if self.solvable_witness.contains(&mul_term.1) && self.solvable_witness.contains(&mul_term.2) { diff --git a/acvm-repo/acvm/src/compiler/transformers/fallback.rs b/acvm-repo/acvm/src/compiler/transformers/fallback.rs index e96fa7283bd..d3e4ea506f8 100644 --- a/acvm-repo/acvm/src/compiler/transformers/fallback.rs +++ b/acvm-repo/acvm/src/compiler/transformers/fallback.rs @@ -106,12 +106,8 @@ impl FallbackTransformer { } #[cfg(feature = "unstable-fallbacks")] BlackBoxFuncCall::SHA256 { inputs, outputs } => { - let mut sha256_inputs = Vec::new(); - for input in inputs.iter() { - let witness_index = Expression::from(input.witness); - let num_bits = input.num_bits; - sha256_inputs.push((witness_index, num_bits)); - } + let sha256_inputs = + inputs.iter().map(|input| (input.witness.into(), input.num_bits)).collect(); stdlib::blackbox_fallbacks::sha256( sha256_inputs, outputs.to_vec(), @@ -120,42 +116,30 @@ impl FallbackTransformer { } #[cfg(feature = "unstable-fallbacks")] BlackBoxFuncCall::Blake2s { inputs, outputs } => { - let mut blake2s_input = Vec::new(); - for input in inputs.iter() { - let witness_index = Expression::from(input.witness); - let num_bits = input.num_bits; - blake2s_input.push((witness_index, num_bits)); - } + let blake2s_inputs = + inputs.iter().map(|input| (input.witness.into(), input.num_bits)).collect(); stdlib::blackbox_fallbacks::blake2s( - blake2s_input, + blake2s_inputs, outputs.to_vec(), current_witness_idx, ) } #[cfg(feature = "unstable-fallbacks")] BlackBoxFuncCall::HashToField128Security { inputs, output } => { - let mut blake2s_input = Vec::new(); - for input in inputs.iter() { - let witness_index = Expression::from(input.witness); - let num_bits = input.num_bits; - blake2s_input.push((witness_index, num_bits)); - } + let hash_to_field_inputs = + inputs.iter().map(|input| (input.witness.into(), input.num_bits)).collect(); stdlib::blackbox_fallbacks::hash_to_field( - blake2s_input, + hash_to_field_inputs, *output, current_witness_idx, ) } #[cfg(feature = "unstable-fallbacks")] BlackBoxFuncCall::Keccak256 { inputs, outputs } => { - let mut keccak_input = Vec::new(); - for input in inputs.iter() { - let witness_index = Expression::from(input.witness); - let num_bits = input.num_bits; - keccak_input.push((witness_index, num_bits)); - } + let keccak_inputs = + inputs.iter().map(|input| (input.witness.into(), input.num_bits)).collect(); stdlib::blackbox_fallbacks::keccak256( - keccak_input, + keccak_inputs, outputs.to_vec(), current_witness_idx, ) diff --git a/acvm-repo/acvm_js/Cargo.toml b/acvm-repo/acvm_js/Cargo.toml index 855ea5202c3..bcb9e34ad04 100644 --- a/acvm-repo/acvm_js/Cargo.toml +++ b/acvm-repo/acvm_js/Cargo.toml @@ -2,7 +2,7 @@ name = "acvm_js" description = "Typescript wrapper around the ACVM allowing execution of ACIR code" # x-release-please-start-version -version = "0.27.2" +version = "0.27.3" # x-release-please-end authors.workspace = true edition.workspace = true diff --git a/acvm-repo/acvm_js/build.sh b/acvm-repo/acvm_js/build.sh index 8157e42c6de..37f2fd0a5a9 100755 --- a/acvm-repo/acvm_js/build.sh +++ b/acvm-repo/acvm_js/build.sh @@ -22,14 +22,13 @@ function run_or_fail { fi } -require_command toml2json require_command jq require_command cargo require_command wasm-bindgen check_installed wasm-opt self_path=$(dirname "$(readlink -f "$0")") -export pname=$(toml2json < $self_path/Cargo.toml | jq -r .package.name) +export pname=$(cargo read-manifest | jq -r '.name') export CARGO_TARGET_DIR=$self_path/target rm -rf $self_path/outputs >/dev/null 2>&1 @@ -45,4 +44,4 @@ fi run_or_fail $self_path/buildPhaseCargoCommand.sh run_or_fail $self_path/installPhase.sh -ln -s $out $self_path/result \ No newline at end of file +ln -s $out $self_path/result diff --git a/acvm-repo/acvm_js/package.json b/acvm-repo/acvm_js/package.json index d1a2c2f7bfa..990ce0de7ef 100644 --- a/acvm-repo/acvm_js/package.json +++ b/acvm-repo/acvm_js/package.json @@ -1,6 +1,6 @@ { "name": "@noir-lang/acvm_js", - "version": "0.27.2", + "version": "0.27.3", "private": true, "repository": { "type": "git", @@ -27,7 +27,8 @@ "build": "bash ./build.sh", "test": "env TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\" }' mocha", "test:browser": "web-test-runner", - "lint": "NODE_NO_WARNINGS=1 eslint . --ext .ts --ignore-path ./.eslintignore --max-warnings 0" + "lint": "NODE_NO_WARNINGS=1 eslint . --ext .ts --ignore-path ./.eslintignore --max-warnings 0", + "clean": "chmod u+w web nodejs && rm -rf web nodejs" }, "devDependencies": { "@esm-bundle/chai": "^4.3.4-fix.0", diff --git a/acvm-repo/barretenberg_blackbox_solver/Cargo.toml b/acvm-repo/barretenberg_blackbox_solver/Cargo.toml index 95e1555a427..eb7ad6a093e 100644 --- a/acvm-repo/barretenberg_blackbox_solver/Cargo.toml +++ b/acvm-repo/barretenberg_blackbox_solver/Cargo.toml @@ -2,7 +2,7 @@ name = "barretenberg_blackbox_solver" description = "A wrapper around a barretenberg WASM binary to execute black box functions for which there is no rust implementation" # x-release-please-start-version -version = "0.27.2" +version = "0.27.3" # x-release-please-end authors.workspace = true edition.workspace = true diff --git a/acvm-repo/blackbox_solver/Cargo.toml b/acvm-repo/blackbox_solver/Cargo.toml index 418c4a404df..1d2676d00b0 100644 --- a/acvm-repo/blackbox_solver/Cargo.toml +++ b/acvm-repo/blackbox_solver/Cargo.toml @@ -2,7 +2,7 @@ name = "acvm_blackbox_solver" description = "A solver for the blackbox functions found in ACIR and Brillig" # x-release-please-start-version -version = "0.27.2" +version = "0.27.3" # x-release-please-end authors.workspace = true edition.workspace = true diff --git a/acvm-repo/brillig/Cargo.toml b/acvm-repo/brillig/Cargo.toml index 99ff19dae59..6d27b7b7da2 100644 --- a/acvm-repo/brillig/Cargo.toml +++ b/acvm-repo/brillig/Cargo.toml @@ -2,7 +2,7 @@ name = "brillig" description = "Brillig is the bytecode ACIR uses for non-determinism." # x-release-please-start-version -version = "0.27.2" +version = "0.27.3" # x-release-please-end authors.workspace = true edition.workspace = true diff --git a/acvm-repo/brillig_vm/Cargo.toml b/acvm-repo/brillig_vm/Cargo.toml index 0c24a4b676b..45ac57283a6 100644 --- a/acvm-repo/brillig_vm/Cargo.toml +++ b/acvm-repo/brillig_vm/Cargo.toml @@ -2,7 +2,7 @@ name = "brillig_vm" description = "The virtual machine that processes Brillig bytecode, used to introduce non-determinism to the ACVM" # x-release-please-start-version -version = "0.27.2" +version = "0.27.3" # x-release-please-end authors.workspace = true edition.workspace = true diff --git a/acvm-repo/cspell.json b/acvm-repo/cspell.json deleted file mode 100644 index 2af69b7dc30..00000000000 --- a/acvm-repo/cspell.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "version": "0.2", - "words": [ - "blackbox", - // In code - // - "acir", - "ACIR", - "ACVM", - "Axyz", - "arithmetization", - "Barretenberg", - "bindgen", - "bivariate", - "barretenberg", - "Brillig", - "canonicalize", - "callstack", - "coeff", - "consts", - "csat", - "decomp", - "deflater", - "endianness", - "euclidian", - "funcs", - "grumpkin", - "hasher", - "jsdoc", - "keccak", - "Merkle", - "OddRange", - "Pedersen", - "PLONKC", - "prehashed", - "pubkey", - "repr", - "secp", - "Schnorr", - "Shleft", - "Shright", - "stdlib", - "struct", - "TORADIX", - "Msgpack", - // Dependencies - // - "bindir", - "bufread", - "flate", - "indexmap", - "thiserror", - "typenum", - "jmpif", - "jmpifnot", - "rustc" - ] -} diff --git a/acvm-repo/deny.toml b/acvm-repo/deny.toml deleted file mode 100644 index 397337c3b09..00000000000 --- a/acvm-repo/deny.toml +++ /dev/null @@ -1,88 +0,0 @@ -# This section is considered when running `cargo deny check advisories` -# More documentation for the advisories section can be found here: -# https://embarkstudios.github.io/cargo-deny/checks/advisories/cfg.html -[advisories] -vulnerability = "deny" -unmaintained = "warn" -unsound = "warn" -yanked = "warn" -notice = "warn" - -# This section is considered when running `cargo deny check bans`. -# More documentation about the 'bans' section can be found here: -# https://embarkstudios.github.io/cargo-deny/checks/bans/cfg.html -[bans] -# Lint level for when multiple versions of the same crate are detected -multiple-versions = "warn" -# Lint level for when a crate version requirement is `*` -wildcards = "deny" -highlight = "all" -# List of crates to deny -deny = [ - # Each entry the name of a crate and a version range. If version is - # not specified, all versions will be matched. - #{ name = "ansi_term", version = "=0.11.0" }, -] -# Certain crates/versions that will be skipped when doing duplicate detection. -skip = [] -# Similarly to `skip` allows you to skip certain crates during duplicate -# detection. Unlike skip, it also includes the entire tree of transitive -# dependencies starting at the specified crate, up to a certain depth, which is -# by default infinite -skip-tree = [] - -[licenses] -unlicensed = "deny" -confidence-threshold = 0.9 -# copyleft = "deny" - -# List of explicitly allowed licenses -# See https://spdx.org/licenses/ for list of possible licenses -# [possible values: any SPDX 3.7 short identifier (+ optional exception)]. -allow = [ - "MIT", - "Apache-2.0", - "Apache-2.0 WITH LLVM-exception", - "BSD-2-Clause", - "BSD-3-Clause", - "ISC", - "0BSD", - "Unicode-DFS-2016", - "Unlicense", - # https://github.com/briansmith/ring/issues/902 - "LicenseRef-ring", - # https://github.com/rustls/webpki/blob/main/LICENSE ISC Style - "LicenseRef-rustls-webpki", -] - -# Allow 1 or more licenses on a per-crate basis, so that particular licenses -# aren't accepted for every possible crate as with the normal allow list -exceptions = [ - # CC0 is a permissive license but somewhat unclear status for source code - # so we prefer to not have dependencies using it - # https://tldrlegal.com/license/creative-commons-cc0-1.0-universal - { allow = ["CC0-1.0"], name = "more-asserts" }, - { allow = ["MPL-2.0"], name = "webpki-roots" }, -] - -[[licenses.clarify]] -name = "ring" -expression = "LicenseRef-ring" -license-files = [{ path = "LICENSE", hash = 0xbd0eed23 }] - -[[licenses.clarify]] -name = "rustls-webpki" -expression = "LicenseRef-rustls-webpki" -license-files = [{ path = "LICENSE", hash = 0x001c7e6c }] - -# This section is considered when running `cargo deny check sources`. -# More documentation about the 'sources' section can be found here: -# https://embarkstudios.github.io/cargo-deny/checks/sources/cfg.html -[sources] -# Lint level for what to happen when a crate from a crate registry that is not -# in the allow list is encountered -unknown-registry = "warn" -# Lint level for what to happen when a crate from a git repository that is not -# in the allow list is encountered -unknown-git = "deny" -allow-git = [] diff --git a/acvm-repo/release-please-config.json b/acvm-repo/release-please-config.json deleted file mode 100644 index f00086319f0..00000000000 --- a/acvm-repo/release-please-config.json +++ /dev/null @@ -1,97 +0,0 @@ -{ - "release-type": "rust", - "bump-minor-pre-major": true, - "bump-patch-for-minor-pre-major": true, - "group-pull-request-title-pattern": "chore: Release ${version}", - "packages": { - ".": { - "release-type": "simple", - "component": "root", - "extra-files": [ - { - "type": "toml", - "path": "Cargo.toml", - "jsonpath": "$.workspace.dependencies.acir.version" - }, - { - "type": "toml", - "path": "Cargo.toml", - "jsonpath": "$.workspace.dependencies.acir_field.version" - }, - { - "type": "toml", - "path": "Cargo.toml", - "jsonpath": "$.workspace.dependencies.stdlib.version" - }, - { - "type": "toml", - "path": "Cargo.toml", - "jsonpath": "$.workspace.dependencies.brillig.version" - }, - { - "type": "toml", - "path": "Cargo.toml", - "jsonpath": "$.workspace.dependencies.brillig_vm.version" - }, - { - "type": "toml", - "path": "Cargo.toml", - "jsonpath": "$.workspace.dependencies.acvm_blackbox_solver.version" - }, - { - "type": "json", - "path": "acvm_js/package.json", - "jsonpath": "$.version" - } - ] - }, - "acir": { - "component": "acir" - }, - "acir_field": { - "component": "acir_field" - }, - "acvm": { - "component": "acvm" - }, - "acvm_js": { - "component": "acvm_js" - }, - "brillig": { - "component": "brillig" - }, - "brillig_vm": { - "component": "brillig_vm" - }, - "stdlib": { - "component": "acvm_stdlib" - }, - "blackbox_solver": { - "component": "acvm_blackbox_solver" - }, - "barretenberg_blackbox_solver": { - "component": "barretenberg_blackbox_solver" - } - }, - "plugins": [ - { - "type": "cargo-workspace", - "merge": false - }, - { - "type": "linked-versions", - "groupName": "acvm", - "components": [ - "root", - "acir", - "acir_field", - "acvm", - "acvm_js", - "brillig", - "brillig_vm", - "acvm_stdlib", - "acvm_blackbox_solver" - ] - } - ] -} \ No newline at end of file diff --git a/acvm-repo/stdlib/Cargo.toml b/acvm-repo/stdlib/Cargo.toml index e4d90095a2f..50510feac69 100644 --- a/acvm-repo/stdlib/Cargo.toml +++ b/acvm-repo/stdlib/Cargo.toml @@ -2,7 +2,7 @@ name = "acvm_stdlib" description = "The ACVM standard library." # x-release-please-start-version -version = "0.27.2" +version = "0.27.3" # x-release-please-end authors.workspace = true edition.workspace = true diff --git a/compiler/fm/src/file_reader.rs b/compiler/fm/src/file_reader.rs index 08df5abc349..6cf90734e18 100644 --- a/compiler/fm/src/file_reader.rs +++ b/compiler/fm/src/file_reader.rs @@ -21,6 +21,28 @@ pub(super) fn is_stdlib_asset(path: &Path) -> bool { path.starts_with("std/") } +fn get_stdlib_asset(path: &Path) -> std::io::Result { + if !is_stdlib_asset(path) { + return Err(Error::new(ErrorKind::InvalidInput, "requested a non-stdlib asset")); + } + + match StdLibAssets::get(path.to_str().unwrap()) { + Some(std_lib_asset) => { + Ok(std::str::from_utf8(std_lib_asset.data.as_ref()).unwrap().to_string()) + } + + None => Err(Error::new(ErrorKind::NotFound, "invalid stdlib path")), + } +} + +pub(crate) fn read_file_to_string(path_to_file: &Path) -> std::io::Result { + if is_stdlib_asset(path_to_file) { + get_stdlib_asset(path_to_file) + } else { + get_non_stdlib_asset(path_to_file) + } +} + cfg_if::cfg_if! { if #[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))] { use wasm_bindgen::{prelude::*, JsValue}; @@ -33,42 +55,17 @@ cfg_if::cfg_if! { } - pub(crate) fn read_file_to_string(path_to_file: &Path) -> Result { + fn get_non_stdlib_asset(path_to_file: &Path) -> std::io::Result { let path_str = path_to_file.to_str().unwrap(); - match StdLibAssets::get(path_str) { - - Some(std_lib_asset) => { - Ok(std::str::from_utf8(std_lib_asset.data.as_ref()).unwrap().to_string()) - }, - - None if is_stdlib_asset(path_to_file) => { - Err(Error::new(ErrorKind::NotFound, "invalid stdlib path")) - } - - None => match read_file(path_str) { - Ok(buffer) => Ok(buffer), - Err(_) => Err(Error::new(ErrorKind::Other, "could not read file using wasm")), - } - + match read_file(path_str) { + Ok(buffer) => Ok(buffer), + Err(_) => Err(Error::new(ErrorKind::Other, "could not read file using wasm")), } } } else { - pub(crate) fn read_file_to_string(path_to_file: &Path) -> Result { - - match StdLibAssets::get(path_to_file.to_str().unwrap()) { - - Some(std_lib_asset) => { - Ok(std::str::from_utf8(std_lib_asset.data.as_ref()).unwrap().to_string()) - }, - - None if is_stdlib_asset(path_to_file) => { - Err(Error::new(ErrorKind::NotFound, "invalid stdlib path")) - } - - None => std::fs::read_to_string(path_to_file) - - } + fn get_non_stdlib_asset(path_to_file: &Path) -> std::io::Result { + std::fs::read_to_string(path_to_file) } } } diff --git a/compiler/noirc_driver/src/contract.rs b/compiler/noirc_driver/src/contract.rs index 69a92764318..a16da313ff6 100644 --- a/compiler/noirc_driver/src/contract.rs +++ b/compiler/noirc_driver/src/contract.rs @@ -3,7 +3,7 @@ use std::collections::BTreeMap; use acvm::acir::circuit::Circuit; use fm::FileId; -use noirc_abi::Abi; +use noirc_abi::{Abi, ContractEvent}; use noirc_errors::debug_info::DebugInfo; use super::debug::DebugFile; @@ -34,6 +34,11 @@ pub struct CompiledContract { /// stored in this `Vector`. pub functions: Vec, + /// All the events defined inside the contract scope. + /// An event is a struct value that can be emitted via oracles + /// by any contract function during execution. + pub events: Vec, + pub file_map: BTreeMap, } diff --git a/compiler/noirc_driver/src/lib.rs b/compiler/noirc_driver/src/lib.rs index 60073f9cc84..381a29ffcda 100644 --- a/compiler/noirc_driver/src/lib.rs +++ b/compiler/noirc_driver/src/lib.rs @@ -6,7 +6,7 @@ use clap::Args; use debug::filter_relevant_files; use fm::FileId; -use noirc_abi::{AbiParameter, AbiType}; +use noirc_abi::{AbiParameter, AbiType, ContractEvent}; use noirc_errors::{CustomDiagnostic, FileDiagnostic}; use noirc_evaluator::{create_circuit, into_abi_params}; use noirc_frontend::graph::{CrateId, CrateName}; @@ -285,7 +285,20 @@ fn compile_contract_inner( let debug_infos: Vec<_> = functions.iter().map(|function| function.debug.clone()).collect(); let file_map = filter_relevant_files(&debug_infos, &context.file_manager); - Ok(CompiledContract { name: contract.name, functions, file_map }) + Ok(CompiledContract { + name: contract.name, + events: contract + .events + .iter() + .map(|event_id| { + let typ = context.def_interner.get_struct(*event_id); + let typ = typ.borrow(); + ContractEvent::from_struct_type(context, &typ) + }) + .collect(), + functions, + file_map, + }) } else { Err(errors) } diff --git a/compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_block.rs b/compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_block.rs index eb2eb1e5f24..9d2a7245e87 100644 --- a/compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_block.rs +++ b/compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_block.rs @@ -1034,29 +1034,12 @@ impl<'block> BrilligBlock<'block> { let binary_type = type_of_binary_operation(dfg[binary.lhs].get_type(), dfg[binary.rhs].get_type()); - let mut left = self.convert_ssa_register_value(binary.lhs, dfg); - let mut right = self.convert_ssa_register_value(binary.rhs, dfg); + let left = self.convert_ssa_register_value(binary.lhs, dfg); + let right = self.convert_ssa_register_value(binary.rhs, dfg); let brillig_binary_op = convert_ssa_binary_op_to_brillig_binary_op(binary.operator, &binary_type); - // Some binary operations with fields are issued by the compiler, such as loop comparisons, cast those to the bit size here - // TODO Remove after fixing https://github.com/noir-lang/noir/issues/1979 - if let ( - BrilligBinaryOp::Integer { bit_size, .. }, - Type::Numeric(NumericType::NativeField), - ) = (&brillig_binary_op, &binary_type) - { - let new_lhs = self.brillig_context.allocate_register(); - let new_rhs = self.brillig_context.allocate_register(); - - self.brillig_context.cast_instruction(new_lhs, left, *bit_size); - self.brillig_context.cast_instruction(new_rhs, right, *bit_size); - - left = new_lhs; - right = new_rhs; - } - self.brillig_context.binary_instruction(left, right, result_register, brillig_binary_op); } diff --git a/compiler/noirc_evaluator/src/ssa/acir_gen/acir_ir/generated_acir.rs b/compiler/noirc_evaluator/src/ssa/acir_gen/acir_ir/generated_acir.rs index 8e6237a40f4..a2a85498f16 100644 --- a/compiler/noirc_evaluator/src/ssa/acir_gen/acir_ir/generated_acir.rs +++ b/compiler/noirc_evaluator/src/ssa/acir_gen/acir_ir/generated_acir.rs @@ -596,10 +596,12 @@ impl GeneratedAcir { // we now have lhs+offset <= rhs <=> lhs_offset <= rhs_offset let bit_size = bit_size_u128(rhs_offset); - // r = 2^bit_size - rhs_offset + // r = 2^bit_size - rhs_offset -1, is of bit size 'bit_size' by construtction let r = (1_u128 << bit_size) - rhs_offset - 1; + // however, since it is a constant, we can compute it's actual bit size + let r_bit_size = bit_size_u128(r); // witness = lhs_offset + r - assert!(bits + bit_size < FieldElement::max_num_bits()); //we need to ensure lhs_offset + r does not overflow + assert!(bits + r_bit_size < FieldElement::max_num_bits()); //we need to ensure lhs_offset + r does not overflow let mut aor = lhs_offset; aor.q_c += FieldElement::from(r); let witness = self.get_or_create_witness(&aor); @@ -607,7 +609,6 @@ impl GeneratedAcir { self.range_constraint(witness, bit_size)?; return Ok(()); } - // General case: lhs_offset<=rhs <=> rhs-lhs_offset>=0 <=> rhs-lhs_offset is a 'bits' bit integer let sub_expression = rhs - &lhs_offset; //rhs-lhs_offset let w = self.create_witness_for_expression(&sub_expression); diff --git a/compiler/noirc_frontend/src/hir/def_map/mod.rs b/compiler/noirc_frontend/src/hir/def_map/mod.rs index 4226454f903..27f757074f6 100644 --- a/compiler/noirc_frontend/src/hir/def_map/mod.rs +++ b/compiler/noirc_frontend/src/hir/def_map/mod.rs @@ -1,9 +1,9 @@ use crate::graph::CrateId; use crate::hir::def_collector::dc_crate::{CompilationError, DefCollector}; use crate::hir::Context; -use crate::node_interner::{FuncId, NodeInterner}; +use crate::node_interner::{FuncId, NodeInterner, StructId}; use crate::parser::{parse_program, ParsedModule, ParserError}; -use crate::token::{FunctionAttribute, TestScope}; +use crate::token::{FunctionAttribute, SecondaryAttribute, TestScope}; use arena::{Arena, Index}; use fm::{FileId, FileManager}; use noirc_errors::Location; @@ -182,8 +182,20 @@ impl CrateDefMap { }) .collect(); + let events = module + .type_definitions() + .filter_map(|id| { + id.as_type().filter(|struct_id| { + interner + .struct_attributes(struct_id) + .iter() + .any(|attr| attr == &SecondaryAttribute::Event) + }) + }) + .collect(); + let name = self.get_module_path(id, module.parent); - Some(Contract { name, location: module.location, functions }) + Some(Contract { name, location: module.location, functions, events }) } else { None } @@ -236,13 +248,14 @@ pub struct ContractFunctionMeta { pub is_entry_point: bool, } -/// A 'contract' in Noir source code with the given name and functions. +/// A 'contract' in Noir source code with a given name, functions and events. /// This is not an AST node, it is just a convenient form to return for CrateDefMap::get_all_contracts. pub struct Contract { /// To keep `name` semi-unique, it is prefixed with the names of parent modules via CrateDefMap::get_module_path pub name: String, pub location: Location, pub functions: Vec, + pub events: Vec, } /// Given a FileId, fetch the File, from the FileManager and parse it's content diff --git a/compiler/noirc_frontend/src/hir/def_map/module_data.rs b/compiler/noirc_frontend/src/hir/def_map/module_data.rs index 1f1fa44108d..f86cce75479 100644 --- a/compiler/noirc_frontend/src/hir/def_map/module_data.rs +++ b/compiler/noirc_frontend/src/hir/def_map/module_data.rs @@ -97,6 +97,10 @@ impl ModuleData { self.scope.find_name(name) } + pub fn type_definitions(&self) -> impl Iterator + '_ { + self.definitions.types().values().map(|(id, _)| *id) + } + /// Return an iterator over all definitions defined within this module, /// excluding any type definitions. pub fn value_definitions(&self) -> impl Iterator + '_ { diff --git a/compiler/noirc_frontend/src/lexer/token.rs b/compiler/noirc_frontend/src/lexer/token.rs index 9eaa4fa75e5..6aabacd8940 100644 --- a/compiler/noirc_frontend/src/lexer/token.rs +++ b/compiler/noirc_frontend/src/lexer/token.rs @@ -467,6 +467,7 @@ impl Attribute { ["contract_library_method"] => { Attribute::Secondary(SecondaryAttribute::ContractLibraryMethod) } + ["event"] => Attribute::Secondary(SecondaryAttribute::Event), ["deprecated", name] => { if !name.starts_with('"') && !name.ends_with('"') { return Err(LexerErrorKind::MalformedFuncAttribute { @@ -544,6 +545,7 @@ pub enum SecondaryAttribute { // is a helper method for a contract and should not be seen as // the entry point. ContractLibraryMethod, + Event, Custom(String), } @@ -556,6 +558,7 @@ impl fmt::Display for SecondaryAttribute { } SecondaryAttribute::Custom(ref k) => write!(f, "#[{k}]"), SecondaryAttribute::ContractLibraryMethod => write!(f, "#[contract_library_method]"), + SecondaryAttribute::Event => write!(f, "#[event]"), } } } @@ -578,6 +581,7 @@ impl AsRef for SecondaryAttribute { SecondaryAttribute::Deprecated(None) => "", SecondaryAttribute::Custom(string) => string, SecondaryAttribute::ContractLibraryMethod => "", + SecondaryAttribute::Event => "", } } } diff --git a/compiler/noirc_frontend/src/node_interner.rs b/compiler/noirc_frontend/src/node_interner.rs index 01633c29178..ce08f3ebec1 100644 --- a/compiler/noirc_frontend/src/node_interner.rs +++ b/compiler/noirc_frontend/src/node_interner.rs @@ -19,7 +19,7 @@ use crate::hir_def::{ function::{FuncMeta, HirFunction}, stmt::HirStatement, }; -use crate::token::Attributes; +use crate::token::{Attributes, SecondaryAttribute}; use crate::{ ContractFunctionType, FunctionDefinition, Generics, Shared, TypeAliasType, TypeBinding, TypeBindings, TypeVariable, TypeVariableId, TypeVariableKind, Visibility, @@ -32,6 +32,8 @@ pub struct TraitImplKey { // pub generics: Generics - TODO } +type StructAttributes = Vec; + /// The node interner is the central storage location of all nodes in Noir's Hir (the /// various node types can be found in hir_def). The interner is also used to collect /// extra information about the Hir, such as the type of each node, information about @@ -73,6 +75,7 @@ pub struct NodeInterner { // methods from impls to the type. structs: HashMap>, + struct_attributes: HashMap, // Type Aliases map. // // Map type aliases to the actual type. @@ -365,6 +368,7 @@ impl Default for NodeInterner { definitions: vec![], id_to_type: HashMap::new(), structs: HashMap::new(), + struct_attributes: HashMap::new(), type_aliases: Vec::new(), traits: HashMap::new(), trait_implementations: HashMap::new(), @@ -456,6 +460,7 @@ impl NodeInterner { let new_struct = StructType::new(struct_id, name, typ.struct_def.span, no_fields, generics); self.structs.insert(struct_id, Shared::new(new_struct)); + self.struct_attributes.insert(struct_id, typ.struct_def.attributes.clone()); struct_id } @@ -678,6 +683,10 @@ impl NodeInterner { &self.function_modifiers[func_id].attributes } + pub fn struct_attributes(&self, struct_id: &StructId) -> &StructAttributes { + &self.struct_attributes[struct_id] + } + /// Returns the interned statement corresponding to `stmt_id` pub fn statement(&self, stmt_id: &StmtId) -> HirStatement { let def = diff --git a/compiler/source-resolver/package.json b/compiler/source-resolver/package.json index d7cc17e94b4..4b8f39a2410 100644 --- a/compiler/source-resolver/package.json +++ b/compiler/source-resolver/package.json @@ -1,6 +1,6 @@ { "name": "@noir-lang/source-resolver", - "version": "0.14.0", + "version": "0.14.1", "license": "MIT", "main": "./lib-node/index_node.js", "types": "./types/index_node.d.ts", diff --git a/compiler/wasm/build.sh b/compiler/wasm/build.sh index 8157e42c6de..37f2fd0a5a9 100755 --- a/compiler/wasm/build.sh +++ b/compiler/wasm/build.sh @@ -22,14 +22,13 @@ function run_or_fail { fi } -require_command toml2json require_command jq require_command cargo require_command wasm-bindgen check_installed wasm-opt self_path=$(dirname "$(readlink -f "$0")") -export pname=$(toml2json < $self_path/Cargo.toml | jq -r .package.name) +export pname=$(cargo read-manifest | jq -r '.name') export CARGO_TARGET_DIR=$self_path/target rm -rf $self_path/outputs >/dev/null 2>&1 @@ -45,4 +44,4 @@ fi run_or_fail $self_path/buildPhaseCargoCommand.sh run_or_fail $self_path/installPhase.sh -ln -s $out $self_path/result \ No newline at end of file +ln -s $out $self_path/result diff --git a/compiler/wasm/package.json b/compiler/wasm/package.json index c2f815abedc..7bab66299b4 100644 --- a/compiler/wasm/package.json +++ b/compiler/wasm/package.json @@ -3,7 +3,7 @@ "collaborators": [ "The Noir Team " ], - "version": "0.14.0", + "version": "0.14.1", "license": "(MIT OR Apache-2.0)", "main": "./nodejs/noir_wasm.js", "types": "./web/noir_wasm.d.ts", @@ -23,7 +23,7 @@ "test": "env TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\" }' mocha", "test:node": "env TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\" }' mocha", "test:browser": "web-test-runner", - "clean": "rm -rf ./nodejs ./web ./target", + "clean": "chmod u+w web nodejs && rm -rf ./nodejs ./web ./target ./result", "lint": "NODE_NO_WARNINGS=1 eslint . --ext .ts --ignore-path ./.eslintignore --max-warnings 0" }, "peerDependencies": { diff --git a/flake.nix b/flake.nix index fe422a02848..8c8371720b4 100644 --- a/flake.nix +++ b/flake.nix @@ -73,7 +73,7 @@ # Configuration shared between builds config = { # x-release-please-start-version - version = "0.14.0"; + version = "0.14.1"; # x-release-please-end src = pkgs.lib.cleanSourceWith { @@ -109,7 +109,6 @@ rustToolchain wasm-bindgen-cli binaryen - toml2json ]; buildInputs = [ ] ++ extraBuildInputs; @@ -236,6 +235,7 @@ # Nix flakes cannot build more than one derivation in one command (see https://github.com/NixOS/nix/issues/5591) # so we use `symlinkJoin` to build everything as the "all" package. all = pkgs.symlinkJoin { name = "all"; paths = [ nargo noir_wasm noirc_abi_wasm acvm_js ]; }; + all_wasm = pkgs.symlinkJoin { name = "all_wasm"; paths = [ noir_wasm noirc_abi_wasm acvm_js ]; }; # We also export individual packages to enable `nix build .#nargo -L`, etc. inherit nargo; diff --git a/package.json b/package.json index 84cada28471..84d44a38383 100644 --- a/package.json +++ b/package.json @@ -12,17 +12,18 @@ "release-tests" ], "scripts": { - "build": "yarn workspaces foreach run build", + "build": "yarn workspaces foreach --parallel --topological-dev --verbose run build", "test": "yarn workspaces foreach run test", "test:integration": "yarn workspace integration-tests test", - "clean:workspaces": "yarn workspaces foreach run clean", + "clean:workspaces": "yarn workspaces foreach --exclude @noir-lang/root run clean", "clean:root": "rm -rf ./result ./target", - "clean": "yarn clean:workspaces && yarn clean:parent", + "clean": "yarn clean:workspaces && yarn clean:root", "lint": "yarn workspaces foreach run lint", - "build:with:nix": "nix build -L .#wasm", + "build:with:nix": "nix build -L .#all_wasm", "install:from:nix:noirc_abi_wasm": "cp -r ./result/noirc_abi_wasm/nodejs ./tooling/noirc_abi_wasm && cp -r ./result/noirc_abi_wasm/web ./tooling/noirc_abi_wasm", "install:from:nix:noir_wasm": "cp -r ./result/noir_wasm/nodejs ./compiler/wasm && cp -r ./result/noir_wasm/web ./compiler/wasm", - "install:from:nix": "yarn build:with:nix && yarn install:from:nix:noirc_abi_wasm && yarn install:from:nix:noir_wasm" + "install:from:nix:acvm_js": "cp -rf ./result/acvm_js/nodejs ./acvm-repo/acvm_js && cp -rf ./result/acvm_js/web ./acvm-repo/acvm_js", + "install:from:nix": "yarn build:with:nix && yarn install:from:nix:noirc_abi_wasm && yarn install:from:nix:noir_wasm && yarn install:from:nix:acvm_js" }, "devDependencies": { "@typescript-eslint/eslint-plugin": "^5.59.5", diff --git a/tooling/nargo/src/artifacts/contract.rs b/tooling/nargo/src/artifacts/contract.rs index 4db7d95731e..fa161b63a5b 100644 --- a/tooling/nargo/src/artifacts/contract.rs +++ b/tooling/nargo/src/artifacts/contract.rs @@ -1,5 +1,5 @@ use acvm::acir::circuit::Circuit; -use noirc_abi::Abi; +use noirc_abi::{Abi, ContractEvent}; use noirc_driver::ContractFunctionType; use serde::{Deserialize, Serialize}; @@ -16,6 +16,8 @@ pub struct PreprocessedContract { pub backend: String, /// Each of the contract's functions are compiled into a separate program stored in this `Vec`. pub functions: Vec, + /// All the events defined inside the contract scope. + pub events: Vec, } /// Each function in the contract will be compiled as a separate noir program. diff --git a/tooling/nargo_cli/src/cli/compile_cmd.rs b/tooling/nargo_cli/src/cli/compile_cmd.rs index d7bcf475a40..7ac7fe58500 100644 --- a/tooling/nargo_cli/src/cli/compile_cmd.rs +++ b/tooling/nargo_cli/src/cli/compile_cmd.rs @@ -267,6 +267,7 @@ fn save_contract( name: contract.name, backend: String::from(BACKEND_IDENTIFIER), functions: preprocessed_functions, + events: contract.events, }; save_contract_to_file( diff --git a/tooling/nargo_cli/tests/execution_success/regression_2854/Nargo.toml b/tooling/nargo_cli/tests/execution_success/regression_2854/Nargo.toml new file mode 100644 index 00000000000..33bd007d898 --- /dev/null +++ b/tooling/nargo_cli/tests/execution_success/regression_2854/Nargo.toml @@ -0,0 +1,7 @@ +[package] +name = "regression_2854" +type = "bin" +authors = [""] +compiler_version = "0.1" + +[dependencies] diff --git a/tooling/nargo_cli/tests/execution_success/regression_2854/Prover.toml b/tooling/nargo_cli/tests/execution_success/regression_2854/Prover.toml new file mode 100644 index 00000000000..07890234a19 --- /dev/null +++ b/tooling/nargo_cli/tests/execution_success/regression_2854/Prover.toml @@ -0,0 +1 @@ +x = "3" diff --git a/tooling/nargo_cli/tests/execution_success/regression_2854/src/main.nr b/tooling/nargo_cli/tests/execution_success/regression_2854/src/main.nr new file mode 100644 index 00000000000..10ada5faeec --- /dev/null +++ b/tooling/nargo_cli/tests/execution_success/regression_2854/src/main.nr @@ -0,0 +1,3 @@ +fn main(x: Field) -> pub i127 { + x as i127 +} \ No newline at end of file diff --git a/tooling/noir_js/package.json b/tooling/noir_js/package.json index a16aa6c301b..bba952e39e3 100644 --- a/tooling/noir_js/package.json +++ b/tooling/noir_js/package.json @@ -3,7 +3,7 @@ "collaborators": [ "The Noir Team " ], - "version": "0.14.0", + "version": "0.14.1", "packageManager": "yarn@3.5.1", "license": "(MIT OR Apache-2.0)", "type": "module", @@ -18,10 +18,10 @@ ], "source": "src/index.ts", "main": "lib/index.cjs", - "module": "lib/index.js", + "module": "lib/index.mjs", "exports": { "require": "./lib/index.cjs", - "default": "./lib/index.js", + "default": "./lib/index.mjs", "types": "./lib/index.d.ts" }, "types": "lib/index.d.ts", @@ -33,7 +33,9 @@ "test:node:cjs": "mocha --timeout 25000 --exit --config ./.mocharc.cjs.json", "prettier": "prettier 'src/**/*.ts'", "prettier:fix": "prettier --write 'src/**/*.ts' 'test/**/*.ts'", - "lint": "NODE_NO_WARNINGS=1 eslint . --ext .ts --ignore-path ./.eslintignore --max-warnings 0" + "lint": "NODE_NO_WARNINGS=1 eslint . --ext .ts --ignore-path ./.eslintignore --max-warnings 0", + "clean": "rm -rf ./lib" + }, "devDependencies": { "@aztec/bb.js": "0.7.2", diff --git a/tooling/noir_js/src/input_validation.ts b/tooling/noir_js/src/input_validation.ts deleted file mode 100644 index 9a19528a0cf..00000000000 --- a/tooling/noir_js/src/input_validation.ts +++ /dev/null @@ -1,55 +0,0 @@ -// Check if all of the input values are correct according to the ABI -export function validateInputs(inputs, abi) { - for (const param of abi.parameters) { - const inputValue = inputs[param.name]; - if (inputValue === undefined) { - // This is checked by noirc_abi, so we could likely remove this check - return { isValid: false, error: `Input for ${param.name} is missing` }; - } - if (!checkType(inputValue, param.type)) { - return { - isValid: false, - error: `Input for ${param.name} is the wrong type, expected ${type_to_string(param.type)}, got "${inputValue}"`, - }; - } - } - return { isValid: true, error: null }; -} - -// Checks that value is of type "type" -// Where type is taken from the abi -function checkType(value, type) { - switch (type.kind) { - case 'integer': - if (type.sign === 'unsigned') { - return isUnsignedInteger(value, type.width); - } - // Other integer sign checks can be added here - break; - // Other type.kind checks can be added here - } - return false; -} - -function type_to_string(type): string { - switch (type.kind) { - case 'integer': - if (type.sign === 'unsigned') { - return `uint${type.width}`; - } - break; - case 'array': - return `${type_to_string(type.element)}[${type.length}]`; - } - return 'unknown type'; -} - -// Returns true if `value` is an unsigned integer that is less than 2^{width} -function isUnsignedInteger(value: bigint, width: bigint) { - try { - const bigIntValue = BigInt(value); - return bigIntValue >= 0 && bigIntValue <= BigInt(2) ** BigInt(width) - 1n; - } catch (e) { - return false; // Not a valid integer - } -} diff --git a/tooling/noir_js/src/witness_generation.ts b/tooling/noir_js/src/witness_generation.ts index c117adcf087..b8f594a5fc5 100644 --- a/tooling/noir_js/src/witness_generation.ts +++ b/tooling/noir_js/src/witness_generation.ts @@ -1,16 +1,11 @@ import { abiEncode } from '@noir-lang/noirc_abi'; -import { validateInputs } from './input_validation.js'; import { base64Decode } from './base64_decode.js'; import { executeCircuit } from '@noir-lang/acvm_js'; import { witnessMapToUint8Array } from './serialize.js'; // Generates the witnesses needed to feed into the chosen proving system export async function generateWitness(compiledProgram, inputs): Promise { - // Validate inputs - const { isValid, error } = validateInputs(inputs, compiledProgram.abi); - if (!isValid) { - throw new Error(error?.toString()); - } + // Throws on ABI encoding error const witnessMap = abiEncode(compiledProgram.abi, inputs, null); // Execute the circuit to generate the rest of the witnesses and serialize diff --git a/tooling/noir_js/test/node/cjs.test.cjs b/tooling/noir_js/test/node/cjs.test.cjs index 0eddb3cc4af..b7b30d7dcdb 100644 --- a/tooling/noir_js/test/node/cjs.test.cjs +++ b/tooling/noir_js/test/node/cjs.test.cjs @@ -70,7 +70,11 @@ describe('input validation', () => { chai.expect.fail('Expected generatedWitness to throw, due to x not being convertible to a uint64'); } catch (error) { const knownError = error; - chai.expect(knownError.message).to.equal('Input for x is the wrong type, expected uint64, got "foo"'); + chai + .expect(knownError.message) + .to.equal( + 'Expected witness values to be integers, provided value causes `invalid digit found in string` error', + ); } }); }); diff --git a/tooling/noir_js/test/node/smoke.test.ts b/tooling/noir_js/test/node/smoke.test.ts index 179246745fe..4b0291c0f41 100644 --- a/tooling/noir_js/test/node/smoke.test.ts +++ b/tooling/noir_js/test/node/smoke.test.ts @@ -7,7 +7,7 @@ it('generates witnesses successfully', async () => { x: '2', y: '3', }; - const _solvedWitness = await generateWitness(assert_lt_json, inputs); + expect(() => generateWitness(assert_lt_json, inputs)).to.not.throw; }); it('string input and number input are the same', async () => { @@ -66,7 +66,9 @@ describe('input validation', () => { expect.fail('Expected generatedWitness to throw, due to x not being convertible to a uint64'); } catch (error) { const knownError = error as Error; - expect(knownError.message).to.equal('Input for x is the wrong type, expected uint64, got "foo"'); + expect(knownError.message).to.equal( + 'Expected witness values to be integers, provided value causes `invalid digit found in string` error', + ); } }); }); diff --git a/tooling/noirc_abi/src/lib.rs b/tooling/noirc_abi/src/lib.rs index d0c7e4e58c1..eb654e25f8c 100644 --- a/tooling/noirc_abi/src/lib.rs +++ b/tooling/noirc_abi/src/lib.rs @@ -12,7 +12,9 @@ use acvm::{ use errors::AbiError; use input_parser::InputValue; use iter_extended::{try_btree_map, try_vecmap, vecmap}; -use noirc_frontend::{hir::Context, Signedness, Type, TypeBinding, TypeVariableKind, Visibility}; +use noirc_frontend::{ + hir::Context, Signedness, StructType, Type, TypeBinding, TypeVariableKind, Visibility, +}; use serde::{Deserialize, Serialize}; // This is the ABI used to bridge the different TOML formats for the initial // witness, the partial witness generator and the interpreter. @@ -477,6 +479,33 @@ fn decode_string_value(field_elements: &[FieldElement]) -> String { final_string.to_owned() } +#[derive(Debug, Serialize, Deserialize)] +pub struct ContractEvent { + /// Event name + name: String, + /// The fully qualified path to the event definition + path: String, + + /// Fields of the event + #[serde( + serialize_with = "serialization::serialize_struct_fields", + deserialize_with = "serialization::deserialize_struct_fields" + )] + fields: Vec<(String, AbiType)>, +} + +impl ContractEvent { + pub fn from_struct_type(context: &Context, struct_type: &StructType) -> Self { + let fields = vecmap(struct_type.get_fields(&[]), |(name, typ)| { + (name, AbiType::from_type(context, &typ)) + }); + // For the ABI, we always want to resolve the struct paths from the root crate + let path = context.fully_qualified_struct_path(context.root_crate_id(), struct_type.id); + + Self { name: struct_type.name.0.contents.clone(), path, fields } + } +} + #[cfg(test)] mod test { use std::collections::BTreeMap; diff --git a/tooling/noirc_abi_wasm/build.sh b/tooling/noirc_abi_wasm/build.sh index 8157e42c6de..37f2fd0a5a9 100755 --- a/tooling/noirc_abi_wasm/build.sh +++ b/tooling/noirc_abi_wasm/build.sh @@ -22,14 +22,13 @@ function run_or_fail { fi } -require_command toml2json require_command jq require_command cargo require_command wasm-bindgen check_installed wasm-opt self_path=$(dirname "$(readlink -f "$0")") -export pname=$(toml2json < $self_path/Cargo.toml | jq -r .package.name) +export pname=$(cargo read-manifest | jq -r '.name') export CARGO_TARGET_DIR=$self_path/target rm -rf $self_path/outputs >/dev/null 2>&1 @@ -45,4 +44,4 @@ fi run_or_fail $self_path/buildPhaseCargoCommand.sh run_or_fail $self_path/installPhase.sh -ln -s $out $self_path/result \ No newline at end of file +ln -s $out $self_path/result diff --git a/tooling/noirc_abi_wasm/package.json b/tooling/noirc_abi_wasm/package.json index af51188daee..1d500d2464b 100644 --- a/tooling/noirc_abi_wasm/package.json +++ b/tooling/noirc_abi_wasm/package.json @@ -3,7 +3,7 @@ "collaborators": [ "The Noir Team " ], - "version": "0.14.0", + "version": "0.14.1", "license": "(MIT OR Apache-2.0)", "files": [ "nodejs", @@ -25,7 +25,7 @@ "build": "bash ./build.sh", "test": "env TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\" }' mocha", "test:browser": "web-test-runner", - "clean": "rm -rf ./nodejs ./web ./target", + "clean": "chmod u+w web nodejs && rm -rf ./nodejs ./web ./target ./result", "lint": "NODE_NO_WARNINGS=1 eslint . --ext .ts --ignore-path ./.eslintignore --max-warnings 0" }, "devDependencies": {