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

Please implement deflating heap arrays from foregin calls #4561

Closed
LogvinovLeon opened this issue Mar 15, 2024 · 5 comments · Fixed by #5132
Closed

Please implement deflating heap arrays from foregin calls #4561

LogvinovLeon opened this issue Mar 15, 2024 · 5 comments · Fixed by #5132
Assignees
Labels
bug Something isn't working

Comments

@LogvinovLeon
Copy link
Contributor

LogvinovLeon commented Mar 15, 2024

Aim

I want to receive a two dimensional array from an oracle.

Expected Behavior

It works

Bug

Failed calling external resolver. JSON decode error: invalid type: map, expected a string at line 1 column 30

To Reproduce

  1. git clone https://github.com/vlayer-xyz/noir-oracles-2d-arrays-repro.git
  2. cd noir-oracles-2d-arrays-repro
  3. rm -r target
  4. yarn install
  5. yarn start
  6. (In a separate terminal) nargo prove --oracle-resolver http://localhost:5555

Gets error:

Failed calling external resolver. JSON decode error: invalid type: map, expected a string at line 1 column 30

Project Impact

Nice-to-have

Impact Context

Without this - I need to linearise arrays and have serde logic in Noir

Workaround

Yes

Workaround Description

custom serde

Additional Context

No response

Installation Method

Binary (noirup default)

Nargo Version

nargo version = 0.26.0
noirc version = 0.26.0+c46b164ce56e6a8f81255fb17eb6539bd040f336
(git version hash: c46b164, is dirty: false)

NoirJS Version

No response

Would you like to submit a PR for this Issue?

None

Support Needs

No response

@LogvinovLeon LogvinovLeon added the bug Something isn't working label Mar 15, 2024
@github-project-automation github-project-automation bot moved this to 📋 Backlog in Noir Mar 15, 2024
@LogvinovLeon
Copy link
Contributor Author

Also - the type in @noir-lang/acvm_js doesn't support 2d arrays

export type ForeignCallOutput = string | string[]

For context: I'm trying to prove ethereum receipt inclusion. Receipts include arrays of logs. And each data is an array by itself, so would be really nice to have nested structures support in oracles

@marekkirejczyk
Copy link

marekkirejczyk commented Mar 22, 2024

@LogvinovLeon Would you add reproduction?

@LogvinovLeon
Copy link
Contributor Author

@LogvinovLeon
Copy link
Contributor Author

Use cases for it:

  • We want to ask an oracle to return us an array of storage proofs. Each storage proof is a struct containing arrays as it's fields.
  • Because Option type is not supported in brillig we want to simulate option with a struct Optional<T> { value: T, is_some: bool}, but brillig does not support nested structs

@Savio-Sou
Copy link
Collaborator

Thanks @LogvinovLeon. Updated the Issue body with what I believe are the steps for reproduction, let us know if any of them is in conflict with your intention / experience 🙌

github-merge-queue bot pushed a commit that referenced this issue Jun 13, 2024
# Description

## Problem\*

Resolves #4561

## Summary\*
Generates brillig arrays of arrays during brillig-gen for types having
nested arrays.
Populate these nested brillig arrays in the brillig VM when data
returned from oracles does not match the size of the outer array


## Additional Context
For this to work, it is required that the oracle returns flatten values,
although its Noir signature is a nested type.
It's certainly possible to deserialise nested json arrays but I could
not get it done easily so it'll be better handled in a separate PR.


## Documentation\*

Check one:
- [ ] No documentation needed.
- [X] Documentation included in this PR.
- [ ] **[For Experimental Features]** Documentation to be submitted in a
separate PR.

# PR Checklist\*

- [X] I have tested the changes locally.
- [X] I have formatted the changes with [Prettier](https://prettier.io/)
and/or `cargo fmt` on default settings.

---------

Co-authored-by: Álvaro Rodríguez <[email protected]>
Co-authored-by: TomAFrench <[email protected]>
@github-project-automation github-project-automation bot moved this from 📋 Backlog to ✅ Done in Noir Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: ✅ Done
Development

Successfully merging a pull request may close this issue.

5 participants