Skip to content
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!: Unify ABIs between nargo and yarn-project #4035

Closed

Conversation

spalladino
Copy link
Contributor

Subrepo push of AztecProtocol/aztec-packages#3989 to a branch in order to trigger Noir CI

Should be merged as part of a proper git subrepo push

Comment on lines 143 to 144
Contract { contract: ContractArtifact, warnings: Vec<String> },
Program { program: ProgramArtifact, warnings: Vec<String> },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realise now that we're actually dropping all of the warnings from the noirc_frontend. Shall we drop these (warnings from noirc_evaluator) as well for now and then we can add a warnings field which contains both of these?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On third thoughts, I'm fairly sure that the types as emitted from the wasm are now completely ignored. There's types in the TS code which are what are meaningful now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally thought we'd still surface these types from the wasm into the TS. Seems like the lazy loading is throwing a spanner in the works however.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm leaving the warnings in for now if that's ok, I think we should make a bigger refactor around those ts types. I'll open another conversation for it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link

New dependencies detected. Learn more about Socket for GitHub ↗︎

Packages Version New capabilities Transitives Size Publisher
@types/pako 2.0.3 None +0 7.8 kB types
pako 2.1.0 None +0 1.64 MB vitaly

@spalladino
Copy link
Contributor Author

The error firing in the codegen-verify of the integration test seems to happen because of a wrong bb version being used. I could reproduce locally, then re-built bb and pointed NARGO_BACKEND_PATH to it, and code generation worked fine. Still, I did get an unreachable error running the recursion test:

test/browser/recursion.test.ts:

 🚧 Browser logs:
      Compiling at /src/main.nr
      Dependencies: 
      Adding source /src/main.nr
      Compiling at /src/main.nr
      Dependencies: 
      Adding source /src/main.nr

 ❌ It compiles noir program code, receiving circuit bytes and abi object. > Should generate valid inner proof for correct input, then verify proof within a proof
      RuntimeError: unreachable
        at wasm://wasm/017523ee:wasm-function[14038]:0x588099
        at wasm://wasm/017523ee:wasm-function[29]:0x1e831
        at wasm://wasm/017523ee:wasm-function[3889]:0x1aa7f3
        at wasm://wasm/017523ee:wasm-function[3887]:0x1aa4f9
        at wasm://wasm/017523ee:wasm-function[3885]:0x1aa470
        at wasm://wasm/017523ee:wasm-function[3884]:0x1aa402
        at wasm://wasm/017523ee:wasm-function[3844]:0x1a9830
        at wasm://wasm/017523ee:wasm-function[3666]:0x1a8162
        at wasm://wasm/017523ee:wasm-function[3652]:0x1a7c11
        at wasm://wasm/017523ee:wasm-function[3643]:0x1a795d

Not sure how to unblock this one.

Copy link
Member

@TomAFrench TomAFrench left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine to me. The JS types are still outdated and referring to internal compiler structs however.

@@ -57,12 +59,16 @@ export interface NoirFunctionEntry {
export interface CompiledContract {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export interface CompiledContract {
export interface ContractArtifact {

Comment on lines 64 to 65
/** Compilation backend. */
backend: string;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/** Compilation backend. */
backend: string;

@@ -73,12 +79,14 @@ export interface CompiledCircuit {
hash?: number;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a ProgramArtifact

Comment on lines 80 to 81
/** Compilation backend. */
backend: string;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/** Compilation backend. */
backend: string;

spalladino added a commit to AztecProtocol/aztec-packages that referenced this pull request Jan 17, 2024
Changes the output of `nargo` and `noir-wasm` to generate a single
artifact that includes debug information. Compiled contracts now have a
`file_map` at the root of the artifact, and a `debug_symbols` within
each function. For consistency, compiled programs also have `file_map`
and `debug_symbols`. Debug symbols are compressed and base64-encoded, as
they were by the former `noir-compiler` postprocessing. The `debug` json
artifact is no longer emitted.

Removes all code related to generating `yarn-project`-specific ABIs from
noir compiler. Instead, `types` now exposes a `loadContractArtifact`
that renames fields as needed (and use camel instead of snake case), and
is required when loading a noir contract artifact. Autogenerated types
run this automatically.

Since we are no longer post-processing artifacts, the `noir-contracts`
project shape is changed. JSON files live in the `target` folder where
nargo outputs them (this is not configurable), and are loaded by the
autogenerated typescript interfaces from there.

As part of the refactor, moves functions for getting functions debug
info out of `acir-simulator` and into `types`.

**Breaking change**: This removes the need to run `codegen` for using a
compiled contract. However, when creating a new contract object from
aztec.js, a dev needs to call `loadContractArtifact`.

**Future changes**: Type information for a compilation artifact is now
spread all over the place, and duplicated in more than one place. There
are types defined within rust code in Noir as
`[wasm_bindgen(typescript_custom_section)]`, others defined within
typescript code in the `noir_wasm` package, others in `foundation`, and
others in `types`. We should unify it in a single place.

Fixes #3812

Supersedes #3906

Noir subrepo has been pushed to
noir-lang/noir#4035 to run the Noir CI
AztecBot pushed a commit that referenced this pull request Jan 17, 2024
Changes the output of `nargo` and `noir-wasm` to generate a single
artifact that includes debug information. Compiled contracts now have a
`file_map` at the root of the artifact, and a `debug_symbols` within
each function. For consistency, compiled programs also have `file_map`
and `debug_symbols`. Debug symbols are compressed and base64-encoded, as
they were by the former `noir-compiler` postprocessing. The `debug` json
artifact is no longer emitted.

Removes all code related to generating `yarn-project`-specific ABIs from
noir compiler. Instead, `types` now exposes a `loadContractArtifact`
that renames fields as needed (and use camel instead of snake case), and
is required when loading a noir contract artifact. Autogenerated types
run this automatically.

Since we are no longer post-processing artifacts, the `noir-contracts`
project shape is changed. JSON files live in the `target` folder where
nargo outputs them (this is not configurable), and are loaded by the
autogenerated typescript interfaces from there.

As part of the refactor, moves functions for getting functions debug
info out of `acir-simulator` and into `types`.

**Breaking change**: This removes the need to run `codegen` for using a
compiled contract. However, when creating a new contract object from
aztec.js, a dev needs to call `loadContractArtifact`.

**Future changes**: Type information for a compilation artifact is now
spread all over the place, and duplicated in more than one place. There
are types defined within rust code in Noir as
`[wasm_bindgen(typescript_custom_section)]`, others defined within
typescript code in the `noir_wasm` package, others in `foundation`, and
others in `types`. We should unify it in a single place.

Fixes AztecProtocol/aztec-packages#3812

Supersedes #3906

Noir subrepo has been pushed to
#4035 to run the Noir CI
@TomAFrench
Copy link
Member

Closing as this got merged in aztec-packages.

@TomAFrench TomAFrench closed this Jan 22, 2024
michaelelliot pushed a commit to Swoir/noir_rs that referenced this pull request Feb 28, 2024
Changes the output of `nargo` and `noir-wasm` to generate a single
artifact that includes debug information. Compiled contracts now have a
`file_map` at the root of the artifact, and a `debug_symbols` within
each function. For consistency, compiled programs also have `file_map`
and `debug_symbols`. Debug symbols are compressed and base64-encoded, as
they were by the former `noir-compiler` postprocessing. The `debug` json
artifact is no longer emitted.

Removes all code related to generating `yarn-project`-specific ABIs from
noir compiler. Instead, `types` now exposes a `loadContractArtifact`
that renames fields as needed (and use camel instead of snake case), and
is required when loading a noir contract artifact. Autogenerated types
run this automatically.

Since we are no longer post-processing artifacts, the `noir-contracts`
project shape is changed. JSON files live in the `target` folder where
nargo outputs them (this is not configurable), and are loaded by the
autogenerated typescript interfaces from there.

As part of the refactor, moves functions for getting functions debug
info out of `acir-simulator` and into `types`.

**Breaking change**: This removes the need to run `codegen` for using a
compiled contract. However, when creating a new contract object from
aztec.js, a dev needs to call `loadContractArtifact`.

**Future changes**: Type information for a compilation artifact is now
spread all over the place, and duplicated in more than one place. There
are types defined within rust code in Noir as
`[wasm_bindgen(typescript_custom_section)]`, others defined within
typescript code in the `noir_wasm` package, others in `foundation`, and
others in `types`. We should unify it in a single place.

Fixes AztecProtocol#3812

Supersedes AztecProtocol#3906

Noir subrepo has been pushed to
noir-lang/noir#4035 to run the Noir CI
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants