feat(frontend): aztec syntactic sugar (feature flagged)#2403
Merged
feat(frontend): aztec syntactic sugar (feature flagged)#2403
Conversation
Contributor
#[aztec(private)]
fn mint(
amount: Field,
owner: Field
) {
let storage = Storage::init();
// Insert new note to a set of user notes and emit the newly created encrypted note preimage via oracle call.
let owner_balance = storage.balances.at(owner);
send_note(&mut context, owner_balance, amount, owner);
emit_unencrypted_log(&mut context, "Coins minted");
}Can you make it so the |
jfecher
requested changes
Aug 22, 2023
kevaundray
reviewed
Aug 29, 2023
Maddiaa0
commented
Aug 29, 2023
Maddiaa0
commented
Aug 29, 2023
Member
Author
We havent finalized this standard in the Aztec team. Once it is final i will make a followup pr |
jfecher
reviewed
Aug 29, 2023
jfecher
reviewed
Aug 29, 2023
jfecher
approved these changes
Aug 29, 2023
Contributor
jfecher
left a comment
There was a problem hiding this comment.
I'm considering this temporary code so I only skimmed it. We can add to it/fix it later if needed
Maddiaa0
added a commit
to AztecProtocol/aztec-packages
that referenced
this pull request
Aug 29, 2023
…1735) ## Overview Now that noir-lang/noir#2403 has been merged into noir and released under the `aztec` tag. This PR now builds! This cleans up the syntax for noir programs, making them less verbose and easier to get started with. For example what originally was: ```rust fn mint( inputs: PrivateContextInputs, amount: Field, owner: Field ) -> distinct pub abi::PrivateCircuitPublicInputs { let storage = Storage::init(); let mut context = PrivateContext::new(inputs, abi::hash_args([amount, owner])); // Insert new note to a set of user notes and emit the newly created encrypted note preimage via oracle call. let owner_balance = storage.balances.at(owner); send_note(&mut context, owner_balance, amount, owner); emit_unencrypted_log(&mut context, "Coins minted"); // Return private circuit public inputs. All private functions need to return this as it is part of the input of the private kernel.. context.finish() } ``` can instead be written as: ```rust #[aztec(private)] fn mint( amount: Field, owner: Field ) { let storage = Storage::init(); // Insert new note to a set of user notes and emit the newly created encrypted note preimage via oracle call. let owner_balance = storage.balances.at(owner); send_note(&mut context, owner_balance, amount, owner); emit_unencrypted_log(&mut context, "Coins minted"); } ```
Collaborator
|
based |
TomAFrench
added a commit
that referenced
this pull request
Aug 30, 2023
* master: (42 commits) fix(ssa): Handle right shift with constants (#2481) chore(noir): Release 0.10.4 (#2354) fix: Divide by zero should fail to satisfy constraints for `Field` and ints (#2475) fix(ssa): Remove padding from ToRadix call with constant inputs (#2479) fix: Implement handling of array aliasing in the mem2reg optimization pass (#2463) chore: resolve `Instruction` inputs fully before checking against cache (#2472) chore: Move independent `run_test` function into nargo core (#2468) feat: Standard library functions can now be called with closure args (#2471) feat(frontend): aztec syntactic sugar (feature flagged) (#2403) chore(ci): enforce compliance with `cargo fmt` (#2467) chore(ci): Allow releases to have additional feature flags (#2405) feat: Add `assert_eq` keyword (#2137) fix(ssa): Do not optimize for allocates in constant folding (#2466) feat(ssa): Reuse existing results for duplicated instructions with no side-effects (#2460) fix: Closure lvalue capture bugfix (#2457) feat: Syntax for environment types now works with generics (#2383) fix(parser): fixes for the parsing of 'where' clauses (#2430) fix: Run `wasm` nodejs tests with no fails (#2387) chore: Run `cargo fmt` (#2455) chore: Perform formatting changes to integration tests (#2448) ...
TomAFrench
added a commit
that referenced
this pull request
Aug 30, 2023
* master: (42 commits) fix(ssa): Handle right shift with constants (#2481) chore(noir): Release 0.10.4 (#2354) fix: Divide by zero should fail to satisfy constraints for `Field` and ints (#2475) fix(ssa): Remove padding from ToRadix call with constant inputs (#2479) fix: Implement handling of array aliasing in the mem2reg optimization pass (#2463) chore: resolve `Instruction` inputs fully before checking against cache (#2472) chore: Move independent `run_test` function into nargo core (#2468) feat: Standard library functions can now be called with closure args (#2471) feat(frontend): aztec syntactic sugar (feature flagged) (#2403) chore(ci): enforce compliance with `cargo fmt` (#2467) chore(ci): Allow releases to have additional feature flags (#2405) feat: Add `assert_eq` keyword (#2137) fix(ssa): Do not optimize for allocates in constant folding (#2466) feat(ssa): Reuse existing results for duplicated instructions with no side-effects (#2460) fix: Closure lvalue capture bugfix (#2457) feat: Syntax for environment types now works with generics (#2383) fix(parser): fixes for the parsing of 'where' clauses (#2430) fix: Run `wasm` nodejs tests with no fails (#2387) chore: Run `cargo fmt` (#2455) chore: Perform formatting changes to integration tests (#2448) ...
superstar0402
added a commit
to superstar0402/aztec-nr
that referenced
this pull request
Aug 16, 2024
…(#1735) ## Overview Now that noir-lang/noir#2403 has been merged into noir and released under the `aztec` tag. This PR now builds! This cleans up the syntax for noir programs, making them less verbose and easier to get started with. For example what originally was: ```rust fn mint( inputs: PrivateContextInputs, amount: Field, owner: Field ) -> distinct pub abi::PrivateCircuitPublicInputs { let storage = Storage::init(); let mut context = PrivateContext::new(inputs, abi::hash_args([amount, owner])); // Insert new note to a set of user notes and emit the newly created encrypted note preimage via oracle call. let owner_balance = storage.balances.at(owner); send_note(&mut context, owner_balance, amount, owner); emit_unencrypted_log(&mut context, "Coins minted"); // Return private circuit public inputs. All private functions need to return this as it is part of the input of the private kernel.. context.finish() } ``` can instead be written as: ```rust #[aztec(private)] fn mint( amount: Field, owner: Field ) { let storage = Storage::init(); // Insert new note to a set of user notes and emit the newly created encrypted note preimage via oracle call. let owner_balance = storage.balances.at(owner); send_note(&mut context, owner_balance, amount, owner); emit_unencrypted_log(&mut context, "Coins minted"); } ```
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Linked work
#[aztec(private)]and#[aztec(public)attributes AztecProtocol/aztec-packages#1735Performs some code generation on
aztecannotated functions.The goal of this PR is to abstract the app developer away from boilerplate code that is required to make noir compatible with the aztec execution environment.
For example what originally was:
can instead be written as:
This will reduce the barrier for entry to new devs, making the syntax alot more approachable for them.
What does it abstract away
There is an execution context created in each function that allows the developer to:
among many other things.
This context is created by providing set inputs to each circuit (depending on the execution environment) and by hashing the other circuit inputs.
At the end of each call the inputs for the kernel iteration must be set as public inputs (returned). This is done with a call to
context.finish().Each macro:
As the "macro" inserts the "context" into the ast, the context object is available to them as it it was something like solidity's
blockormsgstructures.subnote:
The storage pattern has not been added to this just yet as we have not concretely standardised this pattern. This shall be follow up work
Documentation
This PR requires documentation updates when merged.
Additional Context
PR Checklist*
cargo fmton default settings.