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: Aztec prelude #4496

Closed
wants to merge 48 commits into from
Closed
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
bebf5b5
add initial work for inserting an aztec prelude and remove imports fr…
vezenovm Feb 7, 2024
db50e56
merge conflicts w/ master
vezenovm Feb 7, 2024
e67eb78
delete more aztec deps in the contracts
vezenovm Feb 7, 2024
537c3d2
update methods in e2e tests
vezenovm Feb 8, 2024
4c3d679
fix macro imports and merge conflicts w/ master
vezenovm Feb 8, 2024
54d0be2
remove remaining imports from ecdsa_account_contract
vezenovm Feb 8, 2024
ceaba2c
fix e2e test and move prelude source to bottom of file
vezenovm Feb 8, 2024
188ffe7
update benchmarks e2e
vezenovm Feb 8, 2024
a117ec3
stateful test create_new_note
vezenovm Feb 8, 2024
4012615
format
vezenovm Feb 8, 2024
d91f69c
run tests on single thread
vezenovm Feb 8, 2024
1dbf3d5
missing maxWorkers
vezenovm Feb 8, 2024
8aa6ad8
fix stateful constructor and run tests on many threads
vezenovm Feb 8, 2024
fc01877
Merge branch 'master' into mv/aztec-prelude
vezenovm Feb 8, 2024
f03ca68
fix get public key test
vezenovm Feb 8, 2024
d584abc
Merge branch 'master' into mv/aztec-prelude
vezenovm Feb 8, 2024
f834222
update e2e_deploy_contract test after master merge
vezenovm Feb 8, 2024
65bb865
merge conflcits w/ master
vezenovm Feb 15, 2024
423e23c
Merge branch 'master' into mv/aztec-prelude
vezenovm Feb 15, 2024
87bdde6
all contracts working with new prelde
vezenovm Feb 15, 2024
159980d
fix e2e tests
vezenovm Feb 15, 2024
872d70e
cargo fmt
vezenovm Feb 15, 2024
8f96895
remove changes to slow_map.nr
vezenovm Feb 15, 2024
33a2d9c
cleanup has_aztec_dep func
vezenovm Feb 15, 2024
d795c27
use prelude.nr inside of aztec-nr
vezenovm Feb 15, 2024
9d4844f
cargo fmt
vezenovm Feb 15, 2024
f8467e7
rename process_crate_prelude to fetch_crate_prelude
vezenovm Feb 15, 2024
84b2c24
add note imports to prelude
vezenovm Feb 15, 2024
30b8ef7
Merge branch 'master' into mv/aztec-prelude
vezenovm Feb 15, 2024
187b17e
remove more imports due to prelude
vezenovm Feb 16, 2024
701519b
remove PrivateContext import
vezenovm Feb 16, 2024
cf6d1e5
resolve master merge conflicts
vezenovm Feb 16, 2024
9b919f6
dont edit test_contract autogen file
vezenovm Feb 16, 2024
ed10939
Merge branch 'master' into mv/aztec-prelude
vezenovm Feb 19, 2024
3ccd7dc
remove unused method
vezenovm Feb 19, 2024
82d889b
merge conflcits w/ master
vezenovm Feb 19, 2024
359f259
cargo fmt
vezenovm Feb 19, 2024
a160e92
Merge branch 'master' into mv/aztec-prelude
vezenovm Feb 19, 2024
2e3bd3b
Merge branch 'master' into mv/aztec-prelude
vezenovm Feb 19, 2024
b3cefdf
Merge branch 'master' into mv/aztec-prelude
benesjan Feb 29, 2024
266c2b9
fixes after merge
benesjan Feb 29, 2024
4b80987
import cleanup
benesjan Feb 29, 2024
a687f68
Merge branch 'master' into mv/aztec-prelude
benesjan Feb 29, 2024
7328b80
Merge branch 'master' into mv/aztec-prelude
TomAFrench Mar 4, 2024
5e30067
chore: undo unwanted formatting changes
TomAFrench Mar 4, 2024
1269ed7
chore: prevent formatter from running
TomAFrench Mar 4, 2024
35a1472
chore: revert more formatting changes
TomAFrench Mar 4, 2024
3a0796c
chore: one more
TomAFrench Mar 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions boxes/token/src/contracts/src/main.nr
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,9 @@ contract Token {
use dep::compressed_string::FieldCompressedString;

use dep::aztec::{
note::{
note_getter_options::NoteGetterOptions,
note_header::NoteHeader,
utils as note_utils,
},
note::utils as note_utils,
hash::{compute_secret_hash},
state_vars::{map::Map, public_state::PublicState, stable_public_state::StablePublicState, set::Set},
protocol_types::{
abis::function_selector::FunctionSelector,
address::AztecAddress
}
protocol_types::abis::function_selector::FunctionSelector,
};

// docs:start:import_authwit
Expand Down
14 changes: 2 additions & 12 deletions boxes/token/src/contracts/src/types/balances_map.nr
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,10 @@ use dep::std::option::Option;
use dep::safe_math::SafeU120;
use dep::aztec::{
context::Context,
protocol_types::{
address::AztecAddress,
constants::MAX_READ_REQUESTS_PER_CALL,
},
state_vars::{
set::Set,
map::Map
},
protocol_types::constants::MAX_READ_REQUESTS_PER_CALL,
note::{
note_getter::view_notes,
note_getter_options::{NoteGetterOptions, SortOrder},
note_viewer_options::NoteViewerOptions,
note_header::NoteHeader,
note_interface::NoteInterface,
note_getter_options::SortOrder,
}
};
use crate::types::token_note::{TokenNote, OwnedNote};
Expand Down
14 changes: 2 additions & 12 deletions boxes/token/src/contracts/src/types/token_note.nr
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
use dep::aztec::{
protocol_types::{
address::AztecAddress,
constants::MAX_READ_REQUESTS_PER_CALL
},
note::{
note_header::NoteHeader,
note_interface::NoteInterface,
utils::compute_note_hash_for_consumption,
},
context::PrivateContext,
state_vars::set::Set,
log::emit_encrypted_log,
protocol_types::constants::MAX_READ_REQUESTS_PER_CALL,
note::utils::compute_note_hash_for_consumption,
hash::pedersen_hash,
};
use dep::aztec::oracle::{
Expand Down
7 changes: 1 addition & 6 deletions boxes/token/src/contracts/src/types/transparent_note.nr
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
// docs:start:token_types_all
use dep::aztec::{
note::{
note_header::NoteHeader,
note_interface::NoteInterface,
utils::compute_note_hash_for_consumption,
},
note::utils::compute_note_hash_for_consumption,
hash::{compute_secret_hash, pedersen_hash},
context::PrivateContext,
};

global TRANSPARENT_NOTE_LEN: Field = 2;
Expand Down
1 change: 1 addition & 0 deletions noir-projects/aztec-nr/aztec/src/lib.nr
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ mod log;
mod messaging;
mod note;
mod oracle;
mod prelude;
mod state_vars;
use dep::protocol_types;
27 changes: 27 additions & 0 deletions noir-projects/aztec-nr/aztec/src/prelude.nr
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
use dep::protocol_types::{
address::{
AztecAddress,
EthAddress,
},
};
use crate::{
state_vars::{
map::Map,
public_state::PublicState,
singleton::Singleton,
immutable_singleton::ImmutableSingleton,
set::Set,
stable_public_state::StablePublicState,
},
log::{
emit_unencrypted_log,
emit_encrypted_log,
},
context::PrivateContext,
note::{
note_header::NoteHeader,
note_interface::NoteInterface,
note_getter_options::NoteGetterOptions,
benesjan marked this conversation as resolved.
Show resolved Hide resolved
note_viewer_options::NoteViewerOptions,
}
};
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
//

contract AvmTest {
// Libs
use dep::aztec::protocol_types::address::{AztecAddress, EthAddress};

// avm lib
use dep::aztec::avm::context::AvmContext;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ contract Benchmarking {
use dep::value_note::{utils::{increment, decrement}, value_note::{VALUE_NOTE_LEN, ValueNote}};

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}
protocol_types::abis::function_selector::FunctionSelector,
context::Context,
note::utils as note_utils,
};

struct Storage {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@ use dep::aztec::{
MAX_READ_REQUESTS_PER_CALL,
},
},
context::{PrivateContext, PublicContext, Context},
context::{PublicContext, Context},
note::{
note_getter_options::NoteGetterOptions,
note_viewer_options::NoteViewerOptions,
note_getter::view_notes,
},
state_vars::set::Set,
};
use dep::std;
use dep::std::{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use dep::aztec::protocol_types::{
address::AztecAddress,
traits::{Serialize, Deserialize},
};
use crate::cards::Card;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ mod cards;
mod game;

contract CardGame {
use dep::aztec::protocol_types::{abis::function_selector::FunctionSelector, address::AztecAddress, constants::MAX_NOTES_PER_PAGE};
use dep::aztec::{context::Context, hash::pedersen_hash, state_vars::{map::Map, public_state::PublicState}};
use dep::aztec::protocol_types::{abis::function_selector::FunctionSelector, constants::MAX_NOTES_PER_PAGE};
use dep::aztec::{context::Context, hash::pedersen_hash};

use dep::std::option::Option;
use dep::value_note::{balance_utils, value_note::{ValueNote, VALUE_NOTE_LEN}};

use dep::aztec::note::{note_header::NoteHeader, utils as note_utils};
use dep::aztec::note::utils as note_utils;

use crate::cards::{PACK_CARDS, Deck, Card, get_pack_cards, compute_deck_strength};
use crate::game::{NUMBER_OF_PLAYERS, NUMBER_OF_CARDS_DECK, PLAYABLE_CARDS, PlayerEntry, Game, GAME_SERIALIZED_LEN};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ contract Child {
use dep::std::option::Option;

use dep::aztec::{
context::{PrivateContext, PublicContext, Context}, log::emit_unencrypted_log,
state_vars::{public_state::PublicState, set::Set},
protocol_types::{abis::{function_selector::FunctionSelector, call_context::CallContext}, address::AztecAddress},
note::{note_getter_options::NoteGetterOptions}
context::{PublicContext, Context},
protocol_types::abis::{function_selector::FunctionSelector, call_context::CallContext},
};
use dep::value_note::value_note::{ValueNote, VALUE_NOTE_LEN};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
contract Counter {
// docs:start:imports
use dep::aztec::protocol_types::address::AztecAddress;
use dep::aztec::{
context::{PrivateContext, Context},
note::{
note_header::NoteHeader,
utils as note_utils,
},
state_vars::map::Map,
context::Context,
note::utils as note_utils,
};
use dep::value_note::{
balance_utils,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,13 @@ contract DocsExample {
// how to import dependencies defined in your workspace
use dep::aztec::protocol_types::{
abis::function_selector::FunctionSelector,
address::AztecAddress,
};
use dep::aztec::{
note::{
note_header::NoteHeader,
note_getter_options::{NoteGetterOptions, Comparator},
note_viewer_options::{NoteViewerOptions},
note_getter_options::Comparator,
utils as note_utils,
},
context::{PrivateContext, PublicContext, Context},
state_vars::{map::Map, public_state::PublicState,singleton::Singleton, immutable_singleton::ImmutableSingleton, set::Set, stable_public_state::StablePublicState},
context::{PublicContext, Context},
};
// how to import methods from other files/folders within your workspace
use crate::options::create_account_card_getter_options;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use dep::aztec::{
note::{note_header::NoteHeader, note_interface::NoteInterface, utils::compute_note_hash_for_consumption},
note::utils::compute_note_hash_for_consumption,
oracle::{nullifier_key::get_nullifier_secret_key, get_public_key::get_public_key},
log::emit_encrypted_log, hash::pedersen_hash, context::PrivateContext,
protocol_types::{address::AztecAddress, traits::Empty}
hash::pedersen_hash,
protocol_types::traits::Empty,
};

// Shows how to create a custom note
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
// docs:start:easy_private_token_contract
contract EasyPrivateToken {
use dep::aztec::protocol_types::address::AztecAddress;
use dep::std::option::Option;
use dep::aztec::{
context::{PrivateContext, PublicContext, Context},
note::{
note_header::NoteHeader,
utils as note_utils,
},
state_vars::map::Map,
context::{PublicContext, Context},
note::utils as note_utils,
};
use dep::std::option::Option;
use dep::value_note::{
balance_utils,
value_note::{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
contract EasyPrivateVoting {
// docs:start:imports
use dep::aztec::{
protocol_types::{abis::function_selector::FunctionSelector, address::AztecAddress},
context::{PrivateContext, Context}, state_vars::{map::Map, public_state::PublicState}
protocol_types::abis::function_selector::FunctionSelector,
context::Context,
};
// docs:end:imports
// docs:start:storage_struct
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use dep::aztec::protocol_types::address::AztecAddress;
use dep::aztec::{
note::{note_header::NoteHeader, note_interface::NoteInterface, utils::compute_note_hash_for_consumption},
note::utils::compute_note_hash_for_consumption,
oracle::{nullifier_key::get_nullifier_secret_key, get_public_key::get_public_key},
log::emit_encrypted_log, hash::pedersen_hash, context::PrivateContext
hash::pedersen_hash,
};

global ECDSA_PUBLIC_KEY_NOTE_LEN: Field = 5;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ mod ecdsa_public_key_note;
// Account contract that uses ECDSA signatures for authentication on the same curve as Ethereum.
// The signing key is stored in an immutable private note and should be different from the signing key.
contract EcdsaAccount {
use dep::aztec::protocol_types::{abis::call_context::CallContext, address::AztecAddress};
use dep::aztec::protocol_types::abis::call_context::CallContext;
use dep::std;
use dep::std::option::Option;
use dep::aztec::{
context::{PrivateContext, PublicContext, Context},
note::{note_header::NoteHeader, utils as note_utils}, oracle::get_public_key::get_public_key,
state_vars::immutable_singleton::ImmutableSingleton
context::{PublicContext, Context},
note::utils as note_utils, oracle::get_public_key::get_public_key,
};
use dep::authwit::{
entrypoint::{app::AppPayload, fee::FeePayload}, account::AccountActions,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
contract Escrow {
use dep::std::option::Option;

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

use dep::aztec::{
context::{PrivateContext, PublicContext, Context},
note::{note_getter_options::NoteGetterOptions, note_header::NoteHeader, utils as note_utils},
oracle::get_public_key::get_public_key, state_vars::set::Set
context::{PublicContext, Context},
note::utils as note_utils,
oracle::get_public_key::get_public_key,
};

use dep::address_note::address_note::{AddressNote, ADDRESS_NOTE_LEN};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ mod test_contract_interface;
// Contract that uses the autogenerated interface of the Test contract for calling its functions.
// Used for testing calling into other contracts via autogenerated interfaces.
contract ImportTest {
use dep::aztec::protocol_types::address::AztecAddress;
use crate::test_contract_interface::{
TestPrivateContextInterface, TestPublicContextInterface, AStructTestCodeGenStruct,
ADeepStructTestCodeGenStruct, ANoteADeepStructTestCodeGenStruct,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// A demonstration of inclusion and non-inclusion proofs.
contract InclusionProofs {
use dep::aztec::protocol_types::{
abis::function_selector::FunctionSelector, address::{AztecAddress, EthAddress},
abis::function_selector::FunctionSelector,
grumpkin_point::GrumpkinPoint, contract_class::ContractClassId
};
use dep::aztec::{
state_vars::{map::Map, set::Set, public_state::PublicState}, context::Context,
context::Context,
note::{
note_getter_options::NoteGetterOptions, note_getter_options::NoteStatus,
note_header::NoteHeader, utils as note_utils
note_getter_options::NoteStatus,
utils as note_utils,
}
};
// docs:start:imports
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use dep::aztec::protocol_types::{
address::AztecAddress,
traits::{Deserialize, Serialize}
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
use dep::aztec::context::{
PrivateContext,
PublicContext
};

use crate::asset::Asset;
use dep::aztec::protocol_types::{
abis::function_selector::FunctionSelector,
address::AztecAddress,
constants::RETURN_VALUES_LENGTH,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,11 @@ mod interfaces;
contract Lending {
use dep::aztec::protocol_types::{
abis::function_selector::FunctionSelector,
address::AztecAddress,
};
use dep::safe_math::SafeU120;
use dep::std::option::Option;
use dep::aztec::{
context::{PrivateContext, PublicContext, Context},
state_vars::{
map::Map,
public_state::PublicState,
}
};
use crate::asset::Asset;
use crate::interest_math::compute_multiplier;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ contract PendingCommitments {
use dep::std::option::Option;
use dep::value_note::{balance_utils, filter::filter_notes_min_sum, value_note::{VALUE_NOTE_LEN, ValueNote}};
use dep::aztec::{
context::{PrivateContext, PublicContext, Context}, log::emit_encrypted_log,
note::{note_getter::NoteGetterOptions, note_header::NoteHeader, utils as note_utils},
state_vars::{map::Map, set::Set}
context::{PublicContext, Context},
note::utils as note_utils,
};
use dep::aztec::protocol_types::{address::AztecAddress, abis::function_selector::FunctionSelector};
use dep::aztec::protocol_types::abis::function_selector::FunctionSelector;

struct Storage {
balances: Map<AztecAddress, Set<ValueNote>>,
Expand Down
Loading
Loading