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: Sync from aztec-packages #4825

Closed
wants to merge 8 commits into from
Closed

feat: Sync from aztec-packages #4825

wants to merge 8 commits into from

Commits on Apr 16, 2024

  1. chore: Use BrilligCall for unconstrained main and update AVM transpil…

    …er (AztecProtocol/aztec-packages#5797)
    
    A follow-up to AztecProtocol/aztec-packages#5737
    
    Separate PR as this touches mainly the AVM transpiler and not Noir
    codegen itself. Look in PR #5737 for full details about the switch, but
    basically we are moving away from the `Brillig` opcode to a
    `BrilligCall` opcode that contains a Brillig call opcode. The AVM needs
    to be updated to account for this change.
    AztecBot committed Apr 16, 2024
    Configuration menu
    Copy the full SHA
    8314554 View commit details
    Browse the repository at this point in the history

Commits on Apr 17, 2024

  1. fix: Don't reuse brillig with slice arguments (AztecProtocol/aztec-pa…

    …ckages#5800)
    
    This is a quick fix after
    AztecProtocol/aztec-packages#5737 since that PR
    assumes that one generated brillig is valid for all calls to the brillig
    function. This is however not true, since the generated brillig can
    differ if the arguments contains slices. This is because the entry point
    codegen depends on the size of the slice.
    We currently cannot copy slices of any length into brillig due to the
    limitations of
    [CALLDATACOPY](https://yp-aztec.netlify.app/docs/public-vm/instruction-set#calldatacopy)
    where the size being copied needs to be known at compile-time. I'm going
    to chat with the AVM team to see if we can lift this restriction and
    make brillig entry points be able to copy in arguments that contain
    slices of any length.
    AztecBot committed Apr 17, 2024
    Configuration menu
    Copy the full SHA
    2aae5ce View commit details
    Browse the repository at this point in the history
  2. fix: Don't reuse brillig with slice arguments (AztecProtocol/aztec-pa…

    …ckages#5800)
    
    This is a quick fix after
    AztecProtocol/aztec-packages#5737 since that PR
    assumes that one generated brillig is valid for all calls to the brillig
    function. This is however not true, since the generated brillig can
    differ if the arguments contains slices. This is because the entry point
    codegen depends on the size of the slice.
    We currently cannot copy slices of any length into brillig due to the
    limitations of
    [CALLDATACOPY](https://yp-aztec.netlify.app/docs/public-vm/instruction-set#calldatacopy)
    where the size being copied needs to be known at compile-time. I'm going
    to chat with the AVM team to see if we can lift this restriction and
    make brillig entry points be able to copy in arguments that contain
    slices of any length.
    AztecBot committed Apr 17, 2024
    Configuration menu
    Copy the full SHA
    961ca28 View commit details
    Browse the repository at this point in the history
  3. feat!: contract interfaces and better function calls (AztecProtocol/a…

    …ztec-packages#5687)
    
    Closes AztecProtocol/aztec-packages#5081
    
    This PR introduces autogenerated contract interfaces for easy intra and
    inter contract interactions. The `aztec-macro` crate is used to stub
    every non-internal private and public function and inject them into a
    ghost struct which has the same name as the contract that generated
    them. After that, they can be called like this:
    
    ```rust
    
    contract ImportTest {
    
      use dep::my_imported_contract::MyImportedContract;
    
      #[aztec(private)]
      fn a_private_fn() {
        let deserialized_return = MyImportedContract::at(some_address).another_private_fn(arg1, arg2).call(&mut context);
        MyImportedContract::at(some_address).a_public_fn(arg1).enqueue(&mut context);
      }
    
      #[aztec(public)]
      fn a_public_fn() {
        let deserialized_return = MyImportedContract::at(some_address).a_public_fn(arg1).call(&mut context);
      }
    
      #[aztec(private)]
      fn calling_my_own_fns() {
        ImportTest::at(context.this_address).a_private_fn().call(&mut context);
        ImportTest::at(context.this_address).a_public_fn().enqueue(&mut context);
      }
    
    }
    ```
    
    Return values are `deserialized_into()` automatically, providing "real"
    return values thanks to
    AztecProtocol/aztec-packages#5633
    
    Also, some general cleanup was required to allow importing contracts in
    another contracts. Main changes:
    
    - `HirContext.fully_qualified_struct_path` now uses BFS to avoid
    returning the longest path when looking for a struct in a crate. This is
    required to avoid pulling structs usually imported in top-level
    dependencies (usually notes from our main contract) from other imported
    contracts.
    - `pack_args_oracle` now has a slice mode in addition to its usual array
    mode.
    
    PENDING:
    
    ~~AvmContext. The AVM team is discussing supporting args as slices. In
    case it's decided not to do that, a workaround could possibly be
    implemented using the macro, but it would be fairly complex.~~
    
    Thanks to @fcarreiro and the amazing AVM team, this is now supported for
    the AvmContext!
    
    ---------
    
    Co-authored-by: esau <152162806+sklppy88@users.noreply.github.com>
    Co-authored-by: Álvaro Rodríguez <sirasistant@gmail.com>
    3 people committed Apr 17, 2024
    Configuration menu
    Copy the full SHA
    4f32473 View commit details
    Browse the repository at this point in the history
  4. feat!: contract interfaces and better function calls (AztecProtocol/a…

    …ztec-packages#5687)
    
    Closes AztecProtocol/aztec-packages#5081
    
    This PR introduces autogenerated contract interfaces for easy intra and
    inter contract interactions. The `aztec-macro` crate is used to stub
    every non-internal private and public function and inject them into a
    ghost struct which has the same name as the contract that generated
    them. After that, they can be called like this:
    
    ```rust
    
    contract ImportTest {
    
      use dep::my_imported_contract::MyImportedContract;
    
      #[aztec(private)]
      fn a_private_fn() {
        let deserialized_return = MyImportedContract::at(some_address).another_private_fn(arg1, arg2).call(&mut context);
        MyImportedContract::at(some_address).a_public_fn(arg1).enqueue(&mut context);
      }
    
      #[aztec(public)]
      fn a_public_fn() {
        let deserialized_return = MyImportedContract::at(some_address).a_public_fn(arg1).call(&mut context);
      }
    
      #[aztec(private)]
      fn calling_my_own_fns() {
        ImportTest::at(context.this_address).a_private_fn().call(&mut context);
        ImportTest::at(context.this_address).a_public_fn().enqueue(&mut context);
      }
    
    }
    ```
    
    Return values are `deserialized_into()` automatically, providing "real"
    return values thanks to
    AztecProtocol/aztec-packages#5633
    
    Also, some general cleanup was required to allow importing contracts in
    another contracts. Main changes:
    
    - `HirContext.fully_qualified_struct_path` now uses BFS to avoid
    returning the longest path when looking for a struct in a crate. This is
    required to avoid pulling structs usually imported in top-level
    dependencies (usually notes from our main contract) from other imported
    contracts.
    - `pack_args_oracle` now has a slice mode in addition to its usual array
    mode.
    
    PENDING:
    
    ~~AvmContext. The AVM team is discussing supporting args as slices. In
    case it's decided not to do that, a workaround could possibly be
    implemented using the macro, but it would be fairly complex.~~
    
    Thanks to @fcarreiro and the amazing AVM team, this is now supported for
    the AvmContext!
    
    ---------
    
    Co-authored-by: esau <152162806+sklppy88@users.noreply.github.com>
    Co-authored-by: Álvaro Rodríguez <sirasistant@gmail.com>
    3 people committed Apr 17, 2024
    Configuration menu
    Copy the full SHA
    b25ca49 View commit details
    Browse the repository at this point in the history
  5. feat: Sync from noir (AztecProtocol/aztec-packages#5794)

    Automated pull of development from the
    [noir](https://github.com/noir-lang/noir) programming language, a
    dependency of Aztec.
    BEGIN_COMMIT_OVERRIDE
    chore: fix alerts on rust msrv
    (#4817)
    chore(ci): fix alerts on msrv issues
    (#4816)
    chore: run clippy (#4810)
    chore: optimize poseidon2 implementation
    (#4807)
    fix: catch panics from EC point creation (e.g. the point is at infinity)
    (#4790)
    feat: Sync from aztec-packages
    (#4792)
    feat: lalrpop lexer prototype
    (#4656)
    feat(nargo): Handle call stacks for multiple Acir calls
    (#4711)
    fix: proper field inversion for bigints
    (#4802)
    feat: add `NARGO_FOREIGN_CALL_TIMEOUT` environment variable
    (#4780)
    chore(debugger): Docs (#4145)
    feat: narrow ABI encoding errors down to target problem argument/field
    (#4798)
    chore: Rename 'global' to 'function' in the monomorphization pass
    (#4774)
    chore: Add Hir -> Ast conversion
    (#4788)
    fix: Fix panic when returning a zeroed unit value
    (#4797)
    END_COMMIT_OVERRIDE
    
    ---------
    
    Co-authored-by: vezenovm <mvezenov@gmail.com>
    Co-authored-by: Tom French <15848336+TomAFrench@users.noreply.github.com>
    3 people committed Apr 17, 2024
    Configuration menu
    Copy the full SHA
    3d39823 View commit details
    Browse the repository at this point in the history
  6. feat: Sync from noir (AztecProtocol/aztec-packages#5794)

    Automated pull of development from the
    [noir](https://github.com/noir-lang/noir) programming language, a
    dependency of Aztec.
    BEGIN_COMMIT_OVERRIDE
    chore: fix alerts on rust msrv
    (#4817)
    chore(ci): fix alerts on msrv issues
    (#4816)
    chore: run clippy (#4810)
    chore: optimize poseidon2 implementation
    (#4807)
    fix: catch panics from EC point creation (e.g. the point is at infinity)
    (#4790)
    feat: Sync from aztec-packages
    (#4792)
    feat: lalrpop lexer prototype
    (#4656)
    feat(nargo): Handle call stacks for multiple Acir calls
    (#4711)
    fix: proper field inversion for bigints
    (#4802)
    feat: add `NARGO_FOREIGN_CALL_TIMEOUT` environment variable
    (#4780)
    chore(debugger): Docs (#4145)
    feat: narrow ABI encoding errors down to target problem argument/field
    (#4798)
    chore: Rename 'global' to 'function' in the monomorphization pass
    (#4774)
    chore: Add Hir -> Ast conversion
    (#4788)
    fix: Fix panic when returning a zeroed unit value
    (#4797)
    END_COMMIT_OVERRIDE
    
    ---------
    
    Co-authored-by: vezenovm <mvezenov@gmail.com>
    Co-authored-by: Tom French <15848336+TomAFrench@users.noreply.github.com>
    3 people committed Apr 17, 2024
    Configuration menu
    Copy the full SHA
    536a067 View commit details
    Browse the repository at this point in the history
  7. Merge branch 'master' into aztec-packages

    * master:
      chore: remove unnecessary casts in `BoundedVec` (#4831)
      fix: issue 4682 and add solver for unconstrained bigintegers (#4729)
      chore(docs): fix wrong Nargo.toml workspace examples (#4822)
      chore: delete unnecessary Prover.toml file (#4829)
      chore: fix alerts on rust msrv (#4817)
      chore(ci): fix alerts on msrv issues (#4816)
      chore: run clippy (#4810)
      chore: optimize poseidon2 implementation (#4807)
      fix: catch panics from EC point creation (e.g. the point is at infinity) (#4790)
    TomAFrench committed Apr 17, 2024
    Configuration menu
    Copy the full SHA
    cffc206 View commit details
    Browse the repository at this point in the history