-
Notifications
You must be signed in to change notification settings - Fork 219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Save Brillig execution state in ACVM #3026
feat: Save Brillig execution state in ACVM #3026
Conversation
To allow resuming Brillig execution after resolving a foreign call and in preparation to support step-by-step execution of Brillig opcodes when run inside an ACIR block.
Add a new method `resolve_foreign_call` to push the result to the results vector. Then the VM can be resumed and retrieve the pending foreign call result without restarting.
This allows retaining state and reusing the Brillig VM when resuming execution after a pending foreign call is resolved. This is also in preparation to allow stepping into the Brillig code when debugging an ACIR program.
We actually have this already implemented in #2872 although we're not in a big rush to get it merged due to the resulting serialisation change. |
Ah, the suggestions are a bit broken as I made them in a codespace. Will fix. |
This is looking good, I'm happy to merge once the suggestions are applied. We've got a slight issue with having two methods of feeding in foreign call results into the VM which we may want to address but that can also go in a separate PR (as a cleanup after #2872) |
Co-authored-by: Tom French <15848336+TomAFrench@users.noreply.github.com>
@ggiraldez Could you mark future PRs as "Allow edits from maintainers" please? I'd like to merge this but am blocked by the lifetime error, ideally I'd be able to fix this up myself. |
You'll need to merge master into your branch as the error is cause by a conflict with #3030 |
We made the fork in our organization @manastech, and apparently that option is not available for organization forks :( |
Ah ok, no worries then. :) |
Ok, I'm having trouble with lifetimes now and I'm not being able to solve the issue. The I'm lost on how to fix this issue without resorting to copying the Brillig opcodes to spawn the VM (if that's even possible). Maybe using a |
Oof, yeah that's unfortunate. I'll have a think about how to address this. Worst case scenario either we revert the change to pass ownership of brillig bytecode or can save the brillig VM's registers+memory+instruction pointer rather than the VM as a whole. |
Good news, I had a suspicion that #2872 would fix this issue for us and it has. Merging master into this branch should be pretty easy now. |
Whew! Ok, the merge was pretty painless. Some integration tests are failing now though ( I think now it would be pretty safe to remove the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. We can address any issues related to foreign calls in a followup PR
Co-authored-by: Tom French <15848336+TomAFrench@users.noreply.github.com>
🤖 I have created a release *beep* *boop* --- <details><summary>0.19.5</summary> ## [0.19.5](v0.19.4...v0.19.5) (2023-12-01) ### Features * Add `FieldElement::from<usize>` implementation ([#3647](#3647)) ([8b7c5aa](8b7c5aa)) * Add package version to Nargo.toml metadata ([#3427](#3427)) ([9e1717c](9e1717c)) * Add special case for boolean AND in acir-gen ([#3615](#3615)) ([824039b](824039b)) * Aztec-packages ([#3599](#3599)) ([2cd6dc3](2cd6dc3)) * Aztec-packages ([#3626](#3626)) ([e0a96ea](e0a96ea)) * Complex slice inputs for dynamic slice builtins ([#3617](#3617)) ([8b23b34](8b23b34)) * Copy on write optimization for brillig ([#3522](#3522)) ([da29c02](da29c02)) * Data bus ([#3508](#3508)) ([6b0bdbc](6b0bdbc)) * Implement integer printing ([#3577](#3577)) ([6601408](6601408)) * Implement raw string literals ([#3556](#3556)) ([87a302f](87a302f)) * **lsp:** Add goto definition for functions ([#3656](#3656)) ([7bb7356](7bb7356)) * Reuse witnesses more when interacting with memory ([#3658](#3658)) ([5a4a73d](5a4a73d)) ### Bug Fixes * Corrected the formatting of error message parameters in index out of bounds error ([#3630](#3630)) ([3bba386](3bba386)) * Do not simply divisions ([#3664](#3664)) ([e5b981b](e5b981b)) * Docker builds ([#3620](#3620)) ([f3eac52](f3eac52)) * Flatten public inputs according to their index in numerial rather than ascii order ([#3605](#3605)) ([a1f6343](a1f6343)) * Restrict fill_internal_slices pass to acir functions ([#3634](#3634)) ([0cad9aa](0cad9aa)) </details> <details><summary>0.36.0</summary> ## [0.36.0](v0.35.0...v0.36.0) (2023-12-01) ### ⚠ BREAKING CHANGES * Move circuit serialization circuit into acir ([#3345](#3345)) * expose pedersen hash in acir and bb solver ([#3269](#3269)) * Switch to new pedersen implementation ([#3151](#3151)) * Pass ACIR to ACVM by reference rather than passing ownership ([#2872](#2872)) * **wasm:** improve and simplify wasm compiler interface ([#2976](#2976)) * Maintain shape of foreign call arguments ([#2935](#2935)) ### Features * **acvm_js:** Export black box solver functions ([#2812](#2812)) ([da8a98e](da8a98e)) * **acvm:** Separate ACVM optimizations and transformations ([#2979](#2979)) ([5865d1a](5865d1a)) * Add `FieldElement::from<usize>` implementation ([#3647](#3647)) ([8b7c5aa](8b7c5aa)) * Add ACIR serializer C++ codegen ([#2961](#2961)) ([7556982](7556982)) * Add conditional compilation of methods based on the underlying field being used ([#3045](#3045)) ([2e008e2](2e008e2)) * Add debugger commands to introspect (and modify) the current state ([#3391](#3391)) ([9e1ad85](9e1ad85)) * Aztec-packages ([#3599](#3599)) ([2cd6dc3](2cd6dc3)) * Expose pedersen hash in acir and bb solver ([#3269](#3269)) ([0108b6c](0108b6c)) * Extract Brillig VM to allow step debugging ([#3259](#3259)) ([f6431f9](f6431f9)) * Implement euclidean division and signed division in terms of `AcirVar`s ([#3230](#3230)) ([b8b7782](b8b7782)) * Maintain shape of foreign call arguments ([#2935](#2935)) ([f7869e6](f7869e6)) * Pass ACIR to ACVM by reference rather than passing ownership ([#2872](#2872)) ([b3a9c34](b3a9c34)) * Pass brillig bytecode to VM by reference ([#3030](#3030)) ([4ee290b](4ee290b)) * Refactor debugger and separate core from UI ([#3308](#3308)) ([8466810](8466810)) * Replace boolean range constraints with arithmetic opcodes ([#3234](#3234)) ([949222c](949222c)) * Save Brillig execution state in ACVM ([#3026](#3026)) ([88682da](88682da)) * Solve `fixed_base_scalar_mul` black box functions in rust ([#3153](#3153)) ([1c1afbc](1c1afbc)) * Switch to new pedersen implementation ([#3151](#3151)) ([35fb3f7](35fb3f7)) * **wasm:** Improve and simplify wasm compiler interface ([#2976](#2976)) ([1b5124b](1b5124b)) ### Bug Fixes * ACIR optimizer should update assertion messages ([#3010](#3010)) ([758b6b6](758b6b6)) * **acvm:** Return false rather than panicking on invalid ECDSA signatures ([#2783](#2783)) ([155abc0](155abc0)) * Determinism of fallback transformer ([#3100](#3100)) ([12daad1](12daad1)) * Fix method `program_counter`, change method signature ([#3012](#3012)) ([5ea522b](5ea522b)) * Minor problems with `aztec` publishing ([#3095](#3095)) ([0fc8f20](0fc8f20)) * Prevent duplicated assert message transformation ([#3038](#3038)) ([082a6d0](082a6d0)) * Return error rather than panicking on unreadable circuits ([#3179](#3179)) ([d4f61d3](d4f61d3)) ### Miscellaneous Chores * Move circuit serialization circuit into acir ([#3345](#3345)) ([122119b](122119b)) </details> --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
🤖 I have created a release *beep* *boop* --- <details><summary>0.20.0</summary> ## [0.20.0](v0.19.5...v0.20.0) (2023-12-01) ### ⚠ BREAKING CHANGES * avoid integer overflows ([#2713](#2713)) * return Pedersen structure in stdlib ([#3190](#3190)) * noir-wasm outputs debug symbols ([#3317](#3317)) * move mimc to hash submodule ([#3361](#3361)) * bump MSRV to 1.71.1 ([#3353](#3353)) * Add semver checks for the compiler version in Nargo.toml ([#3336](#3336)) * Move circuit serialization circuit into acir ([#3345](#3345)) * change stdlib function `pedersen` to `pedersen_commitment` ([#3341](#3341)) * expose pedersen hash in acir and bb solver ([#3269](#3269)) * Switch to new pedersen implementation ([#3151](#3151)) * Pass ACIR to ACVM by reference rather than passing ownership ([#2872](#2872)) * Make for loops a statement ([#2975](#2975)) * **traits:** trait functions with a default implementation must not be followed by a semicolon ([#2987](#2987)) * **wasm:** improve and simplify wasm compiler interface ([#2976](#2976)) * **wasm:** update wasm artifacts to match cli artifacts ([#2973](#2973)) * Maintain shape of foreign call arguments ([#2935](#2935)) * update to `bb` version 0.7.3 ([#2729](#2729)) * **noir_js:** Rename inner and outer proof methods ([#2845](#2845)) * `generateWitness` now returns a serialized witness file ([#2842](#2842)) * Issue an error when a module is declared twice & fix module search path ([#2801](#2801)) * Default integers to u64 ([#2764](#2764)) ### Features * `compute_note_hash_and_nullifier` check ([#3216](#3216)) ([4963c6c](4963c6c)) * **abi:** Throw errors rather than returning string from `noirc_abi_wasm` ([#2817](#2817)) ([df7b42c](df7b42c)) * **abi:** Tuples as inputs/outputs to main ([#2899](#2899)) ([d8bd78f](d8bd78f)) * **acir:** Enable dynamic indices on non-homogenous arrays ([#2703](#2703)) ([622d2e4](622d2e4)) * **acir:** Handle dynamic array operations for nested slices ([#3187](#3187)) ([e026319](e026319)) * **acir:** Set dynamic array values ([#3054](#3054)) ([e871866](e871866)) * **acvm_js:** Export black box solver functions ([#2812](#2812)) ([da8a98e](da8a98e)) * **acvm:** Separate ACVM optimizations and transformations ([#2979](#2979)) ([5865d1a](5865d1a)) * Add --check option to nargo fmt for dry-run formatting verification ([#3530](#3530)) ([4469707](4469707)) * Add `destroy` method to `Noir` ([#3105](#3105)) ([7e40274](7e40274)) * Add `execute` method to `Noir` class ([#3081](#3081)) ([17bdd7e](17bdd7e)) * Add `FieldElement::from<usize>` implementation ([#3647](#3647)) ([8b7c5aa](8b7c5aa)) * Add `noir_codegen` package ([#3392](#3392)) ([6c4cd4d](6c4cd4d)) * Add ACIR serializer C++ codegen ([#2961](#2961)) ([7556982](7556982)) * Add an options object to `BarretenbergBackend` constructor ([#3105](#3105)) ([7e40274](7e40274)) * Add aztec selectors for event structs ([#2983](#2983)) ([982380e](982380e)) * Add bb interface implementation ([#2902](#2902)) ([fe92dc0](fe92dc0)) * Add check for overlapping generic traits ([#3307](#3307)) ([8cf81b6](8cf81b6)) * Add conditional compilation of methods based on the underlying field being used ([#3045](#3045)) ([2e008e2](2e008e2)) * Add crate for pub modifier ([#3271](#3271)) ([e7a1a1a](e7a1a1a)) * Add debugger commands to introspect (and modify) the current state ([#3391](#3391)) ([9e1ad85](9e1ad85)) * Add experimental REPL-based debugger ([#2995](#2995)) ([281c696](281c696)) * Add exports of JS black box solvers to noirJS ([#3295](#3295)) ([8369871](8369871)) * Add generic count check for trait methods ([#3382](#3382)) ([a9f9717](a9f9717)) * Add JS types for ABI and input maps ([#3023](#3023)) ([599e7a1](599e7a1)) * Add LSP command to profile opcodes in vscode ([#3496](#3496)) ([6fbf77a](6fbf77a)) * Add lsp formatting ([#3433](#3433)) ([286c876](286c876)) * Add noir types package ([#2893](#2893)) ([e8fc868](e8fc868)) * Add package version to Nargo.toml metadata ([#3427](#3427)) ([9e1717c](9e1717c)) * Add profile info print out ([#3425](#3425)) ([a8b5fa8](a8b5fa8)) * Add semver checks for the compiler version in Nargo.toml ([#3336](#3336)) ([0e530cf](0e530cf)) * Add special case for boolean AND in acir-gen ([#3615](#3615)) ([824039b](824039b)) * Add support for tuple values in `noir_codegen` ([#3592](#3592)) ([346d75f](346d75f)) * Allow a trait to be implemented multiple times for the same struct ([#3292](#3292)) ([51831df](51831df)) * Allow providing custom foreign call executors to `execute_circuit` ([#3506](#3506)) ([d27db33](d27db33)) * Allow traits to have generic functions ([#3365](#3365)) ([0f9af65](0f9af65)) * Avoid integer overflows ([#2713](#2713)) ([7d7d632](7d7d632)) * Aztec-packages ([#3599](#3599)) ([2cd6dc3](2cd6dc3)) * Aztec-packages ([#3626](#3626)) ([e0a96ea](e0a96ea)) * Cache debug artifacts ([#3133](#3133)) ([c5a6229](c5a6229)) * Check where clauses when searching for trait impls ([#3407](#3407)) ([84c6604](84c6604)) * Codegen typed interfaces for functions in `noir_codegen` ([#3533](#3533)) ([290c463](290c463)) * Compile without a backend ([#3437](#3437)) ([d69cf5d](d69cf5d)) * Complex slice inputs for dynamic slice builtins ([#3617](#3617)) ([8b23b34](8b23b34)) * Contract events in artifacts ([#2873](#2873)) ([4765c82](4765c82)) * Copy on write optimization for brillig ([#3522](#3522)) ([da29c02](da29c02)) * Data bus ([#3508](#3508)) ([6b0bdbc](6b0bdbc)) * **debugger:** Highlight current src code loc ([#3174](#3174)) ([6b87582](6b87582)) * **debugger:** Print limited source code context ([#3217](#3217)) ([dcda1c7](dcda1c7)) * Default integers to u64 ([#2764](#2764)) ([01cb041](01cb041)) * Dynamic indexing of non-homogenous slices ([#2883](#2883)) ([72c3661](72c3661)) * Enable the `fmt` command in the help menu ([#3328](#3328)) ([63d414c](63d414c)) * Expand trait impl overlap check to cover generic types ([#3320](#3320)) ([a01549b](a01549b)) * Export `CompiledCircuit` from codegened TS ([#3589](#3589)) ([e06c675](e06c675)) * Expose pedersen hash in acir and bb solver ([#3269](#3269)) ([0108b6c](0108b6c)) * Extract Brillig VM to allow step debugging ([#3259](#3259)) ([f6431f9](f6431f9)) * Format infix expressions ([#3001](#3001)) ([7926ada](7926ada)) * **formatter:** Add formatter support for array literals ([#3061](#3061)) ([a535321](a535321)) * Handle constant index operations on simple slices ([#3464](#3464)) ([7ae12f8](7ae12f8)) * Handle warnings in evaluator ([#3205](#3205)) ([5cfd156](5cfd156)) * Implement `bound_constraint_with_offset` in terms of `AcirVar`s ([#3233](#3233)) ([8d89cb5](8d89cb5)) * Implement automatic dereferencing for index expressions ([#3082](#3082)) ([8221bfd](8221bfd)) * Implement automatic dereferencing for indexing lvalues ([#3083](#3083)) ([6e2b70a](6e2b70a)) * Implement euclidean division and signed division in terms of `AcirVar`s ([#3230](#3230)) ([b8b7782](b8b7782)) * Implement impl specialization ([#3087](#3087)) ([44716fa](44716fa)) * Implement integer printing ([#3577](#3577)) ([6601408](6601408)) * Implement raw string literals ([#3556](#3556)) ([87a302f](87a302f)) * Implement string escape sequences ([#2803](#2803)) ([f7529b8](f7529b8)) * Implement where clauses on impls ([#3324](#3324)) ([4c3d1de](4c3d1de)) * **lsp:** Add "info" codelens ([#2982](#2982)) ([80770d9](80770d9)) * **lsp:** Add goto definition for functions ([#3656](#3656)) ([7bb7356](7bb7356)) * Maintain shape of foreign call arguments ([#2935](#2935)) ([f7869e6](f7869e6)) * Make generic impls callable ([#3297](#3297)) ([8d9b738](8d9b738)) * Manage breakpoints and allow restarting a debugging session ([#3325](#3325)) ([f502108](f502108)) * Nargo test runtime callstacks and assert messages without string matching ([#2953](#2953)) ([1b6a4e6](1b6a4e6)) * **noir_js:** Allow providing foreign call handlers in noirJS ([#3294](#3294)) ([c76b0f8](c76b0f8)) * Noir-wasm outputs debug symbols ([#3317](#3317)) ([f9933fa](f9933fa)) * Noir-wasm takes dependency graph ([#3213](#3213)) ([a2c8ebd](a2c8ebd)) * Old docs issues ([#3195](#3195)) ([26746c5](26746c5)) * Optimize euclidean division acir-gen ([#3121](#3121)) ([2c175c0](2c175c0)) * Oracle mocker for nargo test ([#2928](#2928)) ([0dd1e77](0dd1e77)) * Pass ACIR to ACVM by reference rather than passing ownership ([#2872](#2872)) ([b3a9c34](b3a9c34)) * Pass brillig bytecode to VM by reference ([#3030](#3030)) ([4ee290b](4ee290b)) * Perform compile-time euclidean division on constants ([#3231](#3231)) ([3866d7e](3866d7e)) * Prevent unnecessary witness creation in euclidean division ([#2980](#2980)) ([c6f660e](c6f660e)) * Properly track equivalence of witnesses generated for black box functions ([#3428](#3428)) ([20b70c2](20b70c2)) * Provide formatting subcommand ([#2640](#2640)) ([a38b15f](a38b15f)) * Publish aztec build of noir_wasm ([#3049](#3049)) ([3b51f4d](3b51f4d)) * Refactor debugger and separate core from UI ([#3308](#3308)) ([8466810](8466810)) * Remove redundant predicate from brillig quotients ([#2784](#2784)) ([a8f18c5](a8f18c5)) * Remove type arrays for flat slices ([#3466](#3466)) ([8225b2b](8225b2b)) * Remove unnecessary truncation of boolean multiplication ([#3122](#3122)) ([39dbcf1](39dbcf1)) * Replace boolean range constraints with arithmetic opcodes ([#3234](#3234)) ([949222c](949222c)) * Return compilation errors from noir_wasm ([#3091](#3091)) ([55f63c9](55f63c9)) * Return Pedersen structure in stdlib ([#3190](#3190)) ([be30d59](be30d59)) * Reuse witnesses more when interacting with memory ([#3658](#3658)) ([5a4a73d](5a4a73d)) * Reuse witnesses which have been assigned constant values during ACIR gen ([#3137](#3137)) ([9eb43e2](9eb43e2)) * Save Brillig execution state in ACVM ([#3026](#3026)) ([88682da](88682da)) * Send and receive unflattened public inputs to backend ([#3543](#3543)) ([a7bdc67](a7bdc67)) * Solve `fixed_base_scalar_mul` black box functions in rust ([#3153](#3153)) ([1c1afbc](1c1afbc)) * **ssa:** Multiple slice mergers ([#2753](#2753)) ([8f76fe5](8f76fe5)) * **stdlib:** Optimize constraint counts in sha256/sha512 ([#3253](#3253)) ([d3be552](d3be552)) * Switch to new pedersen implementation ([#3151](#3151)) ([35fb3f7](35fb3f7)) * **traits:** Add impl Trait as function return type [#2397](#2397) ([#3176](#3176)) ([4cb2024](4cb2024)) * **traits:** Add trait impl for buildin types ([#2964](#2964)) ([2c87b27](2c87b27)) * **traits:** Added checks for duplicated trait associated items (types, consts, functions) ([#2927](#2927)) ([d49492c](d49492c)) * **traits:** Allow multiple traits to share the same associated function name and to be implemented for the same type ([#3126](#3126)) ([004f8dd](004f8dd)) * **traits:** Implement trait bounds typechecker + monomorphizer passes ([#2717](#2717)) ([5ca99b1](5ca99b1)) * **traits:** Improve support for traits static method resolution ([#2958](#2958)) ([0d0d8f7](0d0d8f7)) * **traits:** Multi module support for traits ([#2844](#2844)) ([4deb07f](4deb07f)) * Use ranges instead of a vector for input witness ([#3314](#3314)) ([b12b7ec](b12b7ec)) * **wasm:** Improve and simplify wasm compiler interface ([#2976](#2976)) ([1b5124b](1b5124b)) * **wasm:** Update wasm artifacts to match cli artifacts ([#2973](#2973)) ([ce16c0b](ce16c0b)) ### Bug Fixes * "Missing trait impl" error in trait dispatch ([#3440](#3440)) ([52daaec](52daaec)) * `compute_note_hash_and_nullifier` compiler check ([#3351](#3351)) ([4e2d35f](4e2d35f)) * **3275:** Activate brillig modulo test with negative integers ([#3318](#3318)) ([31c493c](31c493c)) * **3300:** Cache warnings into debug artefacts ([#3313](#3313)) ([cb5a15b](cb5a15b)) * ACIR optimizer should update assertion messages ([#3010](#3010)) ([758b6b6](758b6b6)) * **acvm:** Return false rather than panicking on invalid ECDSA signatures ([#2783](#2783)) ([155abc0](155abc0)) * Add `pub` modifier to grumpkin functions ([#3036](#3036)) ([f8990d7](f8990d7)) * Add compiler error message for invalid input types ([#3220](#3220)) ([989e80d](989e80d)) * Add size checks to integer literals ([#3236](#3236)) ([7f8fe8c](7f8fe8c)) * Adding proving key initialization ([#3322](#3322)) ([3383740](3383740)) * Allow `where` clause on all functions and improve error message ([#3465](#3465)) ([1647e33](1647e33)) * Allow constructors in parentheses in `if` conditions and `for` ranges ([#3219](#3219)) ([ad192d1](ad192d1)) * Allow two `TypeVariable::Constant(N)` to unify even if their constants are not equal ([#3225](#3225)) ([cc4ca4b](cc4ca4b)) * Apply predicate to over/underflow checks ([#3494](#3494)) ([fc3edf7](fc3edf7)) * **aztec_nr:** Serialise arrays of structs ([#3401](#3401)) ([e979a58](e979a58)) * Change non-constant argument errors from `to_be_radix` from ICE to proper error ([#3048](#3048)) ([19ce286](19ce286)) * Check for overflow with hexadecimal inputs ([#3004](#3004)) ([db1e736](db1e736)) * Compiler version error message ([#3558](#3558)) ([026a358](026a358)) * Complete debug metadata ([#3228](#3228)) ([2f6509d](2f6509d)) * Conditionally run the "Create or Update PR" step in acir artifacts rebuild workflow ([#2849](#2849)) ([63da875](63da875)) * Corrected the formatting of error message parameters in index out of bounds error ([#3630](#3630)) ([3bba386](3bba386)) * **debugger:** Step through foreign calls and breakpoints inside Brillig blocks ([#3511](#3511)) ([5d77d7a](5d77d7a)) * Determinism of fallback transformer ([#3100](#3100)) ([12daad1](12daad1)) * Disable modulo for fields ([#3009](#3009)) ([7e68976](7e68976)) * Disallow returning constant values ([#2978](#2978)) ([79c2e88](79c2e88)) * Do not perform dead instruction elimination on mod,div unless rhs is constant ([#3141](#3141)) ([af3d771](af3d771)) * Do not simply divisions ([#3664](#3664)) ([e5b981b](e5b981b)) * Docker builds ([#3620](#3620)) ([f3eac52](f3eac52)) * **docs:** Update `editUrl` path for docusaurus ([#3184](#3184)) ([4646a93](4646a93)) * Download expected `bb` version if installed backend has version mismatch ([#3150](#3150)) ([3f03435](3f03435)) * Error message for assigning the wrong type is backwards [#2804](#2804) ([#2805](#2805)) ([b2d62bf](b2d62bf)) * Finer bit size in bound constrain ([#2869](#2869)) ([68385e2](68385e2)) * Fix aztec library after nargo fmt ([#3014](#3014)) ([f43083c](f43083c)) * Fix crash when using undeclared traits ([#3509](#3509)) ([8bb095a](8bb095a)) * Fix lexer error formatting ([#3274](#3274)) ([74bd517](74bd517)) * Fix method `program_counter`, change method signature ([#3012](#3012)) ([5ea522b](5ea522b)) * Fix panic in some cases when calling a private function ([#2799](#2799)) ([078d5df](078d5df)) * Fix panic when using repeated arrays which define variables ([#3221](#3221)) ([c4faf3a](c4faf3a)) * Fix should_fail_with ([#2940](#2940)) ([4f07b84](4f07b84)) * Fix subtract with underflow in flattening pass ([#2796](#2796)) ([f2ed505](f2ed505)) * Fixing versioning workflow ([#3296](#3296)) ([3d5e43a](3d5e43a)) * Flatten public inputs according to their index in numerial rather than ascii order ([#3605](#3605)) ([a1f6343](a1f6343)) * Follow dependencies when looking for a struct ([#3405](#3405)) ([561b1b8](561b1b8)) * Force recompilation when `output_debug` flag is set. ([#2898](#2898)) ([9854416](9854416)) * **frontend:** Error on unsupported integer annotation ([#2778](#2778)) ([90c3d8b](90c3d8b)) * Impl methods are no longer placed in contracts ([#3255](#3255)) ([b673b07](b673b07)) * Improve error message when multiplying unit values ([#2950](#2950)) ([57b7c55](57b7c55)) * Include .nr and .sol files in builds ([#3039](#3039)) ([ae8d0e9](ae8d0e9)) * Issue an error when a module is declared twice & fix module search path ([#2801](#2801)) ([7f76910](7f76910)) * Lack of cjs package version ([#2848](#2848)) ([adc2d59](adc2d59)) * Make for loops a statement ([#2975](#2975)) ([0e266eb](0e266eb)) * Match rust behaviour for left-shift overflow ([#3518](#3518)) ([2d7ceb1](2d7ceb1)) * Minor problems with `aztec` publishing ([#3095](#3095)) ([0fc8f20](0fc8f20)) * Move mimc to hash submodule ([#3361](#3361)) ([3ec29f1](3ec29f1)) * Overflow checks for constant folding ([#3420](#3420)) ([b7a6383](b7a6383)) * Parse parenthesized lvalues ([#3058](#3058)) ([50ca58c](50ca58c)) * Prevent duplicated assert message transformation ([#3038](#3038)) ([082a6d0](082a6d0)) * Prevent mutating immutable bindings to mutable types ([#3075](#3075)) ([d5ee20e](d5ee20e)) * **println:** Enable printing of arrays/strings >2 in fmt strings ([#2947](#2947)) ([309fa70](309fa70)) * Recompile artefacts from a different noir version ([#3248](#3248)) ([7347b27](7347b27)) * Remove cast for field comparisons in brillig ([#2874](#2874)) ([1fc1fdb](1fc1fdb)) * Remove duplication of code to load stdlib files ([#2868](#2868)) ([b694aab](b694aab)) * Remove quotes from println output ([#3574](#3574)) ([127b6aa](127b6aa)) * Remove sha2_block test ([#3360](#3360)) ([a48c03b](a48c03b)) * Restrict fill_internal_slices pass to acir functions ([#3634](#3634)) ([0cad9aa](0cad9aa)) * Return error rather than panicking on unreadable circuits ([#3179](#3179)) ([d4f61d3](d4f61d3)) * Show println output before an error occurs in `nargo execute` ([#3211](#3211)) ([2f0b80d](2f0b80d)) * Silence unused variable warnings in stdlib ([#2795](#2795)) ([5747bfe](5747bfe)) * Somewhat reduce mem2reg memory usage ([#3572](#3572)) ([9b9ed89](9b9ed89)) * Split conditional_regression tests ([#2774](#2774)) ([8ed8832](8ed8832)) * **ssa:** Do not replace previously constrained values ([#2647](#2647)) ([d528844](d528844)) * **traits:** Trait functions with a default implementation must not be followed by a semicolon ([#2987](#2987)) ([a3593c0](a3593c0)) * Transform hir before type checks ([#2994](#2994)) ([a29b568](a29b568)) * Update link to recursion example ([#3224](#3224)) ([10eae15](10eae15)) * Use 128 bits for constant bit shift ([#3586](#3586)) ([2ca9b05](2ca9b05)) * Use pedersen_hash for merkle tree ([#3357](#3357)) ([6b74d31](6b74d31)) * Verify impls arising from function calls exist ([#3472](#3472)) ([d7f919d](d7f919d)) ### Miscellaneous Chores * `generateWitness` now returns a serialized witness file ([#2842](#2842)) ([57d3f37](57d3f37)) * Bump MSRV to 1.71.1 ([#3353](#3353)) ([78f2127](78f2127)) * Change stdlib function `pedersen` to `pedersen_commitment` ([#3341](#3341)) ([964b777](964b777)) * Move circuit serialization circuit into acir ([#3345](#3345)) ([122119b](122119b)) * **noir_js:** Rename inner and outer proof methods ([#2845](#2845)) ([71dbbb8](71dbbb8)) * Update to `bb` version 0.7.3 ([#2729](#2729)) ([fce68d1](fce68d1)) </details> <details><summary>0.37.0</summary> ## [0.37.0](v0.36.0...v0.37.0) (2023-12-01) ### ⚠ BREAKING CHANGES * Move circuit serialization circuit into acir ([#3345](#3345)) * expose pedersen hash in acir and bb solver ([#3269](#3269)) * Switch to new pedersen implementation ([#3151](#3151)) * Pass ACIR to ACVM by reference rather than passing ownership ([#2872](#2872)) * **wasm:** improve and simplify wasm compiler interface ([#2976](#2976)) * Maintain shape of foreign call arguments ([#2935](#2935)) ### Features * **acvm_js:** Export black box solver functions ([#2812](#2812)) ([da8a98e](da8a98e)) * **acvm:** Separate ACVM optimizations and transformations ([#2979](#2979)) ([5865d1a](5865d1a)) * Add `FieldElement::from<usize>` implementation ([#3647](#3647)) ([8b7c5aa](8b7c5aa)) * Add ACIR serializer C++ codegen ([#2961](#2961)) ([7556982](7556982)) * Add conditional compilation of methods based on the underlying field being used ([#3045](#3045)) ([2e008e2](2e008e2)) * Add debugger commands to introspect (and modify) the current state ([#3391](#3391)) ([9e1ad85](9e1ad85)) * Aztec-packages ([#3599](#3599)) ([2cd6dc3](2cd6dc3)) * Expose pedersen hash in acir and bb solver ([#3269](#3269)) ([0108b6c](0108b6c)) * Extract Brillig VM to allow step debugging ([#3259](#3259)) ([f6431f9](f6431f9)) * Implement euclidean division and signed division in terms of `AcirVar`s ([#3230](#3230)) ([b8b7782](b8b7782)) * Maintain shape of foreign call arguments ([#2935](#2935)) ([f7869e6](f7869e6)) * Pass ACIR to ACVM by reference rather than passing ownership ([#2872](#2872)) ([b3a9c34](b3a9c34)) * Pass brillig bytecode to VM by reference ([#3030](#3030)) ([4ee290b](4ee290b)) * Refactor debugger and separate core from UI ([#3308](#3308)) ([8466810](8466810)) * Replace boolean range constraints with arithmetic opcodes ([#3234](#3234)) ([949222c](949222c)) * Save Brillig execution state in ACVM ([#3026](#3026)) ([88682da](88682da)) * Solve `fixed_base_scalar_mul` black box functions in rust ([#3153](#3153)) ([1c1afbc](1c1afbc)) * Switch to new pedersen implementation ([#3151](#3151)) ([35fb3f7](35fb3f7)) * **wasm:** Improve and simplify wasm compiler interface ([#2976](#2976)) ([1b5124b](1b5124b)) ### Bug Fixes * ACIR optimizer should update assertion messages ([#3010](#3010)) ([758b6b6](758b6b6)) * **acvm:** Return false rather than panicking on invalid ECDSA signatures ([#2783](#2783)) ([155abc0](155abc0)) * Determinism of fallback transformer ([#3100](#3100)) ([12daad1](12daad1)) * Fix method `program_counter`, change method signature ([#3012](#3012)) ([5ea522b](5ea522b)) * Minor problems with `aztec` publishing ([#3095](#3095)) ([0fc8f20](0fc8f20)) * Prevent duplicated assert message transformation ([#3038](#3038)) ([082a6d0](082a6d0)) * Return error rather than panicking on unreadable circuits ([#3179](#3179)) ([d4f61d3](d4f61d3)) ### Miscellaneous Chores * Move circuit serialization circuit into acir ([#3345](#3345)) ([122119b](122119b)) </details> --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
Description
This PR changes ACVM to retain the Brillig solver state while executing a circuit.
Problem
This is in preparation to support stepping into Brillig opcodes when debugging Brillig blocks (part of #3015). It also brings an additional benefit: the Brillig VM does not need to be restarted from scratch after resolving a foreign call, which should result in a performance improvement when executing circuits.
Summary
The
BrilligSolver
struct was modified to hold a Brillig VM instance and this is kept inACVM
inside anOption<>
while solving a Brillig ACIR opcode.In order to be able to push the results of foreign calls to the Brillig VM without having to rebuild it, a new method was added to push a
ForeignCallResult
to the results vector.These are additive changes and should not break existing code.
Documentation
This PR requires documentation updates when merged.
Additional Context
Some pending considerations:
foreign_call_results
parameter when initializing a Brillig VM, since new results can be inserted while running.PR Checklist
cargo fmt
on default settings.