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

public-vm(aztec-nr): Add oracles and context for AVM opcodes #4313

Closed
Tracked by #3313
Maddiaa0 opened this issue Jan 30, 2024 · 0 comments · Fixed by #4438
Closed
Tracked by #3313

public-vm(aztec-nr): Add oracles and context for AVM opcodes #4313

Maddiaa0 opened this issue Jan 30, 2024 · 0 comments · Fixed by #4438
Assignees
Labels
avm AVM related tickets (aka public VM)

Comments

@Maddiaa0
Copy link
Member

Maddiaa0 commented Jan 30, 2024

Overview

The avm transpiler converts instances of brillig bytecode into avm bytecode, oracle calls in brillig are represented as foreign_call("oracle_name"). These are then swapped out for the avm opcode that gets the particular value.

Public calls have their own context for reading in such values, reading in global variables, or getting note externally

struct AvmContext {

}

We want to create an avm context that will enable the transpiler to insert the correct opcodes for fetching environment getters etc.

@Maddiaa0 Maddiaa0 changed the title public-vm(aztec-nr): Add oracles for AVM opcodes public-vm(aztec-nr): Add oracles and context for AVM opcodes Jan 30, 2024
@Maddiaa0 Maddiaa0 self-assigned this Jan 30, 2024
@Maddiaa0 Maddiaa0 added the avm AVM related tickets (aka public VM) label Jan 30, 2024
AztecBot pushed a commit to AztecProtocol/aztec-nr that referenced this issue Feb 6, 2024
fcarreiro added a commit that referenced this issue Mar 11, 2024
This PR enables the stack of 6 PRs on top.
\
While working on external calls, we came across several problems with Brillig. I made some changes to fix them. Some Brillig changes:
* **Truncation**: Brillig was using AND of Fields (actually, AND on Ints of 254 bits). This is not supported by the VM. Truncation was changed to be done without ANDing, and using `CAST` instead, which truncates to the required bit size. 
* **Array.get**/**Array.set**: Calculation of the `arrayBase+index` was done using field arithmetic (or field sizes). Now it's done using ints.
* **Reference counting**: Checking `refCount==1` was done using field arithmetic (or field sizes). Now it's done with ints.

These changes seem to solve all the comparison w/different bit sizes, and unexpected uses of field arithmetic. (That we've found with the current test contract).

NOTE: I had to recreate the contract snapshots with `yarn workspace @aztec/protocol-contracts test -u`, then modify 
* noir-projects/noir-contracts/contracts/app_subscription_contract/src/main.nr
* noir-projects/noir-contracts/contracts/fpc_contract/src/main.nr

Relates to #4313, #4127.
fcarreiro added a commit that referenced this issue Mar 11, 2024
* Logging
* `Call` and `StaticCall` were returning Field while per YP should be Uint8.
* I'm also moving the RETURN and REVERT opcodes to `external_calls.ts` (from `control_flow.ts`).

Relates to #4313, #4127.
fcarreiro added a commit that referenced this issue Mar 11, 2024
This PR finishes the external call opcodes, adds the necessary aztec.nr machinery and tests. It's based on David's work.

Relates to #4313, #4127.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
avm AVM related tickets (aka public VM)
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant