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(nargo): add skeleton of composite types in template input tomls #1104

Merged
merged 2 commits into from
Apr 6, 2023

Conversation

TomAFrench
Copy link
Member

Related issue(s)

Resolves #

Description

Summary of changes

Consider the program

struct MyStruct {
  d1: Field,
  d2: [Field; 2],
}

fn main(a: Field, b: u32, c: [Field; 2], d: MyStruct, e: bool) {}

Currently this gets templated into Prover.toml by nargo check as

a = ""
b = ""
c = []
d = ""
e = ""

This adds unnecessary friction as d is really a table and will need to be moved down to the bottom of the file and the user is responsible for adding all of its fields. This can lead to an annoying back and forth with ABIErrors when trying to fill in this file.

To address this, we now template each AbiType recursively to produce

a = ""
b = ""
c = ["", ""]
e = ""

[d]
d1 = ""
d2 = ["", "", ""]

Users no longer have to rebuild their struct types or worry about lengths of array, just replace anywhere there's a "" with an actual value.

Dependency additions / changes

Test additions / changes

I've added a test as a smoke test for this.

Checklist

  • I have tested the changes locally.
  • I have formatted the changes with Prettier and/or cargo fmt with default settings.
  • I have linked this PR to the issue(s) that it resolves.
  • I have reviewed the changes on GitHub, line by line.
  • I have ensured all changes are covered in the description.

Documentation needs

  • This PR requires documentation updates when merged.

Any examples of generated Prover.toml files in the docs need to be updated if they contain structs or arrays.

Additional context

@kevaundray kevaundray added this pull request to the merge queue Apr 6, 2023
Merged via the queue into master with commit 1fb2756 Apr 6, 2023
@kevaundray kevaundray deleted the input-toml-template branch April 6, 2023 16:39
@Savio-Sou
Copy link
Collaborator

Prover.toml examples in the docs do not involve structs or arrays.

Thanks for flagging nonetheless. Removing doc needed label now.

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.

3 participants