-
Notifications
You must be signed in to change notification settings - Fork 219
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(frontend): aztec syntactic sugar (feature flagged) #2403
Conversation
#[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 |
We havent finalized this standard in the Aztec team. Once it is final i will make a followup pr |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm considering this temporary code so I only skimmed it. We can add to it/fix it later if needed
…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"); } ```
based |
* 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) ...
* 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) ...
…(#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"); } ```
Description
Linked work
#[aztec(private)]
and#[aztec(public)
attributes AztecProtocol/aztec-packages#1735Performs some code generation on
aztec
annotated 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
block
ormsg
structures.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 fmt
on default settings.