Skip to content

Commit

Permalink
feat: reexport protocol_types from aztec-nr (AztecProtocol#3926)
Browse files Browse the repository at this point in the history
This PR rexports `protocol_types` from `aztec-nr` so that users of
`aztec-nr` don't need to have a direct dependency on `protocol_types`

Closes AztecProtocol#3590
  • Loading branch information
TomAFrench authored Jan 12, 2024
1 parent d925d85 commit 1e9ba84
Show file tree
Hide file tree
Showing 110 changed files with 125 additions and 147 deletions.
1 change: 0 additions & 1 deletion boxes/blank-react/src/contracts/Nargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ type = "contract"

[dependencies]
aztec = { path = "../../../../yarn-project/aztec-nr/aztec" }
protocol_types = { path = "../../../../yarn-project/noir-protocol-circuits/src/crates/types" }
4 changes: 2 additions & 2 deletions boxes/blank-react/src/contracts/src/main.nr
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ contract Blank {
oracle::{
get_public_key::get_public_key,
},
protocol_types::address::AztecAddress
};
use dep::protocol_types::address::AztecAddress;


#[aztec(private)]
fn constructor() {}

Expand Down
1 change: 0 additions & 1 deletion boxes/blank/src/contracts/Nargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ type = "contract"

[dependencies]
aztec = { path = "../../../../yarn-project/aztec-nr/aztec" }
protocol_types = { path = "../../../../yarn-project/noir-protocol-circuits/src/crates/types" }
6 changes: 3 additions & 3 deletions boxes/blank/src/contracts/src/main.nr
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ contract Blank {
abi,
oracle::{
get_public_key::get_public_key,
}
},
protocol_types::address::AztecAddress
};
use dep::protocol_types::address::AztecAddress;


#[aztec(private)]
fn constructor() {}

Expand Down
1 change: 0 additions & 1 deletion boxes/token/src/contracts/Nargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ value_note = { path = "../../../../yarn-project/aztec-nr/value-note"}
safe_math = { path = "../../../../yarn-project/aztec-nr/safe-math" }
authwit = { path = "../../../../yarn-project/aztec-nr/authwit" }
aztec = { path = "../../../../yarn-project/aztec-nr/aztec" }
protocol_types = { path = "../../../../yarn-project/noir-protocol-circuits/src/crates/types" }
10 changes: 5 additions & 5 deletions boxes/token/src/contracts/src/main.nr
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ contract Token {
bool_serialization::{BoolSerializationMethods, BOOL_SERIALIZED_LEN},
address_serialization::{AddressSerializationMethods, AZTEC_ADDRESS_SERIALIZED_LEN},
},
protocol_types::{
abis::function_selector::FunctionSelector,
address::AztecAddress,
}
};
use dep::protocol_types::{
abis::function_selector::FunctionSelector,
address::AztecAddress,
};


// docs:start:import_authwit
use dep::authwit::{
auth::{
Expand Down
8 changes: 4 additions & 4 deletions boxes/token/src/contracts/src/types/balance_set.nr
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use dep::std::option::Option;
use dep::safe_math::SafeU120;
use dep::protocol_types::{
constants::MAX_READ_REQUESTS_PER_CALL,
address::AztecAddress,
};
use dep::aztec::{
context::Context,
state_vars::set::Set,
};
use dep::aztec::protocol_types::{
constants::MAX_READ_REQUESTS_PER_CALL,
address::AztecAddress,
};
use dep::aztec::note::{
note_getter::view_notes,
note_getter_options::{NoteGetterOptions, SortOrder},
Expand Down
2 changes: 1 addition & 1 deletion boxes/token/src/contracts/src/types/balances_map.nr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use dep::aztec::context::{PrivateContext, PublicContext, Context};
use dep::std::option::Option;
use crate::types::balance_set::BalanceSet;
use dep::aztec::hash::pedersen_hash;
use dep::protocol_types::address::AztecAddress;
use dep::aztec::protocol_types::address::AztecAddress;

use crate::types::token_note::{TokenNote, TOKEN_NOTE_LEN, TokenNoteMethods};
use dep::aztec::state_vars::{map::Map, set::Set};
Expand Down
12 changes: 6 additions & 6 deletions boxes/token/src/contracts/src/types/token_note.nr
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use dep::protocol_types::{
address::AztecAddress,
constants::{
MAX_READ_REQUESTS_PER_CALL
},
};
use dep::aztec::{
protocol_types::{
address::AztecAddress,
constants::{
MAX_READ_REQUESTS_PER_CALL
},
}
note::{
note_header::NoteHeader,
note_interface::NoteInterface,
Expand Down
1 change: 0 additions & 1 deletion docs/docs/dev_docs/contracts/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ type = "contract"
[dependencies]
# Framework import
aztec = { git="https://github.com/AztecProtocol/aztec-packages/", tag="#include_aztec_version", directory="yarn-project/aztec-nr/aztec" }
protocol_types = { git="https://github.com/AztecProtocol/aztec-packages/", tag="#include_aztec_version", directory="yarn-project/noir-protocol-circuits/src/crates/types"}

# Utility dependencies
value_note = { git="https://github.com/AztecProtocol/aztec-packages/", tag="#include_aztec_version", directory="yarn-project/aztec-nr/value-note"}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ compiler_version = ">=0.18.0"
aztec = { git="https://github.com/AztecProtocol/aztec-packages/", tag="#include_aztec_version", directory="yarn-project/aztec-nr/aztec" }
value_note = { git="https://github.com/AztecProtocol/aztec-packages/", tag="#include_aztec_version", directory="yarn-project/aztec-nr/value-note"}
easy_private_state = { git="https://github.com/AztecProtocol/aztec-packages/", tag="#include_aztec_version", directory="yarn-project/aztec-nr/easy-private-state"}
protocol_types = { git="https://github.com/AztecProtocol/aztec-packages/", tag="#include_aztec_version", directory="yarn-project/noir-protocol-circuits/src/crates/types"}
```

## Define the functions
Expand Down
1 change: 0 additions & 1 deletion docs/docs/dev_docs/tutorials/token_portal/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ type = "contract"
[dependencies]
aztec = { git="https://github.com/AztecProtocol/aztec-packages/", tag="#include_aztec_version", directory="yarn-project/aztec-nr/aztec" }
token_portal_content_hash_lib = { git="https://github.com/AztecProtocol/aztec-packages/", tag="aztec-packages-v0.16.9", directory="yarn-project/noir-contracts/contracts/token_portal_content_hash_lib" }
protocol_types = { git="https://github.com/AztecProtocol/aztec-packages/", tag="#include_aztec_version", directory="yarn-project/noir-protocol-circuits/src/crates/types"}
```

We will also be writing some helper functions that should exist elsewhere so we don't overcomplicated our contract. In `src` create two more files - one called `util.nr` and one called `token_interface` - so your dir structure should now look like this:
Expand Down
1 change: 0 additions & 1 deletion docs/docs/dev_docs/tutorials/uniswap/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ Inside `uniswap/Nargo.toml` paste this in `[dependencies]`:
[dependencies]
aztec = { git="https://github.com/AztecProtocol/aztec-packages/", tag="#include_aztec_version", directory="yarn-project/aztec-nr/aztec" }
authwit = { git="https://github.com/AztecProtocol/aztec-packages/", tag="#include_aztec_version", directory="yarn-project/aztec-nr/authwit"}
protocol_types = { git="https://github.com/AztecProtocol/aztec-packages/", tag="#include_aztec_version", directory="yarn-project/noir-protocol-circuits/src/crates/types"}
```

## L2 contracts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ Then, open the `contracts/token/Nargo.toml` configuration file, and add the `azt
aztec = { git="https://github.com/AztecProtocol/aztec-packages/", tag="#include_aztec_version", directory="yarn-project/aztec-nr/aztec" }
authwit = { git="https://github.com/AztecProtocol/aztec-packages/", tag="#include_aztec_version", directory="yarn-project/aztec-nr/authwit"}
safe_math = { git="https://github.com/AztecProtocol/aztec-packages/", tag="#include_aztec_version", directory="yarn-project/aztec-nr/safe-math"}
protocol_types = { git="https://github.com/AztecProtocol/aztec-packages/", tag="#include_aztec_version", directory="yarn-project/noir-protocol-circuits/src/crates/types"}
```

Last, copy-paste the code from the `Token` contract into `contracts/token/main.nr`:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ compiler_version = ">=0.18.0"

[dependencies]
aztec = { git="https://github.com/AztecProtocol/aztec-packages", tag="#include_aztec_version", directory="yarn-project/aztec-nr/aztec" }
protocol_types = { git="https://github.com/AztecProtocol/aztec-packages/", tag="#include_aztec_version", directory="yarn-project/noir-protocol-circuits/src/crates/types"}
```

## Initiate the contract and define imports
Expand Down
1 change: 0 additions & 1 deletion docs/docs/dev_docs/tutorials/writing_token_contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ type = "contract"
aztec = { git="https://github.com/AztecProtocol/aztec-packages/", tag="#include_aztec_version", directory="yarn-project/aztec-nr/aztec" }
safe_math = { git="https://github.com/AztecProtocol/aztec-packages/", tag="#include_aztec_version", directory="yarn-project/aztec-nr/safe-math"}
authwit={ git="https://github.com/AztecProtocol/aztec-packages/", tag="#include_aztec_version", directory="yarn-project/aztec-nr/authwit"}
protocol_types = { git="https://github.com/AztecProtocol/aztec-packages/", tag="#include_aztec_version", directory="yarn-project/noir-protocol-circuits/src/crates/types"}
```

## Contract Interface
Expand Down
10 changes: 10 additions & 0 deletions docs/docs/misc/migration_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ keywords: [sandbox, cli, aztec, notes, migration, updating, upgrading]

Aztec is in full-speed development. Literally every version breaks compatibility with the previous ones. This page attempts to target errors and difficulties you might encounter when upgrading, and how to resolve them.

## 0.18.0

### [Aztec.nr] Remove `protocol_types` from Nargo.toml

The `protocol_types` package is now being reexported from `aztec`. It can be accessed through `dep::aztec::protocol_types`.

```toml
aztec = { git="https://github.com/AztecProtocol/aztec-packages/", tag="#include_aztec_version", directory="yarn-project/aztec-nr/aztec" }
```

## 0.17.0

### [js] New `@aztec/accounts` package
Expand Down
6 changes: 2 additions & 4 deletions noir/aztec_macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -483,12 +483,11 @@ const SIGNATURE_PLACEHOLDER: &str = "SIGNATURE_PLACEHOLDER";

/// Generates the impl for an event selector
///
/// TODO(https://github.com/AztecProtocol/aztec-packages/issues/3590): Make this point to aztec-nr once the issue is fixed.
/// Inserts the following code:
/// ```noir
/// impl SomeStruct {
/// fn selector() -> FunctionSelector {
/// protocol_types::abis::function_selector::FunctionSelector::from_signature("SIGNATURE_PLACEHOLDER")
/// aztec::protocol_types::abis::function_selector::FunctionSelector::from_signature("SIGNATURE_PLACEHOLDER")
/// }
/// }
/// ```
Expand All @@ -499,9 +498,8 @@ const SIGNATURE_PLACEHOLDER: &str = "SIGNATURE_PLACEHOLDER";
fn generate_selector_impl(structure: &NoirStruct) -> TypeImpl {
let struct_type = make_type(UnresolvedTypeData::Named(path(structure.name.clone()), vec![]));

// TODO(https://github.com/AztecProtocol/aztec-packages/issues/3590): Make this point to aztec-nr once the issue is fixed.
let selector_path =
chained_path!("protocol_types", "abis", "function_selector", "FunctionSelector");
chained_path!("aztec", "protocol_types", "abis", "function_selector", "FunctionSelector");
let mut from_signature_path = selector_path.clone();
from_signature_path.segments.push(ident("from_signature"));

Expand Down
2 changes: 1 addition & 1 deletion noir/tooling/nargo_fmt/tests/expected/contract.nr
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
// Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
contract Benchmarking {
use dep::protocol_types::abis::function_selector::FunctionSelector;
use dep::aztec::protocol_types::abis::function_selector::FunctionSelector;

use dep::value_note::{
utils::{increment, decrement},
Expand Down
2 changes: 1 addition & 1 deletion noir/tooling/nargo_fmt/tests/input/contract.nr
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
// Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
contract Benchmarking {
use dep::protocol_types::abis::function_selector::FunctionSelector;
use dep::aztec::protocol_types::abis::function_selector::FunctionSelector;

use dep::value_note::{
utils::{increment, decrement},
Expand Down
1 change: 0 additions & 1 deletion yarn-project/aztec-nr/address-note/Nargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ type = "lib"

[dependencies]
aztec = { path = "../aztec" }
protocol_types = { path = "../../noir-protocol-circuits/src/crates/types" }
2 changes: 1 addition & 1 deletion yarn-project/aztec-nr/address-note/src/address_note.nr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// docs:start:encrypted_import
use dep::aztec::log::emit_encrypted_log;
// docs:end:encrypted_import
use dep::protocol_types::address::AztecAddress;
use dep::aztec::{
protocol_types::address::AztecAddress,
note::{
note_header::NoteHeader,
note_interface::NoteInterface,
Expand Down
1 change: 0 additions & 1 deletion yarn-project/aztec-nr/authwit/Nargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ type = "lib"

[dependencies]
aztec = { path = "../aztec" }
protocol_types = { path = "../../noir-protocol-circuits/src/crates/types" }
10 changes: 7 additions & 3 deletions yarn-project/aztec-nr/authwit/src/auth.nr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use dep::protocol_types::{
use dep::aztec::protocol_types::{
abis::function_selector::FunctionSelector,
address::AztecAddress,
constants::{
Expand All @@ -22,7 +22,11 @@ global IS_VALID_PUBLIC_SELECTOR = 0xf3661153;

// docs:start:assert_valid_authwit
// Assert that `on_behalf_of` have authorized `message_hash` with a valid authentication witness
pub fn assert_valid_authwit(context: &mut PrivateContext, on_behalf_of: AztecAddress, message_hash: Field) {
pub fn assert_valid_authwit(
context: &mut PrivateContext,
on_behalf_of: AztecAddress,
message_hash: Field
) {
let is_valid_selector = FunctionSelector::from_field(IS_VALID_SELECTOR);
let result = context.call_private_function(on_behalf_of, is_valid_selector, [message_hash])[0];
context.push_new_nullifier(message_hash, 0);
Expand Down Expand Up @@ -82,4 +86,4 @@ pub fn compute_authwit_message_hash<N>(
GENERATOR_INDEX__SIGNATURE_PAYLOAD
)
}
// docs:end:compute_authwit_message_hash
// docs:end:compute_authwit_message_hash
2 changes: 1 addition & 1 deletion yarn-project/aztec-nr/authwit/src/entrypoint.nr
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use dep::aztec::abi;
use dep::aztec::types::vec::BoundedVec;
use dep::aztec::context::PrivateContext;
use dep::protocol_types::{
use dep::aztec::protocol_types::{
abis::{
call_stack_item::{
PrivateCallStackItem,
Expand Down
1 change: 1 addition & 0 deletions yarn-project/aztec-nr/aztec/src/lib.nr
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ mod oracle;
mod state_vars;
mod types;
mod utils;
use dep::protocol_types;
1 change: 0 additions & 1 deletion yarn-project/aztec-nr/compressed-string/Nargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ type = "lib"

[dependencies]
aztec = {path = "../aztec"}
protocol_types = {path = "../../noir-protocol-circuits/src/crates/types"}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use dep::aztec::types::type_serialization::TypeSerializationInterface;
use dep::protocol_types::utils::field::field_from_bytes;
use dep::aztec::protocol_types::utils::field::field_from_bytes;
use dep::std;

// A Fixedsize Compressed String.
Expand Down
1 change: 0 additions & 1 deletion yarn-project/aztec-nr/easy-private-state/Nargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ type = "lib"
[dependencies]
aztec = { path = "../aztec" }
value_note = { path = "../value-note" }
protocol_types = { path = "../../noir-protocol-circuits/src/crates/types" }
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use dep::protocol_types::address::AztecAddress;
use dep::aztec::{
protocol_types::address::AztecAddress,
context::Context,
note::note_getter_options::NoteGetterOptions,
state_vars::set::Set,
Expand Down
1 change: 0 additions & 1 deletion yarn-project/aztec-nr/value-note/Nargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ type = "lib"

[dependencies]
aztec = { path = "../aztec" }
protocol_types = { path = "../../noir-protocol-circuits/src/crates/types" }
2 changes: 1 addition & 1 deletion yarn-project/aztec-nr/value-note/src/filter.nr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use dep::std::option::Option;
use dep::protocol_types::constants::MAX_READ_REQUESTS_PER_CALL;
use dep::aztec::protocol_types::constants::MAX_READ_REQUESTS_PER_CALL;
use crate::value_note::ValueNote;

pub fn filter_notes_min_sum(
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/aztec-nr/value-note/src/utils.nr
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{
filter::filter_notes_min_sum,
value_note::{ValueNote, VALUE_NOTE_LEN},
};
use dep::protocol_types::address::AztecAddress;
use dep::aztec::protocol_types::address::AztecAddress;

// Sort the note values (0th field) in descending order.
// Pick the fewest notes whose sum is equal to or greater than `amount`.
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/aztec-nr/value-note/src/value_note.nr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use dep::protocol_types::address::AztecAddress;
use dep::aztec::{
protocol_types::address::AztecAddress,
note::{
note_header::NoteHeader,
note_interface::NoteInterface,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ type = "contract"
[dependencies]
aztec = { path = "../../../aztec-nr/aztec" }
value_note = { path = "../../../aztec-nr/value-note" }
protocol_types = { path = "../../../noir-protocol-circuits/src/crates/types" }
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,17 @@ contract Benchmarking {
};

use dep::aztec::{
protocol_types::{
abis::function_selector::FunctionSelector,
address::AztecAddress,
},
context::{Context},
note::{utils as note_utils, note_getter_options::NoteGetterOptions, note_header::NoteHeader},
log::emit_unencrypted_log,
state_vars::{map::Map, public_state::PublicState, set::Set},
types::type_serialization::field_serialization::{FieldSerializationMethods, FIELD_SERIALIZED_LEN},
};

use dep::protocol_types::{
abis::function_selector::FunctionSelector,
address::AztecAddress,
};

struct Storage {
notes: Map<AztecAddress, Set<ValueNote, VALUE_NOTE_LEN>>,
balances: Map<AztecAddress, PublicState<Field, FIELD_SERIALIZED_LEN>>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ type = "contract"
[dependencies]
aztec = { path = "../../../aztec-nr/aztec" }
value_note = { path = "../../../aztec-nr/value-note"}
protocol_types = { path = "../../../noir-protocol-circuits/src/crates/types" }

Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use dep::protocol_types::{
address::AztecAddress,
constants::{
MAX_NOTES_PER_PAGE,
MAX_READ_REQUESTS_PER_CALL,
},
};
use dep::aztec::{
protocol_types::{
address::AztecAddress,
constants::{
MAX_NOTES_PER_PAGE,
MAX_READ_REQUESTS_PER_CALL,
},
},
context::{PrivateContext, PublicContext, Context},
note::{
note_getter_options::NoteGetterOptions,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use dep::protocol_types::address::AztecAddress;
use dep::aztec::protocol_types::address::AztecAddress;
use dep::aztec::types::type_serialization::TypeSerializationInterface;
use crate::cards::Card;

Expand Down
Loading

0 comments on commit 1e9ba84

Please sign in to comment.