Skip to content

Commit

Permalink
feat: Sync from noir (#9099)
Browse files Browse the repository at this point in the history
Automated pull of development from the
[noir](https://github.com/noir-lang/noir) programming language, a
dependency of Aztec.
BEGIN_COMMIT_OVERRIDE
feat(test): Fuzz poseidon hases against an external library
(noir-lang/noir#6273)
feat: remove byte decomposition in `compute_decomposition`
(noir-lang/noir#6159)
fix: address inactive public key check in `verify_signature_noir`
(noir-lang/noir#6270)
feat(test): Fuzz test poseidon2 hash equivalence
(noir-lang/noir#6265)
fix!: Integer division is not the inverse of integer multiplication
(noir-lang/noir#6243)
feat(perf): Flamegraphs for test program execution benchmarks
(noir-lang/noir#6253)
fix: visibility for impl methods
(noir-lang/noir#6261)
feat: Add `checked_transmute`
(noir-lang/noir#6262)
feat!: kind size checks (noir-lang/noir#6137)
feat: don't crash LSP when there are errors resolving the workspace
(noir-lang/noir#6257)
fix: don't warn on unuse global if it has an abi annotation
(noir-lang/noir#6258)
fix: don't warn on unused struct that has an abi annotation
(noir-lang/noir#6254)
feat: don't suggest private struct fields in LSP
(noir-lang/noir#6256)
feat: visibility for struct fields
(noir-lang/noir#6221)
fix: handle dfg databus in SSA normalization
(noir-lang/noir#6249)
fix: homogeneous input points for EC ADD
(noir-lang/noir#6241)
chore: add regression test for #5756
(noir-lang/noir#5770)
feat: allow `unconstrained` after visibility
(noir-lang/noir#6246)
feat: optimize `Quoted::as_expr` by parsing just once
(noir-lang/noir#6237)
fix(frontend): Do not warn when a nested struct is provided as input to
main (noir-lang/noir#6239)
fix!: Change tag attributes to require a ' prefix
(noir-lang/noir#6235)
feat: recover from '=' instead of ':' in struct constructor/pattern
(noir-lang/noir#6236)
END_COMMIT_OVERRIDE

---------

Co-authored-by: Tom French <tom@tomfren.ch>
  • Loading branch information
AztecBot and TomAFrench authored Oct 14, 2024
1 parent 0fa1423 commit 5a3a8cc
Show file tree
Hide file tree
Showing 257 changed files with 4,750 additions and 1,347 deletions.
2 changes: 1 addition & 1 deletion .noir-sync-commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
c4273a0c8f8b751a3dbe097e070e4e7b2c8ec438
ae87d287ab1fae0f999dfd0d1166fbddb927ba97
4 changes: 3 additions & 1 deletion boxes/boxes/react/src/contracts/src/main.nr
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ contract BoxReact {
}

#[private]
#[initializer]
#['private]
#['initializer]
fn constructor(
number: Field,
owner: AztecAddress,
Expand All @@ -30,6 +31,7 @@ contract BoxReact {
}

#[private]
#['private]
fn setNumber(
number: Field,
owner: AztecAddress,
Expand Down
4 changes: 3 additions & 1 deletion boxes/boxes/vanilla/src/contracts/src/main.nr
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ contract Vanilla {
}

#[private]
#[initializer]
#['private]
#['initializer]
fn constructor(
number: Field,
owner: AztecAddress,
Expand All @@ -30,6 +31,7 @@ contract Vanilla {
}

#[private]
#['private]
fn setNumber(
number: Field,
owner: AztecAddress,
Expand Down
3 changes: 2 additions & 1 deletion boxes/init/src/main.nr
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use dep::aztec::macros::aztec;
#[aztec]
contract Main {
#[private]
#[initializer]
#['private]
#['initializer]
fn constructor() { }
}
1 change: 1 addition & 0 deletions noir-projects/aztec-nr/aztec/src/macros/dispatch/mod.nr
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ pub comptime fn generate_public_dispatch(m: Module) -> Quoted {
// functions having this attribute. However, the public MACRO will
// handle the public_dispatch function specially and do nothing.
#[public]
#['public]
pub unconstrained fn public_dispatch(selector: Field) {
$dispatch
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ contract AppSubscription {
global SUBSCRIPTION_TXS = 5;

#[private]
#['private]
fn entrypoint(payload: DAppPayload, user_address: AztecAddress) {
// Default msg_sender for entrypoints is now Fr.max_value rather than 0 addr (see #7190 & #7404)
assert(context.msg_sender().to_field() == MAX_FIELD_VALUE);
Expand Down Expand Up @@ -64,7 +65,8 @@ contract AppSubscription {
}

#[public]
#[initializer]
#['public]
#['initializer]
fn constructor(
target_address: AztecAddress,
subscription_recipient_address: AztecAddress,
Expand All @@ -80,6 +82,7 @@ contract AppSubscription {
}

#[private]
#['private]
fn subscribe(subscriber: AztecAddress, nonce: Field, expiry_block_number: Field, tx_count: Field) {
assert(tx_count as u64 <= SUBSCRIPTION_TXS as u64);

Expand Down
18 changes: 13 additions & 5 deletions noir-projects/noir-contracts/contracts/auth_contract/src/main.nr
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,16 @@ contract Auth {
}

#[public]
#[initializer]
#['public]
#['initializer]
fn constructor(admin: AztecAddress) {
assert(!admin.is_zero(), "invalid admin");
storage.admin.initialize(admin);
}

// docs:start:shared_mutable_schedule
#[public]
#['public]
fn set_authorized(authorized: AztecAddress) {
assert_eq(storage.admin.read(), context.msg_sender(), "caller is not admin");
storage.authorized.schedule_value_change(authorized);
Expand All @@ -40,7 +42,8 @@ contract Auth {

// docs:start:public_getter
#[public]
#[view]
#['public]
#['view]
fn get_authorized() -> AztecAddress {
// docs:start:shared_mutable_get_current_public
storage.authorized.get_current_value_in_public()
Expand All @@ -49,7 +52,8 @@ contract Auth {
// docs:end:public_getter

#[public]
#[view]
#['public]
#['view]
fn get_scheduled_authorized() -> AztecAddress {
// docs:start:shared_mutable_get_scheduled_public
let (scheduled_value, _block_of_change): (AztecAddress, u32) = storage.authorized.get_scheduled_value_in_public();
Expand All @@ -58,17 +62,20 @@ contract Auth {
}

#[public]
#[view]
#['public]
#['view]
fn get_authorized_delay() -> pub u32 {
storage.authorized.get_current_delay_in_public()
}

#[public]
#['public]
fn set_authorized_delay(new_delay: u32) {
storage.authorized.schedule_delay_change(new_delay);
}

#[private]
#['private]
fn do_private_authorized_thing() {
// Reading a value from authorized in private automatically adds an extra validity condition: the base rollup
// circuit will reject this tx if included in a block past the block horizon, which is as far as the circuit can
Expand All @@ -80,7 +87,8 @@ contract Auth {
}

#[private]
#[view]
#['private]
#['view]
fn get_authorized_in_private() -> AztecAddress {
storage.authorized.get_current_value_in_private()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ contract AuthRegistry {
* @param authorize True if the caller is authorized to perform the message hash, false otherwise
*/
#[public]
#['public]
fn set_authorized(message_hash: Field, authorize: bool) {
storage.approved_actions.at(context.msg_sender()).at(message_hash).write(authorize);
}
Expand All @@ -34,6 +35,7 @@ contract AuthRegistry {
* @param reject True if all actions should be rejected, false otherwise
*/
#[public]
#['public]
fn set_reject_all(reject: bool) {
storage.reject_all.at(context.msg_sender()).write(reject);
}
Expand All @@ -49,6 +51,7 @@ contract AuthRegistry {
* @return `IS_VALID_SELECTOR` if the action was consumed, revert otherwise
*/
#[public]
#['public]
fn consume(on_behalf_of: AztecAddress, inner_hash: Field) -> Field {
assert_eq(false, storage.reject_all.at(on_behalf_of).read(), "rejecting all");

Expand Down Expand Up @@ -79,6 +82,7 @@ contract AuthRegistry {
* @param authorize True if the message hash should be authorized, false otherwise
*/
#[private]
#['private]
fn set_authorized_private(approver: AztecAddress, message_hash: Field, authorize: bool) {
assert_current_call_valid_authwit(&mut context, approver);
AuthRegistry::at(context.this_address())._set_authorized(approver, message_hash, authorize).enqueue(&mut context);
Expand All @@ -93,7 +97,8 @@ contract AuthRegistry {
* @param authorize True if the caller is authorized to perform the message hash, false otherwise
*/
#[public]
#[internal]
#['public]
#['internal]
fn _set_authorized(approver: AztecAddress, message_hash: Field, authorize: bool) {
storage.approved_actions.at(approver).at(message_hash).write(authorize);
}
Expand All @@ -105,7 +110,8 @@ contract AuthRegistry {
* @return True if all actions are rejected, false otherwise
*/
#[public]
#[view]
#['public]
#['view]
fn is_reject_all(on_behalf_of: AztecAddress) -> bool {
storage.reject_all.at(on_behalf_of).read()
}
Expand All @@ -118,7 +124,8 @@ contract AuthRegistry {
* @return True if the caller is authorized to perform the action, false otherwise
*/
#[public]
#[view]
#['public]
#['view]
fn is_consumable(on_behalf_of: AztecAddress, message_hash: Field) -> bool {
storage.approved_actions.at(on_behalf_of).at(message_hash).read()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ contract AuthWitTest {
use dep::authwit::auth::{assert_inner_hash_valid_authwit, assert_inner_hash_valid_authwit_public};

#[private]
#['private]
fn consume(on_behalf_of: AztecAddress, inner_hash: Field) {
assert_inner_hash_valid_authwit(&mut context, on_behalf_of, inner_hash);
}

#[public]
#['public]
fn consume_public(on_behalf_of: AztecAddress, inner_hash: Field) {
assert_inner_hash_valid_authwit_public(&mut context, on_behalf_of, inner_hash);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ contract AvmInitializerTest {
* Storage
************************************************************************/
#[public]
#[initializer]
#['public]
#['initializer]
fn constructor() {
storage.immutable.initialize(42);
}

#[public]
#['public]
fn read_storage_immutable() -> pub Field {
storage.immutable.read()
}
Expand Down
Loading

0 comments on commit 5a3a8cc

Please sign in to comment.