diff --git a/barretenberg/cpp/pil/vm2/constants_gen.pil b/barretenberg/cpp/pil/vm2/constants_gen.pil index 3a72f21190dd..315189ae763a 100644 --- a/barretenberg/cpp/pil/vm2/constants_gen.pil +++ b/barretenberg/cpp/pil/vm2/constants_gen.pil @@ -15,12 +15,10 @@ namespace constants; pol MAX_L2_TO_L1_MSGS_PER_TX = 8; pol MAX_PACKED_PUBLIC_BYTECODE_SIZE_IN_FIELDS = 3000; pol MAX_PROTOCOL_CONTRACTS = 11; - pol CANONICAL_AUTH_REGISTRY_ADDRESS = 1; - pol CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS = 2; - pol CONTRACT_CLASS_REGISTRY_CONTRACT_ADDRESS = 3; - pol MULTI_CALL_ENTRYPOINT_ADDRESS = 4; - pol FEE_JUICE_ADDRESS = 5; - pol PUBLIC_CHECKS_ADDRESS = 6; + pol FEE_JUICE_ADDRESS = 1; + pol CONTRACT_CLASS_REGISTRY_CONTRACT_ADDRESS = 2; + pol CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS = 3; + pol CANONICAL_AUTH_REGISTRY_ADDRESS = 4; pol FEE_JUICE_BALANCES_SLOT = 1; pol UPDATED_CLASS_IDS_SLOT = 1; pol FLAT_PUBLIC_LOGS_HEADER_LENGTH = 1; diff --git a/barretenberg/cpp/src/barretenberg/vm2/common/aztec_constants.hpp b/barretenberg/cpp/src/barretenberg/vm2/common/aztec_constants.hpp index 8d055ddc8f24..f5b48451ddfd 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/common/aztec_constants.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/common/aztec_constants.hpp @@ -21,12 +21,10 @@ #define GENESIS_ARCHIVE_ROOT "0x15684c8c3d2106918d3860f777e50555b7166adff47df13cc652e2e5a50bf5c7" #define MAX_PACKED_PUBLIC_BYTECODE_SIZE_IN_FIELDS 3000 #define MAX_PROTOCOL_CONTRACTS 11 -#define CANONICAL_AUTH_REGISTRY_ADDRESS 1 -#define CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS 2 -#define CONTRACT_CLASS_REGISTRY_CONTRACT_ADDRESS 3 -#define MULTI_CALL_ENTRYPOINT_ADDRESS 4 -#define FEE_JUICE_ADDRESS 5 -#define PUBLIC_CHECKS_ADDRESS 6 +#define FEE_JUICE_ADDRESS 1 +#define CONTRACT_CLASS_REGISTRY_CONTRACT_ADDRESS 2 +#define CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS 3 +#define CANONICAL_AUTH_REGISTRY_ADDRESS 4 #define FEE_JUICE_BALANCES_SLOT 1 #define UPDATED_CLASS_IDS_SLOT 1 #define FLAT_PUBLIC_LOGS_HEADER_LENGTH 1 diff --git a/barretenberg/cpp/src/barretenberg/vm2/generated/relations/contract_instance_retrieval_impl.hpp b/barretenberg/cpp/src/barretenberg/vm2/generated/relations/contract_instance_retrieval_impl.hpp index 9808eda1d573..db11b1eff7aa 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/generated/relations/contract_instance_retrieval_impl.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/generated/relations/contract_instance_retrieval_impl.hpp @@ -16,7 +16,7 @@ void contract_instance_retrievalImpl::accumulate(ContainerOverSubrelations& using C = ColumnAndShifts; const auto constants_MAX_PROTOCOL_CONTRACTS = FF(11); - const auto constants_CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS = FF(2); + const auto constants_CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS = FF(3); const auto constants_AVM_PUBLIC_INPUTS_PROTOCOL_CONTRACTS_ROW_IDX = FF(8); const auto contract_instance_retrieval_NOT_EXISTS = (FF(1) - in.get(C::contract_instance_retrieval_exists)); diff --git a/barretenberg/cpp/src/barretenberg/vm2/generated/relations/tx_impl.hpp b/barretenberg/cpp/src/barretenberg/vm2/generated/relations/tx_impl.hpp index 8188cb63e09f..4e769d93d0c8 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/generated/relations/tx_impl.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/generated/relations/tx_impl.hpp @@ -18,7 +18,7 @@ void txImpl::accumulate(ContainerOverSubrelations& evals, const auto constants_MAX_NOTE_HASHES_PER_TX = FF(64); const auto constants_MAX_NULLIFIERS_PER_TX = FF(64); const auto constants_MAX_L2_TO_L1_MSGS_PER_TX = FF(8); - const auto constants_FEE_JUICE_ADDRESS = FF(5); + const auto constants_FEE_JUICE_ADDRESS = FF(1); const auto constants_FEE_JUICE_BALANCES_SLOT = FF(1); const auto constants_AVM_TX_PHASE_VALUE_START = FF(0); const auto constants_AVM_TX_PHASE_VALUE_LAST = FF(11); diff --git a/barretenberg/cpp/src/barretenberg/vm2/generated/relations/update_check_impl.hpp b/barretenberg/cpp/src/barretenberg/vm2/generated/relations/update_check_impl.hpp index 01d64295ba51..27eeba910162 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/generated/relations/update_check_impl.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/generated/relations/update_check_impl.hpp @@ -15,7 +15,7 @@ void update_checkImpl::accumulate(ContainerOverSubrelations& evals, { using C = ColumnAndShifts; - const auto constants_CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS = FF(2); + const auto constants_CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS = FF(3); const auto constants_UPDATED_CLASS_IDS_SLOT = FF(1); const auto constants_AVM_PUBLIC_INPUTS_GLOBAL_VARIABLES_TIMESTAMP_ROW_IDX = FF(4); const auto constants_TIMESTAMP_OF_CHANGE_BIT_SIZE = FF(32); diff --git a/barretenberg/cpp/src/barretenberg/vm2/testing/minimal_tx.testdata.bin b/barretenberg/cpp/src/barretenberg/vm2/testing/minimal_tx.testdata.bin index 33d0ef793daa..3ad59384f729 100644 Binary files a/barretenberg/cpp/src/barretenberg/vm2/testing/minimal_tx.testdata.bin and b/barretenberg/cpp/src/barretenberg/vm2/testing/minimal_tx.testdata.bin differ diff --git a/boxes/boxes/vanilla/app/embedded-wallet.ts b/boxes/boxes/vanilla/app/embedded-wallet.ts index 7cf5d68f6a47..7b57c6dd6b9b 100644 --- a/boxes/boxes/vanilla/app/embedded-wallet.ts +++ b/boxes/boxes/vanilla/app/embedded-wallet.ts @@ -45,13 +45,19 @@ const LocalStorageKey = 'aztec-account'; export class EmbeddedWallet extends BaseWallet { connectedAccount: AztecAddress | null = null; protected accounts: Map = new Map(); + private multiCallEntrypointAddress?: AztecAddress; protected async getAccountFromAddress( address: AztecAddress ): Promise { let account: Account | undefined; if (address.equals(AztecAddress.ZERO)) { - account = new SignerlessAccount(); + if (!this.multiCallEntrypointAddress) { + throw new Error( + 'multiCallEntrypointAddress is required for signerless accounts' + ); + } + account = new SignerlessAccount(this.multiCallEntrypointAddress); } else { account = this.accounts.get(address?.toString() ?? ''); } diff --git a/docs/docs-developers/docs/foundational-topics/call_types.md b/docs/docs-developers/docs/foundational-topics/call_types.md index 74a4c44dba3e..e6925a9d7153 100644 --- a/docs/docs-developers/docs/foundational-topics/call_types.md +++ b/docs/docs-developers/docs/foundational-topics/call_types.md @@ -131,7 +131,7 @@ It is also possible to create public functions that can _only_ be invoked by pri A common pattern is to enqueue public calls to check some validity condition on public state, e.g. that a deadline has not expired or that some public value is set. -#include_code enqueueing /noir-projects/noir-contracts/contracts/protocol/public_checks_contract/src/utils.nr rust +#include_code enqueueing /noir-projects/noir-contracts/contracts/app/public_checks_contract/src/utils.nr rust Note that this reveals what public function is being called on what contract, and perhaps more importantly which contract enqueued the call during private execution. To prevent this you can enqueue a call to a public function using `self.enqueue_incognito` that behaves the same as `self.enqueue` but conceals the message sender. @@ -145,11 +145,11 @@ An example of how a deadline can be checked using the `PublicChecks` contract fo `privately_check_timestamp` and `privately_check_block_number` are helper functions around the call to the `PublicChecks` contract: -#include_code helper_public_checks_functions /noir-projects/noir-contracts/contracts/protocol/public_checks_contract/src/utils.nr rust +#include_code helper_public_checks_functions /noir-projects/noir-contracts/contracts/app/public_checks_contract/src/utils.nr rust This is what the implementation of the check timestamp functionality looks like: -#include_code check_timestamp /noir-projects/noir-contracts/contracts/protocol/public_checks_contract/src/main.nr rust +#include_code check_timestamp /noir-projects/noir-contracts/contracts/app/public_checks_contract/src/main.nr rust :::note The `PublicChecks` contract is not part of the [aztec-nr repository](https://github.com/AztecProtocol/aztec-nr). @@ -157,7 +157,7 @@ To add it as a dependency, point to the aztec-packages repository: ```toml [dependencies] -public_checks = { git = "https://github.com/AztecProtocol/aztec-packages/", tag = "#include_aztec_version", directory = "noir-projects/noir-contracts/contracts/protocol/public_checks_contract" } +public_checks = { git = "https://github.com/AztecProtocol/aztec-packages/", tag = "#include_aztec_version", directory = "noir-projects/noir-contracts/contracts/app/public_checks_contract" } ``` ::: diff --git a/docs/docs/networks.md b/docs/docs/networks.md index 30e249bf4801..6c2ec5e1407f 100644 --- a/docs/docs/networks.md +++ b/docs/docs/networks.md @@ -52,10 +52,10 @@ Not sure which network to use? Jump to our [Network Selection Guide](#network-se | Contract Name | Ignition (Mainnet) | Testnet | Devnet | |---------------|-------------------|---------|--------| -| **Instance Registry** | N/A | `0x0000000000000000000000000000000000000000000000000000000000000002` | `0x0000000000000000000000000000000000000000000000000000000000000002` | -| **Class Registry** | N/A | `0x0000000000000000000000000000000000000000000000000000000000000003` | `0x0000000000000000000000000000000000000000000000000000000000000003` | -| **MultiCall Entrypoint** | N/A | `0x0000000000000000000000000000000000000000000000000000000000000004` | `0x0000000000000000000000000000000000000000000000000000000000000004` | -| **Fee Juice** | N/A | `0x0000000000000000000000000000000000000000000000000000000000000005` | `0x0000000000000000000000000000000000000000000000000000000000000005` | +| **Fee Juice** | N/A | `0x0000000000000000000000000000000000000000000000000000000000000001` | `0x0000000000000000000000000000000000000000000000000000000000000001` | +| **Class Registry** | N/A | `0x0000000000000000000000000000000000000000000000000000000000000002` | `0x0000000000000000000000000000000000000000000000000000000000000002` | +| **Instance Registry** | N/A | `0x0000000000000000000000000000000000000000000000000000000000000003` | `0x0000000000000000000000000000000000000000000000000000000000000003` | +| **Auth Registry** | N/A | `0x0000000000000000000000000000000000000000000000000000000000000004` | `0x0000000000000000000000000000000000000000000000000000000000000004` | | **SponsoredFPC** | N/A | `0x1586f476995be97f07ebd415340a14be48dc28c6c661cc6bdddb80ae790caa4e` | `0x1586f476995be97f07ebd415340a14be48dc28c6c661cc6bdddb80ae790caa4e` | ## Governance Parameters diff --git a/l1-contracts/src/core/libraries/ConstantsGen.sol b/l1-contracts/src/core/libraries/ConstantsGen.sol index 7e7a779d1b7b..70656b180092 100644 --- a/l1-contracts/src/core/libraries/ConstantsGen.sol +++ b/l1-contracts/src/core/libraries/ConstantsGen.sol @@ -23,7 +23,7 @@ library Constants { 9_682_850_228_538_071_369_704_502_076_456_077_473_410_427_336_083_826_595_120_404_283_897_422_804_423; uint256 internal constant EMPTY_EPOCH_OUT_HASH = 355_785_372_471_781_095_838_790_036_702_437_931_769_306_153_278_986_832_745_847_530_947_941_691_539; - uint256 internal constant FEE_JUICE_ADDRESS = 5; + uint256 internal constant FEE_JUICE_ADDRESS = 1; uint256 internal constant BLS12_POINT_COMPRESSED_BYTES = 48; uint256 internal constant ROOT_ROLLUP_PUBLIC_INPUTS_LENGTH = 111; uint256 internal constant NUM_MSGS_PER_BASE_PARITY = 256; diff --git a/noir-projects/noir-contracts/Nargo.toml b/noir-projects/noir-contracts/Nargo.toml index 41842163ae57..098cb22eb982 100644 --- a/noir-projects/noir-contracts/Nargo.toml +++ b/noir-projects/noir-contracts/Nargo.toml @@ -30,8 +30,8 @@ members = [ "contracts/protocol/contract_class_registry_contract", "contracts/protocol/contract_instance_registry_contract", "contracts/protocol/fee_juice_contract", - "contracts/protocol/multi_call_entrypoint_contract", - "contracts/protocol/public_checks_contract", + "contracts/app/multi_call_entrypoint_contract", + "contracts/app/public_checks_contract", "contracts/protocol_interface/auth_registry_interface", "contracts/protocol_interface/contract_instance_registry_interface", "contracts/protocol_interface/fee_juice_interface", diff --git a/noir-projects/noir-contracts/README.md b/noir-projects/noir-contracts/README.md index fdfd0f0aa2ec..613eb156c1ca 100644 --- a/noir-projects/noir-contracts/README.md +++ b/noir-projects/noir-contracts/README.md @@ -1,3 +1,12 @@ ## Noir Contracts A series of example aztec-nr smart contracts used in our end to end testing flow + +### protocol_contracts.json + +A list of protocol contract artifacts, formatted as `-`. This mirrors the Noir compiler's output naming convention for files in `target/`. Consumers split on `-` to get the contract name. + +Consumed by: + +- `yarn-project/protocol-contracts/src/scripts/generate_data.ts` — generates `protocol_contract_data.ts` (names, salts, addresses, derived addresses, protocol contracts list and hash) +- `yarn-project/aztec.js/src/scripts/generate_protocol_contract_types.ts` — generates TypeScript contract wrapper classes in `aztec.js/src/contract/protocol_contracts/` diff --git a/noir-projects/noir-contracts/contracts/app/app_subscription_contract/Nargo.toml b/noir-projects/noir-contracts/contracts/app/app_subscription_contract/Nargo.toml index 3a698e724c38..bf7b7d45345e 100644 --- a/noir-projects/noir-contracts/contracts/app/app_subscription_contract/Nargo.toml +++ b/noir-projects/noir-contracts/contracts/app/app_subscription_contract/Nargo.toml @@ -7,4 +7,4 @@ type = "contract" [dependencies] aztec = { path = "../../../../aztec-nr/aztec" } token = { path = "../token_contract" } -public_checks = { path = "../../protocol/public_checks_contract" } +public_checks = { path = "../public_checks_contract" } diff --git a/noir-projects/noir-contracts/contracts/app/app_subscription_contract/src/config.nr b/noir-projects/noir-contracts/contracts/app/app_subscription_contract/src/config.nr index bbd5eddb9d74..ebac4ec6828e 100644 --- a/noir-projects/noir-contracts/contracts/app/app_subscription_contract/src/config.nr +++ b/noir-projects/noir-contracts/contracts/app/app_subscription_contract/src/config.nr @@ -10,4 +10,5 @@ pub struct Config { pub subscription_recipient_address: AztecAddress, pub subscription_price: u128, pub fee_juice_limit_per_tx: Field, + pub public_checks_address: AztecAddress, // Address of the PublicChecks contract } diff --git a/noir-projects/noir-contracts/contracts/app/app_subscription_contract/src/main.nr b/noir-projects/noir-contracts/contracts/app/app_subscription_contract/src/main.nr index 2bf539b44498..e921f454083c 100644 --- a/noir-projects/noir-contracts/contracts/app/app_subscription_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/app/app_subscription_contract/src/main.nr @@ -107,7 +107,12 @@ pub contract AppSubscription { // We check that the note is not expired. We do that via the public checks contract to conceal which contract // is performing the check. - privately_check_block_number(Comparator.LT, *user_expiry_block_number, self.context); + privately_check_block_number( + Comparator.LT, + *user_expiry_block_number, + self.context, + config.public_checks_address, + ); payload.execute_calls(self.context, config.target_address); } @@ -120,6 +125,7 @@ pub contract AppSubscription { subscription_token_address: AztecAddress, subscription_price: u128, fee_juice_limit_per_tx: Field, + public_checks_address: AztecAddress, ) { self.storage.config.initialize( Config { @@ -128,6 +134,7 @@ pub contract AppSubscription { subscription_token_address, subscription_price, fee_juice_limit_per_tx, + public_checks_address, }, ); } @@ -156,6 +163,7 @@ pub contract AppSubscription { Comparator.GT, expiry_block_number - SUBSCRIPTION_DURATION_IN_BLOCKS, self.context, + config.public_checks_address, ); // docs:start:owned_private_mutable_initialize self diff --git a/noir-projects/noir-contracts/contracts/app/crowdfunding_contract/Nargo.toml b/noir-projects/noir-contracts/contracts/app/crowdfunding_contract/Nargo.toml index 2a6f92ccd0ff..7cfc5d3eeb54 100644 --- a/noir-projects/noir-contracts/contracts/app/crowdfunding_contract/Nargo.toml +++ b/noir-projects/noir-contracts/contracts/app/crowdfunding_contract/Nargo.toml @@ -8,4 +8,4 @@ type = "contract" aztec = { path = "../../../../aztec-nr/aztec" } uint_note = { path = "../../../../aztec-nr/uint-note" } token = { path = "../token_contract" } -public_checks = { path = "../../protocol/public_checks_contract" } +public_checks = { path = "../public_checks_contract" } diff --git a/noir-projects/noir-contracts/contracts/app/crowdfunding_contract/src/config.nr b/noir-projects/noir-contracts/contracts/app/crowdfunding_contract/src/config.nr index 7f3a031fe556..12b9071b27a9 100644 --- a/noir-projects/noir-contracts/contracts/app/crowdfunding_contract/src/config.nr +++ b/noir-projects/noir-contracts/contracts/app/crowdfunding_contract/src/config.nr @@ -8,4 +8,5 @@ pub struct Config { pub donation_token: AztecAddress, // Token used for donations (e.g. DAI) pub operator: AztecAddress, // Crowdfunding campaign operator pub deadline: u64, // End of the crowdfunding campaign after which no more donations are accepted + pub public_checks_address: AztecAddress, // Address of the PublicChecks contract } diff --git a/noir-projects/noir-contracts/contracts/app/crowdfunding_contract/src/main.nr b/noir-projects/noir-contracts/contracts/app/crowdfunding_contract/src/main.nr index 816f159fa681..b042c22bbedc 100644 --- a/noir-projects/noir-contracts/contracts/app/crowdfunding_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/app/crowdfunding_contract/src/main.nr @@ -35,8 +35,15 @@ pub contract Crowdfunding { #[external("public")] #[initializer] // this-will-error:init-header-error - fn init(donation_token: AztecAddress, operator: AztecAddress, deadline: u64) { - self.storage.config.initialize(Config { donation_token, operator, deadline }); + fn init( + donation_token: AztecAddress, + operator: AztecAddress, + deadline: u64, + public_checks_address: AztecAddress, + ) { + self.storage.config.initialize( + Config { donation_token, operator, deadline, public_checks_address }, + ); } #[external("private")] @@ -46,7 +53,12 @@ pub contract Crowdfunding { // 1) Check that the deadline has not passed --> we do that via the public checks contract to conceal which contract // is performing the check. // docs:start:call-check-deadline - privately_check_timestamp(Comparator.LT, config.deadline, self.context); + privately_check_timestamp( + Comparator.LT, + config.deadline, + self.context, + config.public_checks_address, + ); // docs:end:call-check-deadline // 2) Transfer the donation tokens from donor to this contract diff --git a/noir-projects/noir-contracts/contracts/protocol/multi_call_entrypoint_contract/Nargo.toml b/noir-projects/noir-contracts/contracts/app/multi_call_entrypoint_contract/Nargo.toml similarity index 100% rename from noir-projects/noir-contracts/contracts/protocol/multi_call_entrypoint_contract/Nargo.toml rename to noir-projects/noir-contracts/contracts/app/multi_call_entrypoint_contract/Nargo.toml diff --git a/noir-projects/noir-contracts/contracts/protocol/multi_call_entrypoint_contract/src/main.nr b/noir-projects/noir-contracts/contracts/app/multi_call_entrypoint_contract/src/main.nr similarity index 80% rename from noir-projects/noir-contracts/contracts/protocol/multi_call_entrypoint_contract/src/main.nr rename to noir-projects/noir-contracts/contracts/app/multi_call_entrypoint_contract/src/main.nr index a9defbbac2bb..afe7dbdfbe92 100644 --- a/noir-projects/noir-contracts/contracts/protocol/multi_call_entrypoint_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/app/multi_call_entrypoint_contract/src/main.nr @@ -5,9 +5,6 @@ // // Pair this with SignerlessWallet to perform multiple actions before any account contracts are deployed (and without // authentication). -// -// Note that this contract should not be grouped with protocol contracts as it is not part of the protocol. We keep -// it here for now as it allows us to use hardcoded address. use aztec::macros::aztec; #[aztec] diff --git a/noir-projects/noir-contracts/contracts/protocol/public_checks_contract/Nargo.toml b/noir-projects/noir-contracts/contracts/app/public_checks_contract/Nargo.toml similarity index 100% rename from noir-projects/noir-contracts/contracts/protocol/public_checks_contract/Nargo.toml rename to noir-projects/noir-contracts/contracts/app/public_checks_contract/Nargo.toml diff --git a/noir-projects/noir-contracts/contracts/protocol/public_checks_contract/src/main.nr b/noir-projects/noir-contracts/contracts/app/public_checks_contract/src/main.nr similarity index 87% rename from noir-projects/noir-contracts/contracts/protocol/public_checks_contract/src/main.nr rename to noir-projects/noir-contracts/contracts/app/public_checks_contract/src/main.nr index 5a9ae16c2623..613e700ae85b 100644 --- a/noir-projects/noir-contracts/contracts/protocol/public_checks_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/app/public_checks_contract/src/main.nr @@ -5,9 +5,6 @@ use aztec::macros::aztec; /// The purpose of this contract is to perform a check in public without revealing what contract enqueued the public /// call. This can be achieved by enqueueing an `incognito` public call. -/// -/// Note that this contract should not be grouped with protocol contracts as it is not part of the protocol. We keep -/// it here for now as it allows us to use hardcoded address. #[aztec] pub contract PublicChecks { use aztec::{macros::functions::{external, view}, utils::comparison::compare}; diff --git a/noir-projects/noir-contracts/contracts/protocol/public_checks_contract/src/test.nr b/noir-projects/noir-contracts/contracts/app/public_checks_contract/src/test.nr similarity index 100% rename from noir-projects/noir-contracts/contracts/protocol/public_checks_contract/src/test.nr rename to noir-projects/noir-contracts/contracts/app/public_checks_contract/src/test.nr diff --git a/noir-projects/noir-contracts/contracts/protocol/public_checks_contract/src/utils.nr b/noir-projects/noir-contracts/contracts/app/public_checks_contract/src/utils.nr similarity index 71% rename from noir-projects/noir-contracts/contracts/protocol/public_checks_contract/src/utils.nr rename to noir-projects/noir-contracts/contracts/app/public_checks_contract/src/utils.nr index dae43db36f0f..2cbd46435ca3 100644 --- a/noir-projects/noir-contracts/contracts/protocol/public_checks_contract/src/utils.nr +++ b/noir-projects/noir-contracts/contracts/app/public_checks_contract/src/utils.nr @@ -1,13 +1,18 @@ use crate::PublicChecks; use aztec::context::PrivateContext; -use aztec::protocol::constants::PUBLIC_CHECKS_ADDRESS; +use aztec::protocol::address::AztecAddress; // docs:start:helper_public_checks_functions /// Asserts that the current timestamp in the enqueued public call enqueued by `check_timestamp` satisfies /// the `operation` with respect to the `value. Preserves privacy by performing the check via the public checks contract. /// This conceals an address of the calling contract by setting `context.msg_sender` to the public checks contract address. -pub fn privately_check_timestamp(operation: u8, value: u64, context: &mut PrivateContext) { - PublicChecks::at(PUBLIC_CHECKS_ADDRESS) +pub fn privately_check_timestamp( + operation: u8, + value: u64, + context: &mut PrivateContext, + public_checks_address: AztecAddress, +) { + PublicChecks::at(public_checks_address) .check_timestamp(operation, value) .enqueue_view_incognito(context); } @@ -15,9 +20,14 @@ pub fn privately_check_timestamp(operation: u8, value: u64, context: &mut Privat /// Asserts that the current block number in the enqueued public call enqueued by `check_block_number` satisfies /// the `operation` with respect to the `value. Preserves privacy by performing the check via the public checks contract. /// This conceals an address of the calling contract by setting `context.msg_sender` to the public checks contract address. -pub fn privately_check_block_number(operation: u8, value: u32, context: &mut PrivateContext) { +pub fn privately_check_block_number( + operation: u8, + value: u32, + context: &mut PrivateContext, + public_checks_address: AztecAddress, +) { // docs:start:enqueueing - PublicChecks::at(PUBLIC_CHECKS_ADDRESS) + PublicChecks::at(public_checks_address) .check_block_number(operation, value) .enqueue_view_incognito(context); // docs:end:enqueueing diff --git a/noir-projects/noir-contracts/protocol_contracts.json b/noir-projects/noir-contracts/protocol_contracts.json index 8a293be0d777..7fa3f765787d 100644 --- a/noir-projects/noir-contracts/protocol_contracts.json +++ b/noir-projects/noir-contracts/protocol_contracts.json @@ -1,8 +1,6 @@ [ - "auth_registry_contract-AuthRegistry", - "contract_instance_registry_contract-ContractInstanceRegistry", - "contract_class_registry_contract-ContractClassRegistry", - "multi_call_entrypoint_contract-MultiCallEntrypoint", "fee_juice_contract-FeeJuice", - "public_checks_contract-PublicChecks" + "contract_class_registry_contract-ContractClassRegistry", + "contract_instance_registry_contract-ContractInstanceRegistry", + "auth_registry_contract-AuthRegistry" ] diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr b/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr index 0329c6bb0ec0..1d41adcc5809 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr @@ -221,12 +221,10 @@ pub global CONTRACT_INSTANCE_UPDATED_MAGIC_VALUE: Field = // Chosen to be a multiple of 3 (-1 to account for the separator), to optimize the poseidon2 hash. pub global MAX_PROTOCOL_CONTRACTS: u32 = 11; // Address 0 is not a protocol contract. -pub global CANONICAL_AUTH_REGISTRY_ADDRESS: AztecAddress = AztecAddress::from_field(1); -pub global CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS: AztecAddress = AztecAddress::from_field(2); -pub global CONTRACT_CLASS_REGISTRY_CONTRACT_ADDRESS: AztecAddress = AztecAddress::from_field(3); -pub global MULTI_CALL_ENTRYPOINT_ADDRESS: AztecAddress = AztecAddress::from_field(4); -pub global FEE_JUICE_ADDRESS: AztecAddress = AztecAddress::from_field(5); -pub global PUBLIC_CHECKS_ADDRESS: AztecAddress = AztecAddress::from_field(6); +pub global FEE_JUICE_ADDRESS: AztecAddress = AztecAddress::from_field(1); +pub global CONTRACT_CLASS_REGISTRY_CONTRACT_ADDRESS: AztecAddress = AztecAddress::from_field(2); +pub global CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS: AztecAddress = AztecAddress::from_field(3); +pub global CANONICAL_AUTH_REGISTRY_ADDRESS: AztecAddress = AztecAddress::from_field(4); // `SIDE_EFFECT_MASKING_ADDRESS` is used by the protocol circuits to silo the padding side effects. It's not a protocol // contract (hence its address is greater than `MAX_PROTOCOL_CONTRACTS`). diff --git a/yarn-project/aztec-node/src/aztec-node/server.ts b/yarn-project/aztec-node/src/aztec-node/server.ts index 02c55f4cbbb2..b66da60ad287 100644 --- a/yarn-project/aztec-node/src/aztec-node/server.ts +++ b/yarn-project/aztec-node/src/aztec-node/server.ts @@ -1243,10 +1243,10 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable { public getProtocolContractAddresses(): Promise { return Promise.resolve({ - classRegistry: ProtocolContractAddress.ContractClassRegistry, feeJuice: ProtocolContractAddress.FeeJuice, + classRegistry: ProtocolContractAddress.ContractClassRegistry, instanceRegistry: ProtocolContractAddress.ContractInstanceRegistry, - multiCallEntrypoint: ProtocolContractAddress.MultiCallEntrypoint, + authRegistry: ProtocolContractAddress.AuthRegistry, }); } diff --git a/yarn-project/aztec.js/src/account/signerless_account.ts b/yarn-project/aztec.js/src/account/signerless_account.ts index c6c2e7b7e861..d7fc0aab1f3a 100644 --- a/yarn-project/aztec.js/src/account/signerless_account.ts +++ b/yarn-project/aztec.js/src/account/signerless_account.ts @@ -11,13 +11,13 @@ import type { CallIntent, IntentInnerHash } from '../utils/authwit.js'; import type { Account } from './account.js'; /** - * Account implementation which creates a transaction using the multicall protocol contract as entrypoint. + * Account implementation which creates a transaction using a deployed MultiCallEntrypoint contract as entrypoint. */ export class SignerlessAccount implements Account { private entrypoint: EntrypointInterface; - constructor() { - this.entrypoint = new DefaultMultiCallEntrypoint(); + constructor(multiCallEntrypointAddress: AztecAddress) { + this.entrypoint = new DefaultMultiCallEntrypoint(multiCallEntrypointAddress); } createTxExecutionRequest( diff --git a/yarn-project/aztec.js/src/api/protocol.ts b/yarn-project/aztec.js/src/api/protocol.ts index 62be26a31981..549dc7aead4f 100644 --- a/yarn-project/aztec.js/src/api/protocol.ts +++ b/yarn-project/aztec.js/src/api/protocol.ts @@ -5,5 +5,3 @@ export { AuthRegistryContract } from '../contract/protocol_contracts/auth-regist export { ContractClassRegistryContract } from '../contract/protocol_contracts/contract-class-registry.js'; export { ContractInstanceRegistryContract } from '../contract/protocol_contracts/contract-instance-registry.js'; export { FeeJuiceContract } from '../contract/protocol_contracts/fee-juice.js'; -export { MultiCallEntrypointContract } from '../contract/protocol_contracts/multi-call-entrypoint.js'; -export { PublicChecksContract } from '../contract/protocol_contracts/public-checks.js'; diff --git a/yarn-project/aztec/src/mainnet_compatibility.test.ts b/yarn-project/aztec/src/mainnet_compatibility.test.ts index dca7d1fcc9d5..533b2f371c08 100644 --- a/yarn-project/aztec/src/mainnet_compatibility.test.ts +++ b/yarn-project/aztec/src/mainnet_compatibility.test.ts @@ -9,12 +9,12 @@ import { getGenesisValues } from '@aztec/world-state/testing'; */ describe('Mainnet compatibility', () => { it('has expected VK tree root', () => { - const expectedRoots = [Fr.fromHexString('0x0f485d750a6264d399c416e01909e4dd18fa0dbaad882fe2b87c7847aeaab564')]; + const expectedRoots = [Fr.fromHexString('0x09fbd43fbad54dad3c323b0fda88fa0329a68f4b368459705afb90b162a67e8e')]; expect(expectedRoots).toContainEqual(getVKTreeRoot()); }); it('has expected Protocol Contracts tree root', () => { expect(protocolContractsHash).toEqual( - Fr.fromHexString('0x2348b12e0edd63c38dbb849b6c788c4975ed3f1f3706fcb5e17431e805da672d'), + Fr.fromHexString('0x18e3bc43bf7b5f79b767cf17245968147d5fc62593ff8d25ea045defee0cfe2e'), ); }); it('has expected Genesis tree roots', async () => { @@ -25,7 +25,7 @@ describe('Mainnet compatibility', () => { /* initial public data leaves */ [], ); expect(genesisArchiveRoot).toEqual( - Fr.fromHexString('0x1f8c805403d88ee809d3cb3e52eeba0a104f69968cdb844a9cbdf1e9e00b3a95'), + Fr.fromHexString('0x15684c8c3d2106918d3860f777e50555b7166adff47df13cc652e2e5a50bf5c7'), ); }); }); diff --git a/yarn-project/aztec/src/testnet_compatibility.test.ts b/yarn-project/aztec/src/testnet_compatibility.test.ts index 4368637d98fd..27bf43ae04ac 100644 --- a/yarn-project/aztec/src/testnet_compatibility.test.ts +++ b/yarn-project/aztec/src/testnet_compatibility.test.ts @@ -11,12 +11,12 @@ import { getGenesisValues } from '@aztec/world-state/testing'; */ describe('Testnet compatibility', () => { it('has expected VK tree root', () => { - const expectedRoots = [Fr.fromHexString('0x0c7576d33473911a15b9b490f1d9ba378355e17b956d974bf89d604b6b1b0b0f')]; + const expectedRoots = [Fr.fromHexString('0x09fbd43fbad54dad3c323b0fda88fa0329a68f4b368459705afb90b162a67e8e')]; expect(expectedRoots).toContainEqual(getVKTreeRoot()); }); it('has expected Protocol Contracts hash', () => { expect(protocolContractsHash).toEqual( - Fr.fromHexString('0x20b49b5e2004b516f057509123ae1a4a2120605005351776051867e3caab413e'), + Fr.fromHexString('0x18e3bc43bf7b5f79b767cf17245968147d5fc62593ff8d25ea045defee0cfe2e'), ); }); it('has expected Genesis tree roots', async () => { @@ -26,7 +26,7 @@ describe('Testnet compatibility', () => { const { genesisArchiveRoot } = await getGenesisValues(initialFundedAccounts); expect(genesisArchiveRoot).toEqual( - Fr.fromHexString('0x204ce64a69ce23a572afdbb50a156a58b2ee1c37ea92a278f96147f3aec93dfc'), + Fr.fromHexString('0x1dd4aee0d326916da4ea905f192543a735a73eabed3f71bcfc674eaabbbd6b5f'), ); }); }); diff --git a/yarn-project/cli-wallet/src/utils/wallet.ts b/yarn-project/cli-wallet/src/utils/wallet.ts index bca0286ecc77..ccb27fbaf0f4 100644 --- a/yarn-project/cli-wallet/src/utils/wallet.ts +++ b/yarn-project/cli-wallet/src/utils/wallet.ts @@ -37,6 +37,7 @@ export class CLIWallet extends BaseWallet { node: AztecNode, private userLog: LogFn, private db?: WalletDB, + private multiCallEntrypointAddress?: AztecAddress, ) { super(pxe, node); this.cancellableTransactions = true; @@ -47,10 +48,11 @@ export class CLIWallet extends BaseWallet { log: LogFn, db?: WalletDB, overridePXEConfig?: Partial, + multiCallEntrypointAddress?: AztecAddress, ): Promise { const pxeConfig = Object.assign(getPXEConfig(), overridePXEConfig); const pxe = await createPXE(node, pxeConfig); - return new CLIWallet(pxe, node, log, db); + return new CLIWallet(pxe, node, log, db, multiCallEntrypointAddress); } override async getAccounts(): Promise[]> { @@ -93,7 +95,10 @@ export class CLIWallet extends BaseWallet { override async getAccountFromAddress(address: AztecAddress) { let account: Account | undefined; if (address.equals(AztecAddress.ZERO)) { - account = new SignerlessAccount(); + if (!this.multiCallEntrypointAddress) { + throw new Error('multiCallEntrypointAddress is required for signerless accounts'); + } + account = new SignerlessAccount(this.multiCallEntrypointAddress); } else if (this.accountCache.has(address.toString())) { return this.accountCache.get(address.toString())!; } else { diff --git a/yarn-project/cli/src/cmds/aztec_node/get_node_info.ts b/yarn-project/cli/src/cmds/aztec_node/get_node_info.ts index dd42e8a09153..c20e961dfd9c 100644 --- a/yarn-project/cli/src/cmds/aztec_node/get_node_info.ts +++ b/yarn-project/cli/src/cmds/aztec_node/get_node_info.ts @@ -28,10 +28,10 @@ export async function getNodeInfo(nodeUrl: string, json: boolean, log: LogFn, lo stakingAssetHandler: info.l1ContractAddresses.stakingAssetHandlerAddress?.toString(), }, protocolContractAddresses: { - classRegistry: info.protocolContractAddresses.classRegistry.toString(), feeJuice: info.protocolContractAddresses.feeJuice.toString(), + classRegistry: info.protocolContractAddresses.classRegistry.toString(), instanceRegistry: info.protocolContractAddresses.instanceRegistry.toString(), - multiCallEntrypoint: info.protocolContractAddresses.multiCallEntrypoint.toString(), + authRegistry: info.protocolContractAddresses.authRegistry.toString(), }, }); } else { @@ -55,9 +55,9 @@ export async function getNodeInfo(nodeUrl: string, json: boolean, log: LogFn, lo log(` FeeAssetHandler Address: ${info.l1ContractAddresses.feeAssetHandlerAddress?.toString()}`); log(` StakingAssetHandler Address: ${info.l1ContractAddresses.stakingAssetHandlerAddress?.toString()}`); log(`L2 Contract Addresses:`); - log(` Class Registry: ${info.protocolContractAddresses.classRegistry.toString()}`); log(` Fee Juice: ${info.protocolContractAddresses.feeJuice.toString()}`); + log(` Class Registry: ${info.protocolContractAddresses.classRegistry.toString()}`); log(` Instance Deployer: ${info.protocolContractAddresses.instanceRegistry.toString()}`); - log(` MultiCall: ${info.protocolContractAddresses.multiCallEntrypoint.toString()}`); + log(` Auth Registry: ${info.protocolContractAddresses.authRegistry.toString()}`); } } diff --git a/yarn-project/constants/src/constants.gen.ts b/yarn-project/constants/src/constants.gen.ts index 3c1ce83ddc71..a0c6b2e3d1c7 100644 --- a/yarn-project/constants/src/constants.gen.ts +++ b/yarn-project/constants/src/constants.gen.ts @@ -112,12 +112,10 @@ export const CONTRACT_CLASS_REGISTRY_UTILITY_FUNCTION_BROADCASTED_MAGIC_VALUE = export const CONTRACT_INSTANCE_PUBLISHED_MAGIC_VALUE = 10538216027419913765597387738085647348651103543680388181336823392401502757423n; export const CONTRACT_INSTANCE_UPDATED_MAGIC_VALUE = 20721543224513346060908370400407150739273836456436647488068002302723900469047n; export const MAX_PROTOCOL_CONTRACTS = 11; -export const CANONICAL_AUTH_REGISTRY_ADDRESS = 1; -export const CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS = 2; -export const CONTRACT_CLASS_REGISTRY_CONTRACT_ADDRESS = 3; -export const MULTI_CALL_ENTRYPOINT_ADDRESS = 4; -export const FEE_JUICE_ADDRESS = 5; -export const PUBLIC_CHECKS_ADDRESS = 6; +export const FEE_JUICE_ADDRESS = 1; +export const CONTRACT_CLASS_REGISTRY_CONTRACT_ADDRESS = 2; +export const CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS = 3; +export const CANONICAL_AUTH_REGISTRY_ADDRESS = 4; export const SIDE_EFFECT_MASKING_ADDRESS = 19523154334483583633304358390644137470227519736821975910774528428729027989987n; export const NULL_MSG_SENDER_CONTRACT_ADDRESS = 21888242871839275222246405745257275088548364400416034343698204186575808495616n; export const CONTRACT_CLASS_REGISTRY_BYTECODE_CAPSULE_SLOT = 14193106819744442689484501689686180698286338820089744102289275815863062044599n; diff --git a/yarn-project/constants/src/scripts/constants.in.ts b/yarn-project/constants/src/scripts/constants.in.ts index 9bfe82656b50..37d904620f46 100644 --- a/yarn-project/constants/src/scripts/constants.in.ts +++ b/yarn-project/constants/src/scripts/constants.in.ts @@ -26,9 +26,7 @@ const CPP_CONSTANTS = [ 'CANONICAL_AUTH_REGISTRY_ADDRESS', 'CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS', 'CONTRACT_CLASS_REGISTRY_CONTRACT_ADDRESS', - 'MULTI_CALL_ENTRYPOINT_ADDRESS', 'FEE_JUICE_ADDRESS', - 'PUBLIC_CHECKS_ADDRESS', 'FEE_JUICE_BALANCES_SLOT', 'UPDATED_CLASS_IDS_SLOT', 'UPDATES_DELAYED_PUBLIC_MUTABLE_VALUES_LEN', @@ -166,9 +164,7 @@ const PIL_CONSTANTS = [ 'CANONICAL_AUTH_REGISTRY_ADDRESS', 'CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS', 'CONTRACT_CLASS_REGISTRY_CONTRACT_ADDRESS', - 'MULTI_CALL_ENTRYPOINT_ADDRESS', 'FEE_JUICE_ADDRESS', - 'PUBLIC_CHECKS_ADDRESS', 'FEE_JUICE_BALANCES_SLOT', 'TIMESTAMP_OF_CHANGE_BIT_SIZE', 'UPDATES_DELAYED_PUBLIC_MUTABLE_METADATA_BIT_SIZE', diff --git a/yarn-project/end-to-end/src/e2e_crowdfunding_and_claim.test.ts b/yarn-project/end-to-end/src/e2e_crowdfunding_and_claim.test.ts index e82734a14b15..1fb25558b74e 100644 --- a/yarn-project/end-to-end/src/e2e_crowdfunding_and_claim.test.ts +++ b/yarn-project/end-to-end/src/e2e_crowdfunding_and_claim.test.ts @@ -4,6 +4,7 @@ import type { Logger } from '@aztec/aztec.js/log'; import { CheatCodes } from '@aztec/aztec/testing'; import { ClaimContract } from '@aztec/noir-contracts.js/Claim'; import { CrowdfundingContract } from '@aztec/noir-contracts.js/Crowdfunding'; +import { PublicChecksContract } from '@aztec/noir-contracts.js/PublicChecks'; import { TokenContract } from '@aztec/noir-contracts.js/Token'; import { AztecAddress } from '@aztec/stdlib/aztec-address'; @@ -40,6 +41,7 @@ describe('e2e_crowdfunding_and_claim', () => { let donationToken: TokenContract; let rewardToken: TokenContract; + let publicCheckContract: PublicChecksContract; let crowdfundingContract: CrowdfundingContract; let claimContract: ClaimContract; @@ -80,6 +82,9 @@ describe('e2e_crowdfunding_and_claim', () => { ).send({ from: operatorAddress }); logger.info(`Reward Token deployed to ${rewardToken.address}`); + publicCheckContract = await PublicChecksContract.deploy(wallet).send({ from: operatorAddress }); + logger.info(`Public Check Contract deployed at ${publicCheckContract.address}`); + // We deploy the Crowdfunding contract as an escrow contract (i.e. with populated public keys that make it // a potential recipient of notes) because the donations accumulate "in it". crowdfundingSecretKey = Fr.random(); @@ -91,6 +96,7 @@ describe('e2e_crowdfunding_and_claim', () => { donationToken.address, operatorAddress, deadline, + publicCheckContract.address, ); const crowdfundingInstance = await crowdfundingDeployment.getInstance(); await wallet.registerContract(crowdfundingInstance, CrowdfundingContract.artifact, crowdfundingSecretKey); @@ -219,6 +225,7 @@ describe('e2e_crowdfunding_and_claim', () => { donationToken.address, operatorAddress, deadline, + publicCheckContract.address, ); otherCrowdfundingContract = await otherCrowdfundingDeployment.send({ from: operatorAddress }); diff --git a/yarn-project/end-to-end/src/test-wallet/test_wallet.ts b/yarn-project/end-to-end/src/test-wallet/test_wallet.ts index 1b4722d3501c..db1db1250a56 100644 --- a/yarn-project/end-to-end/src/test-wallet/test_wallet.ts +++ b/yarn-project/end-to-end/src/test-wallet/test_wallet.ts @@ -47,6 +47,7 @@ export class TestWallet extends BaseWallet { constructor( pxe: PXE, private readonly nodeRef: AztecNodeProxy, + private multiCallEntrypointAddress?: AztecAddress, ) { super(pxe, nodeRef); } @@ -55,6 +56,7 @@ export class TestWallet extends BaseWallet { node: AztecNode, overridePXEConfig?: Partial, options: PXECreationOptions = { loggers: {} }, + multiCallEntrypointAddress?: AztecAddress, ): Promise { const nodeRef = new AztecNodeProxy(node); const pxeConfig = Object.assign(getPXEConfig(), { @@ -62,7 +64,7 @@ export class TestWallet extends BaseWallet { ...overridePXEConfig, }); const pxe = await createPXE(nodeRef, pxeConfig, options); - return new TestWallet(pxe, nodeRef); + return new TestWallet(pxe, nodeRef, multiCallEntrypointAddress); } /** @@ -148,7 +150,10 @@ export class TestWallet extends BaseWallet { protected getAccountFromAddress(address: AztecAddress): Promise { let account: Account | undefined; if (address.equals(AztecAddress.ZERO)) { - account = new SignerlessAccount(); + if (!this.multiCallEntrypointAddress) { + throw new Error('multiCallEntrypointAddress is required for signerless accounts'); + } + account = new SignerlessAccount(this.multiCallEntrypointAddress); } else { account = this.accounts.get(address?.toString() ?? ''); } diff --git a/yarn-project/entrypoints/src/default_multi_call_entrypoint.ts b/yarn-project/entrypoints/src/default_multi_call_entrypoint.ts index 60c905a415b0..e3ade383c586 100644 --- a/yarn-project/entrypoints/src/default_multi_call_entrypoint.ts +++ b/yarn-project/entrypoints/src/default_multi_call_entrypoint.ts @@ -1,5 +1,4 @@ import { Fr } from '@aztec/foundation/curves/bn254'; -import { ProtocolContractAddress } from '@aztec/protocol-contracts'; import { type FunctionAbi, FunctionCall, FunctionSelector, encodeArguments } from '@aztec/stdlib/abi'; import type { AztecAddress } from '@aztec/stdlib/aztec-address'; import type { GasSettings } from '@aztec/stdlib/gas'; @@ -9,10 +8,11 @@ import { EncodedAppEntrypointCalls } from './encoding.js'; import type { ChainInfo, EntrypointInterface } from './interfaces.js'; /** - * Implementation for an entrypoint interface that can execute multiple function calls in a single transaction + * Implementation for an entrypoint interface that can execute multiple function calls in a single transaction. + * Requires the address of a deployed MultiCallEntrypoint contract. */ export class DefaultMultiCallEntrypoint implements EntrypointInterface { - constructor(private address: AztecAddress = ProtocolContractAddress.MultiCallEntrypoint) {} + constructor(private address: AztecAddress) {} async createTxExecutionRequest( exec: ExecutionPayload, diff --git a/yarn-project/protocol-contracts/src/multi-call-entrypoint/index.ts b/yarn-project/protocol-contracts/src/multi-call-entrypoint/index.ts deleted file mode 100644 index a3e478f51867..000000000000 --- a/yarn-project/protocol-contracts/src/multi-call-entrypoint/index.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { loadContractArtifact } from '@aztec/stdlib/abi'; -import type { NoirCompiledContract } from '@aztec/stdlib/noir'; - -import MultiCallEntrypointJson from '../../artifacts/MultiCallEntrypoint.json' with { type: 'json' }; -import { makeProtocolContract } from '../make_protocol_contract.js'; -import type { ProtocolContract } from '../protocol_contract.js'; - -export const MultiCallEntrypointArtifact = loadContractArtifact(MultiCallEntrypointJson as NoirCompiledContract); - -let protocolContract: ProtocolContract; - -/** Returns the canonical deployment of the contract. */ -export async function getCanonicalMultiCallEntrypoint(): Promise { - if (!protocolContract) { - protocolContract = await makeProtocolContract('MultiCallEntrypoint', MultiCallEntrypointArtifact); - } - return protocolContract; -} diff --git a/yarn-project/protocol-contracts/src/multi-call-entrypoint/lazy.ts b/yarn-project/protocol-contracts/src/multi-call-entrypoint/lazy.ts deleted file mode 100644 index 18d9c4fc94f0..000000000000 --- a/yarn-project/protocol-contracts/src/multi-call-entrypoint/lazy.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { type ContractArtifact, loadContractArtifact } from '@aztec/stdlib/abi'; - -import { makeProtocolContract } from '../make_protocol_contract.js'; -import type { ProtocolContract } from '../protocol_contract.js'; - -let protocolContract: ProtocolContract; -let protocolContractArtifact: ContractArtifact; - -export async function getMultiCallEntrypointArtifact(): Promise { - if (!protocolContractArtifact) { - // Cannot assert this import as it's incompatible with bundlers like vite - // https://github.com/vitejs/vite/issues/19095#issuecomment-2566074352 - // Even if now supported by al major browsers, the MIME type is replaced with - // "text/javascript" - // In the meantime, this lazy import is INCOMPATIBLE WITH NODEJS - const { default: multiCallEntrypointJson } = await import('../../artifacts/MultiCallEntrypoint.json'); - protocolContractArtifact = loadContractArtifact(multiCallEntrypointJson); - } - return protocolContractArtifact; -} - -/** Returns the canonical deployment of the auth registry. */ -export async function getCanonicalMultiCallEntrypoint(): Promise { - if (!protocolContract) { - const multiCallEntrypointArtifact = await getMultiCallEntrypointArtifact(); - protocolContract = await makeProtocolContract('MultiCallEntrypoint', multiCallEntrypointArtifact); - } - return protocolContract; -} diff --git a/yarn-project/protocol-contracts/src/provider/bundle.ts b/yarn-project/protocol-contracts/src/provider/bundle.ts index ad886d532a9f..6085414cc2cd 100644 --- a/yarn-project/protocol-contracts/src/provider/bundle.ts +++ b/yarn-project/protocol-contracts/src/provider/bundle.ts @@ -5,19 +5,15 @@ import { ContractClassRegistryArtifact } from '../class-registry/index.js'; import { FeeJuiceArtifact } from '../fee-juice/index.js'; import { ContractInstanceRegistryArtifact } from '../instance-registry/index.js'; import { makeProtocolContract } from '../make_protocol_contract.js'; -import { MultiCallEntrypointArtifact } from '../multi-call-entrypoint/index.js'; import type { ProtocolContract } from '../protocol_contract.js'; import type { ProtocolContractName } from '../protocol_contract_data.js'; -import { PublicChecksArtifact } from '../public-checks/index.js'; import type { ProtocolContractsProvider } from './protocol_contracts_provider.js'; export const ProtocolContractArtifact: Record = { - AuthRegistry: AuthRegistryArtifact, - ContractInstanceRegistry: ContractInstanceRegistryArtifact, - ContractClassRegistry: ContractClassRegistryArtifact, - MultiCallEntrypoint: MultiCallEntrypointArtifact, FeeJuice: FeeJuiceArtifact, - PublicChecks: PublicChecksArtifact, + ContractClassRegistry: ContractClassRegistryArtifact, + ContractInstanceRegistry: ContractInstanceRegistryArtifact, + AuthRegistry: AuthRegistryArtifact, }; export class BundledProtocolContractsProvider implements ProtocolContractsProvider { diff --git a/yarn-project/protocol-contracts/src/provider/lazy.ts b/yarn-project/protocol-contracts/src/provider/lazy.ts index 590a1ecbf08a..fc0dca49375a 100644 --- a/yarn-project/protocol-contracts/src/provider/lazy.ts +++ b/yarn-project/protocol-contracts/src/provider/lazy.ts @@ -2,27 +2,21 @@ import { getCanonicalAuthRegistry } from '../auth-registry/lazy.js'; import { getCanonicalClassRegistry } from '../class-registry/lazy.js'; import { getCanonicalFeeJuice } from '../fee-juice/lazy.js'; import { getCanonicalInstanceRegistry } from '../instance-registry/lazy.js'; -import { getCanonicalMultiCallEntrypoint } from '../multi-call-entrypoint/lazy.js'; import type { ProtocolContract } from '../protocol_contract.js'; import type { ProtocolContractName } from '../protocol_contract_data.js'; -import { getCanonicalPublicChecks } from '../public-checks/lazy.js'; import type { ProtocolContractsProvider } from './protocol_contracts_provider.js'; export class LazyProtocolContractsProvider implements ProtocolContractsProvider { getProtocolContractArtifact(name: ProtocolContractName): Promise { switch (name) { - case 'AuthRegistry': - return getCanonicalAuthRegistry(); - case 'ContractInstanceRegistry': - return getCanonicalInstanceRegistry(); - case 'ContractClassRegistry': - return getCanonicalClassRegistry(); - case 'MultiCallEntrypoint': - return getCanonicalMultiCallEntrypoint(); case 'FeeJuice': return getCanonicalFeeJuice(); - case 'PublicChecks': - return getCanonicalPublicChecks(); + case 'ContractClassRegistry': + return getCanonicalClassRegistry(); + case 'ContractInstanceRegistry': + return getCanonicalInstanceRegistry(); + case 'AuthRegistry': + return getCanonicalAuthRegistry(); default: throw new Error(`Unknown protocol contract name: ${name}`); } diff --git a/yarn-project/protocol-contracts/src/public-checks/index.ts b/yarn-project/protocol-contracts/src/public-checks/index.ts deleted file mode 100644 index 66280429fcc3..000000000000 --- a/yarn-project/protocol-contracts/src/public-checks/index.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { loadContractArtifact } from '@aztec/stdlib/abi'; -import type { NoirCompiledContract } from '@aztec/stdlib/noir'; - -import PublicChecksJson from '../../artifacts/PublicChecks.json' with { type: 'json' }; -import { makeProtocolContract } from '../make_protocol_contract.js'; -import type { ProtocolContract } from '../protocol_contract.js'; - -export const PublicChecksArtifact = loadContractArtifact(PublicChecksJson as NoirCompiledContract); - -let protocolContract: ProtocolContract; - -/** Returns the canonical deployment of the contract. */ -export async function getCanonicalPublicChecks(): Promise { - if (!protocolContract) { - protocolContract = await makeProtocolContract('PublicChecks', PublicChecksArtifact); - } - return protocolContract; -} diff --git a/yarn-project/protocol-contracts/src/public-checks/lazy.ts b/yarn-project/protocol-contracts/src/public-checks/lazy.ts deleted file mode 100644 index 21a8eef301a4..000000000000 --- a/yarn-project/protocol-contracts/src/public-checks/lazy.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { type ContractArtifact, loadContractArtifact } from '@aztec/stdlib/abi'; - -import { makeProtocolContract } from '../make_protocol_contract.js'; -import type { ProtocolContract } from '../protocol_contract.js'; - -let protocolContract: ProtocolContract; -let protocolContractArtifact: ContractArtifact; - -export async function getPublicChecksArtifact(): Promise { - if (!protocolContractArtifact) { - // Cannot assert this import as it's incompatible with bundlers like vite - // https://github.com/vitejs/vite/issues/19095#issuecomment-2566074352 - // Even if now supported by al major browsers, the MIME type is replaced with - // "text/javascript" - // In the meantime, this lazy import is INCOMPATIBLE WITH NODEJS - const { default: publicChecksJson } = await import('../../artifacts/PublicChecks.json'); - protocolContractArtifact = loadContractArtifact(publicChecksJson); - } - return protocolContractArtifact; -} - -/** Returns the canonical deployment of the public checks contract. */ -export async function getCanonicalPublicChecks(): Promise { - if (!protocolContract) { - const publicChecksArtifact = await getPublicChecksArtifact(); - protocolContract = await makeProtocolContract('PublicChecks', publicChecksArtifact); - } - return protocolContract; -} diff --git a/yarn-project/protocol-contracts/src/scripts/generate_data.ts b/yarn-project/protocol-contracts/src/scripts/generate_data.ts index f6648841ea11..545350863fce 100644 --- a/yarn-project/protocol-contracts/src/scripts/generate_data.ts +++ b/yarn-project/protocol-contracts/src/scripts/generate_data.ts @@ -5,8 +5,6 @@ import { CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS, FEE_JUICE_ADDRESS, MAX_PROTOCOL_CONTRACTS, - MULTI_CALL_ENTRYPOINT_ADDRESS, - PUBLIC_CHECKS_ADDRESS, } from '@aztec/constants'; import { makeTuple } from '@aztec/foundation/array'; import { Fr } from '@aztec/foundation/curves/bn254'; @@ -31,12 +29,10 @@ const outputFilePath = './src/protocol_contract_data.ts'; const salt = new Fr(1); const contractAddressMapping: { [name: string]: number } = { - AuthRegistry: CANONICAL_AUTH_REGISTRY_ADDRESS, - ContractInstanceRegistry: CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS, - ContractClassRegistry: CONTRACT_CLASS_REGISTRY_CONTRACT_ADDRESS, - MultiCallEntrypoint: MULTI_CALL_ENTRYPOINT_ADDRESS, FeeJuice: FEE_JUICE_ADDRESS, - PublicChecks: PUBLIC_CHECKS_ADDRESS, + ContractClassRegistry: CONTRACT_CLASS_REGISTRY_CONTRACT_ADDRESS, + ContractInstanceRegistry: CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS, + AuthRegistry: CANONICAL_AUTH_REGISTRY_ADDRESS, }; async function clearDestDir() { diff --git a/yarn-project/pxe/src/pxe.test.ts b/yarn-project/pxe/src/pxe.test.ts index f53376b0e4b3..91a1edc32434 100644 --- a/yarn-project/pxe/src/pxe.test.ts +++ b/yarn-project/pxe/src/pxe.test.ts @@ -70,10 +70,10 @@ describe('PXE', () => { enr: undefined, l1ContractAddresses: mockedContracts, protocolContractAddresses: { - classRegistry: await AztecAddress.random(), feeJuice: await AztecAddress.random(), + classRegistry: await AztecAddress.random(), instanceRegistry: await AztecAddress.random(), - multiCallEntrypoint: await AztecAddress.random(), + authRegistry: await AztecAddress.random(), }, realProofs: true, }); diff --git a/yarn-project/stdlib/src/contract/interfaces/protocol_contract_addresses.ts b/yarn-project/stdlib/src/contract/interfaces/protocol_contract_addresses.ts index 953cbe62a7e4..e9917d4287a1 100644 --- a/yarn-project/stdlib/src/contract/interfaces/protocol_contract_addresses.ts +++ b/yarn-project/stdlib/src/contract/interfaces/protocol_contract_addresses.ts @@ -3,18 +3,18 @@ import { z } from 'zod'; import type { AztecAddress } from '../../aztec-address/index.js'; import { schemas } from '../../schemas/index.js'; -export const ProtocolContractsNames = ['classRegistry', 'feeJuice', 'instanceRegistry', 'multiCallEntrypoint'] as const; +export const ProtocolContractsNames = ['feeJuice', 'classRegistry', 'instanceRegistry', 'authRegistry'] as const; export type ProtocolContractAddresses = { - classRegistry: AztecAddress; feeJuice: AztecAddress; + classRegistry: AztecAddress; instanceRegistry: AztecAddress; - multiCallEntrypoint: AztecAddress; + authRegistry: AztecAddress; }; export const ProtocolContractAddressesSchema = z.object({ - classRegistry: schemas.AztecAddress, feeJuice: schemas.AztecAddress, + classRegistry: schemas.AztecAddress, instanceRegistry: schemas.AztecAddress, - multiCallEntrypoint: schemas.AztecAddress, + authRegistry: schemas.AztecAddress, }); diff --git a/yarn-project/wallets/src/embedded/embedded_wallet.ts b/yarn-project/wallets/src/embedded/embedded_wallet.ts index e1ecae7f92d0..31e165db80cd 100644 --- a/yarn-project/wallets/src/embedded/embedded_wallet.ts +++ b/yarn-project/wallets/src/embedded/embedded_wallet.ts @@ -29,13 +29,17 @@ export class EmbeddedWallet extends BaseWallet { protected walletDB: WalletDB, protected accountContracts: AccountContractsProvider, log?: Logger, + protected multiCallEntrypointAddress?: AztecAddress, ) { super(pxe, aztecNode, log); } protected async getAccountFromAddress(address: AztecAddress): Promise { if (address.equals(AztecAddress.ZERO)) { - return new SignerlessAccount(); + if (!this.multiCallEntrypointAddress) { + throw new Error('multiCallEntrypointAddress is required for signerless accounts'); + } + return new SignerlessAccount(this.multiCallEntrypointAddress); } const { secretKey, salt, signingKey, type } = await this.walletDB.retrieveAccount(address);