From 8cc4f694f93499e91026bd6c144a3f646d987588 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Bene=C5=A1?= Date: Wed, 27 Sep 2023 16:24:46 +0100 Subject: [PATCH] refactor: rename all the occurrences of `Aztec RPC` (#2552) Fixes #2451 --- .circleci/config.yml | 10 +-- README.md | 2 +- .../roadmap/features_initial_ldt.md | 2 +- .../docs/concepts/foundation/accounts/keys.md | 2 +- docs/docs/dev_docs/cli/main.md | 4 +- docs/docs/dev_docs/contracts/common_errors.md | 16 ++-- docs/docs/dev_docs/contracts/compiling.md | 2 +- docs/docs/dev_docs/contracts/deploying.md | 16 ++-- docs/docs/dev_docs/contracts/syntax/events.md | 20 ++--- .../dev_docs/contracts/syntax/functions.md | 2 +- .../dev_docs/getting_started/quickstart.md | 8 +- docs/docs/dev_docs/testing/cheat_codes.md | 8 +- docs/docs/dev_docs/tutorials/testing.md | 28 +++---- .../writing_dapp/contract_deployment.md | 2 +- .../tutorials/writing_dapp/project_setup.md | 2 +- .../{rpc_server.md => pxe_service.md} | 4 +- .../tutorials/writing_token_contract.md | 2 +- docs/docs/dev_docs/wallets/architecture.md | 8 +- .../wallets/writing_an_account_contract.md | 2 +- docs/docusaurus.config.js | 4 +- docs/internal_notes/api.md | 2 +- .../dev_docs/sandbox/components.md | 7 +- docs/sidebars.js | 6 +- yarn-project/aztec-node/src/bin/index.ts | 2 +- yarn-project/aztec-rpc/src/bin/index.ts | 39 ---------- yarn-project/aztec-sandbox/README.md | 2 +- yarn-project/aztec-sandbox/docker-compose.yml | 2 +- yarn-project/aztec-sandbox/src/bin/index.ts | 14 ++-- .../src/examples/private_token_contract.ts | 10 +-- .../examples/uniswap_trade_on_l1_from_l2.ts | 45 +++++------ .../aztec-sandbox/src/examples/util.ts | 2 +- yarn-project/aztec-sandbox/src/routes.ts | 2 +- yarn-project/aztec-sandbox/src/sandbox.ts | 12 +-- yarn-project/aztec-sandbox/src/server.ts | 12 +-- yarn-project/aztec.js/README.md | 4 +- yarn-project/aztec.js/src/account/index.ts | 38 +++++----- .../aztec.js/src/account/manager/index.ts | 22 +++--- yarn-project/aztec.js/src/account/utils.ts | 22 +++--- .../src/contract/base_contract_interaction.ts | 10 +-- .../aztec.js/src/contract/contract.test.ts | 2 +- .../aztec.js/src/contract/contract.ts | 2 +- .../aztec.js/src/contract/contract_base.ts | 4 +- yarn-project/aztec.js/src/contract/index.ts | 2 +- .../aztec.js/src/contract/sent_tx.test.ts | 20 ++--- yarn-project/aztec.js/src/contract/sent_tx.ts | 18 ++--- .../contract_deployer.test.ts | 16 ++-- .../contract_deployer/contract_deployer.ts | 8 +- .../src/contract_deployer/deploy_method.ts | 12 +-- .../src/contract_deployer/deploy_sent_tx.ts | 8 +- yarn-project/aztec.js/src/index.ts | 4 +- .../{aztec_rpc_client.ts => pxe_client.ts} | 6 +- yarn-project/aztec.js/src/sandbox/index.ts | 22 +++--- .../aztec.js/src/utils/cheat_codes.ts | 20 ++--- .../aztec.js/src/utils/l2_contracts.ts | 8 +- .../aztec.js/src/wallet/account_wallet.ts | 8 +- .../aztec.js/src/wallet/base_wallet.ts | 56 +++++++------- yarn-project/aztec.js/src/wallet/index.ts | 4 +- .../aztec.js/src/wallet/signerless_wallet.ts | 2 +- .../boxes/blank-react/docker-compose.yml | 2 +- .../src/app/components/wallet_dropdown.tsx | 4 +- .../boxes/blank-react/src/artifacts/blank.ts | 10 +-- yarn-project/boxes/blank-react/src/config.ts | 4 +- .../src/scripts/call_contract_function.ts | 6 +- .../src/scripts/deploy_contract.ts | 6 +- .../boxes/blank-react/src/scripts/util.ts | 10 +-- .../src/scripts/view_contract_function.ts | 6 +- .../src/tests/blank.contract.test.ts | 28 +++---- yarn-project/boxes/blank/docker-compose.yml | 2 +- .../boxes/blank/src/artifacts/blank.ts | 10 +-- yarn-project/boxes/blank/src/index.ts | 34 ++++----- .../blank/src/tests/blank.contract.test.ts | 26 +++---- .../boxes/private-token/docker-compose.yml | 2 +- .../app/components/contract_function_form.tsx | 21 ++--- .../private-token/src/app/components/copy.tsx | 2 +- .../src/app/components/dropdown.tsx | 5 +- .../src/app/components/popup.tsx | 2 +- .../src/app/components/select.tsx | 5 +- .../src/app/components/wallet_dropdown.tsx | 10 +-- .../boxes/private-token/src/app/contract.tsx | 8 +- .../boxes/private-token/src/app/home.tsx | 6 +- .../boxes/private-token/src/app/index.tsx | 4 +- .../src/artifacts/private_token.ts | 10 +-- .../boxes/private-token/src/config.ts | 8 +- .../src/scripts/call_contract_function.ts | 8 +- .../src/scripts/deploy_contract.ts | 6 +- .../boxes/private-token/src/scripts/util.ts | 10 +-- .../src/scripts/view_contract_function.ts | 8 +- .../src/tests/privatetoken.sandbox.test.ts | 43 +++++------ .../canary/scripts/docker-compose-browser.yml | 2 +- .../scripts/docker-compose-e2e-sandbox.yml | 2 +- .../canary/scripts/docker-compose.yml | 2 +- yarn-project/canary/src/cli.test.ts | 8 +- .../src/uniswap_trade_on_l1_from_l2.test.ts | 14 ++-- yarn-project/canary/src/utils.ts | 2 +- yarn-project/cli/README.md | 38 +++++----- yarn-project/cli/src/client.test.ts | 22 +++--- yarn-project/cli/src/client.ts | 33 +++----- yarn-project/cli/src/index.ts | 40 +++++----- yarn-project/cli/src/test/utils.test.ts | 8 +- yarn-project/cli/src/utils.ts | 13 ++-- .../docker-compose-e2e-sandbox-browser.yml | 2 +- .../scripts/docker-compose-e2e-sandbox.yml | 2 +- .../end-to-end/scripts/docker-compose.yml | 2 +- .../end-to-end/src/aztec_rpc_sandbox.test.ts | 12 --- yarn-project/end-to-end/src/canary/browser.ts | 42 +++++----- yarn-project/end-to-end/src/canary/cli.ts | 16 ++-- ...rpc_servers.test.ts => e2e_2_pxes.test.ts} | 68 ++++++++--------- .../src/e2e_account_contracts.test.ts | 16 ++-- .../end-to-end/src/e2e_block_building.test.ts | 10 +-- .../end-to-end/src/e2e_card_game.test.ts | 8 +- .../end-to-end/src/e2e_cheat_codes.test.ts | 8 +- yarn-project/end-to-end/src/e2e_cli.test.ts | 14 ++-- .../src/e2e_cross_chain_messaging.test.ts | 4 +- .../src/e2e_deploy_contract.test.ts | 18 ++--- .../src/e2e_escrow_contract.test.ts | 10 +-- .../e2e_multiple_accounts_1_enc_key.test.ts | 12 +-- .../src/e2e_nested_contract.test.ts | 8 +- .../src/e2e_non_contract_account.test.ts | 10 +-- .../end-to-end/src/e2e_ordering.test.ts | 14 ++-- .../end-to-end/src/e2e_p2p_network.test.ts | 35 ++++----- .../e2e_public_cross_chain_messaging.test.ts | 4 +- .../e2e_public_to_private_messaging.test.ts | 8 +- .../src/e2e_public_token_contract.test.ts | 10 +-- .../src/e2e_sandbox_example.test.ts | 34 ++++----- .../end-to-end/src/e2e_token_contract.test.ts | 16 ++-- .../src/fixtures/cross_chain_test_harness.ts | 18 ++--- yarn-project/end-to-end/src/fixtures/utils.ts | 76 +++++++++---------- .../src/guides/dapp_testing.test.ts | 54 ++++++------- .../src/guides/up_quick_start.test.ts | 2 +- .../writing_an_account_contract.test.ts | 6 +- .../end-to-end/src/pxe_sandbox.test.ts | 12 +++ .../end-to-end/src/sample-dapp/connect.mjs | 6 +- .../end-to-end/src/sample-dapp/deploy.mjs | 8 +- .../end-to-end/src/sample-dapp/index.mjs | 58 +++++++------- .../end-to-end/src/sample-dapp/index.test.mjs | 8 +- .../src/uniswap_trade_on_l1_from_l2.test.ts | 16 ++-- yarn-project/key-store/README.md | 2 +- .../src/__snapshots__/index.test.ts.snap | 6 +- .../src/contract-interface-gen/typescript.ts | 10 +-- yarn-project/pxe/README.md | 8 +- yarn-project/pxe/src/aztec_rpc_http/index.ts | 1 - .../pxe/src/aztec_rpc_server/index.ts | 3 - yarn-project/pxe/src/bin/index.ts | 39 ++++++++++ yarn-project/pxe/src/config/index.ts | 12 +-- yarn-project/pxe/src/index.ts | 4 +- yarn-project/pxe/src/pxe_http/index.ts | 1 + .../pxe_http_server.ts} | 19 +++-- .../create_pxe_service.ts} | 28 +++---- yarn-project/pxe/src/pxe_service/index.ts | 3 + .../pxe_service.ts} | 24 +++--- .../test/pxe_service.test.ts} | 22 +++--- .../test/pxe_test_suite.ts} | 60 +++++++-------- .../pxe/src/simulator_oracle/index.ts | 2 +- .../pxe/src/synchronizer/synchronizer.ts | 4 +- yarn-project/types/src/interfaces/index.ts | 2 +- .../src/interfaces/{aztec_rpc.ts => pxe.ts} | 36 ++++----- .../types/src/tx_execution_request.ts | 2 +- 157 files changed, 998 insertions(+), 1046 deletions(-) rename docs/docs/dev_docs/tutorials/writing_dapp/{rpc_server.md => pxe_service.md} (74%) delete mode 100644 yarn-project/aztec-rpc/src/bin/index.ts rename yarn-project/aztec.js/src/{aztec_rpc_client.ts => pxe_client.ts} (84%) delete mode 100644 yarn-project/end-to-end/src/aztec_rpc_sandbox.test.ts rename yarn-project/end-to-end/src/{e2e_2_rpc_servers.test.ts => e2e_2_pxes.test.ts} (80%) create mode 100644 yarn-project/end-to-end/src/pxe_sandbox.test.ts delete mode 100644 yarn-project/pxe/src/aztec_rpc_http/index.ts delete mode 100644 yarn-project/pxe/src/aztec_rpc_server/index.ts create mode 100644 yarn-project/pxe/src/bin/index.ts create mode 100644 yarn-project/pxe/src/pxe_http/index.ts rename yarn-project/pxe/src/{aztec_rpc_http/aztec_rpc_http_server.ts => pxe_http/pxe_http_server.ts} (65%) rename yarn-project/pxe/src/{aztec_rpc_server/create_aztec_rpc_server.ts => pxe_service/create_pxe_service.ts} (57%) create mode 100644 yarn-project/pxe/src/pxe_service/index.ts rename yarn-project/pxe/src/{aztec_rpc_server/aztec_rpc_server.ts => pxe_service/pxe_service.ts} (96%) rename yarn-project/pxe/src/{aztec_rpc_server/test/aztec_rpc_server.test.ts => pxe_service/test/pxe_service.test.ts} (74%) rename yarn-project/pxe/src/{aztec_rpc_server/test/aztec_rpc_test_suite.ts => pxe_service/test/pxe_test_suite.ts} (75%) rename yarn-project/types/src/interfaces/{aztec_rpc.ts => pxe.ts} (91%) diff --git a/.circleci/config.yml b/.circleci/config.yml index fb5fc534ad2..b05b90cf172 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -520,7 +520,7 @@ jobs: name: "Build" command: build end-to-end - e2e-2-rpc-servers: + e2e-2-pxes: machine: image: ubuntu-2204:2023.07.2 resource_class: large @@ -529,7 +529,7 @@ jobs: - *setup_env - run: name: "Test" - command: cond_run_script end-to-end ./scripts/run_tests_local e2e_2_rpc_servers.test.ts + command: cond_run_script end-to-end ./scripts/run_tests_local e2e_2_pxes.test.ts e2e-multiple-accounts-1-enc-key: machine: @@ -826,7 +826,7 @@ jobs: - *setup_env - run: name: "Test" - command: cond_run_script end-to-end ./scripts/run_tests_local aztec_rpc_sandbox.test.ts ./scripts/docker-compose-e2e-sandbox.yml + command: cond_run_script end-to-end ./scripts/run_tests_local pxe_sandbox.test.ts ./scripts/docker-compose-e2e-sandbox.yml cli-docs-sandbox: machine: @@ -1186,7 +1186,7 @@ workflows: - canary <<: *defaults - - e2e-2-rpc-servers: *e2e_test + - e2e-2-pxes: *e2e_test - e2e-deploy-contract: *e2e_test - e2e-lending-contract: *e2e_test - e2e-token-contract: *e2e_test @@ -1223,7 +1223,7 @@ workflows: - e2e-end: requires: - - e2e-2-rpc-servers + - e2e-2-pxes - e2e-deploy-contract - e2e-lending-contract - e2e-token-contract diff --git a/README.md b/README.md index c6ce2670977..bf141bfea78 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ All the packages that make up [Aztec](https://docs.aztec.network). - [Aztec.nr](./yarn-project/aztec-nr/): A [Noir](https://noir-lang.org) framework for smart contracts on Aztec. - [Aztec Sandbox](./yarn-project/aztec-sandbox/): A package for setting up a local dev net, including a local Ethereum network, deployed rollup contracts and Aztec execution environment. -- [Aztec.js](./yarn-project/aztec.js/): A tool for interacting with the Aztec network. It communicates via the [Aztec RPC Server](./yarn-project/pxe/). +- [Aztec.js](./yarn-project/aztec.js/): A tool for interacting with the Aztec network. It communicates via the [Private Execution Environment (PXE)](./yarn-project/pxe/). - [Aztec Boxes](./yarn-project/boxes/): A minimal framework for building full stack applications for Aztec (using React). - [Example contracts](./yarn-project/noir-contracts/): Example contracts for the Aztec network, written in Noir. - [End to end tests](./yarn-project/end-to-end/): Integration tests writted in Typescript--a good reference for how to use the packages for specific tasks. diff --git a/docs/docs/about_aztec/roadmap/features_initial_ldt.md b/docs/docs/about_aztec/roadmap/features_initial_ldt.md index 73c4ac3ee91..34b86912cba 100644 --- a/docs/docs/about_aztec/roadmap/features_initial_ldt.md +++ b/docs/docs/about_aztec/roadmap/features_initial_ldt.md @@ -64,7 +64,7 @@ A typescript wrapper for making RPC calls to an Aztec Sandbox node. See the sour A bundle of packages which emulate the actions of all eventual Aztec network participants. The goal is for developer experience to be akin to Ganache / Anvil. -- Aztec RPC Client +- PXE client - Simulate and/or execute private functions locally. - Aztec Public Node - Broadcasts a user's txs to the tx pool. diff --git a/docs/docs/concepts/foundation/accounts/keys.md b/docs/docs/concepts/foundation/accounts/keys.md index 2fb19d87860..71c77d1336d 100644 --- a/docs/docs/concepts/foundation/accounts/keys.md +++ b/docs/docs/concepts/foundation/accounts/keys.md @@ -74,7 +74,7 @@ An application in Aztec.nr can access the encryption public key for a given addr #include_code encrypted /yarn-project/aztec-nr/value-note/src/utils.nr rust :::info -In order to be able to provide the public encryption key for a given address, that public key needs to have been registered in advance. At the moment, there is no broadcasting mechanism for public keys, which means that you will need to manually register all addresses you intend to send encrypted notes to. You can do this via the `registerRecipient` method of the Aztec RPC server, callable either via aztec.js or the CLI. Note that any accounts you own that have been added to the RPC server are automatically registered. +In order to be able to provide the public encryption key for a given address, that public key needs to have been registered in advance. At the moment, there is no broadcasting mechanism for public keys, which means that you will need to manually register all addresses you intend to send encrypted notes to. You can do this via the `registerRecipient` method of the Private Execution Environment (PXE), callable either via aztec.js or the CLI. Note that any accounts you own that have been added to the RPC server are automatically registered. ::: ### Nullifier secrets diff --git a/docs/docs/dev_docs/cli/main.md b/docs/docs/dev_docs/cli/main.md index 363677b4c2e..4836fad27a3 100644 --- a/docs/docs/dev_docs/cli/main.md +++ b/docs/docs/dev_docs/cli/main.md @@ -36,7 +36,7 @@ Once installed it is invoked via: ## I have the Sandbox running, now what? -Lets first establish that we are able to communicate with the Sandbox. Most commands will require the url to the Sandbox, which defaults in the CLI to `http://localhost:8080`. You can override this as an option with each command or by setting `AZTEC_RPC_HOST` environment variable. +Lets first establish that we are able to communicate with the Sandbox. Most commands will require the url to the Sandbox, which defaults in the CLI to `http://localhost:8080`. You can override this as an option with each command or by setting `PXE_HOST` environment variable. To test communication with the Sandbox, let's run the command: @@ -124,7 +124,7 @@ The `call` command calls a read-only method on a contract, one that will not gen - `--contract-abi` - The abi of the contract we are calling. - `--contract-address` - The address of the deployed contract -As you can see from the result, this address has a balance of 1000000, as expected. When using the Sandbox, you are able to query the balance of any account that has been created in the system, even the accounts created by default. You may wonder why this is, as you haven't provided the private keys for these accounts. The Sandbox contains a component known as the AztecRPCServer. When an account is created, this component stores the provided encryption private key and is able to read the account's private state meaning that the Sandbox can report the balance of any of it's accounts. More information about the account model can be found [here](../../concepts/foundation/accounts/main.md). +As you can see from the result, this address has a balance of 1000000, as expected. When using the Sandbox, you are able to query the balance of any account that has been created in the system, even the accounts created by default. You may wonder why this is, as you haven't provided the private keys for these accounts. The Sandbox contains a component known as the Private Execution Environment (PXE). When an account is created, this component stores the provided encryption private key and is able to read the account's private state meaning that the Sandbox can report the balance of any of it's accounts. More information about the account model can be found [here](../../concepts/foundation/accounts/main.md). ## Sending a Transaction diff --git a/docs/docs/dev_docs/contracts/common_errors.md b/docs/docs/dev_docs/contracts/common_errors.md index cefaa8535fb..c73607e8107 100644 --- a/docs/docs/dev_docs/contracts/common_errors.md +++ b/docs/docs/dev_docs/contracts/common_errors.md @@ -15,34 +15,34 @@ Simulation error: Assertion failed: Balance too low 'sum == amount' To address the error. find the line in the contract that is throwing the error and investigate why the condition is not met. ### Unknown Contract Error -This error occurs when you are trying to interact with a smart contract via an Aztec RPC Server that does not have the necessary information to execute a transaction. +This error occurs when you are trying to interact with a smart contract via an Private Execution Environment (PXE) that does not have the necessary information to execute a transaction. This is what the error typically looks like: ``` -Unknown contract 0x1d206be10b873b78b875259e1a8c39e2212e2f181d2fd0b0407446487deba522: add it to Aztec RPC server by calling server.addContracts(...) +Unknown contract 0x1d206be10b873b78b875259e1a8c39e2212e2f181d2fd0b0407446487deba522: add it to PXE by calling server.addContracts(...) ``` -To execute a transaction, the Aztec RPC Server needs to know the complete address of a contract, portal address (if portal is used) and contract artifacts. +To execute a transaction, the PXE needs to know the complete address of a contract, portal address (if portal is used) and contract artifacts. -To address the error, add the contract to the Aztec RPC Server by calling `server.addContracts(...)`. +To address the error, add the contract to the PXE by calling `server.addContracts(...)`. ### Unknown Complete Address Error -This error occurs when your contract is trying to get a public key via the `get_public_key` oracle call, but the Aztec RPC Server does not have the Complete Address (Complete Address contains the public key). +This error occurs when your contract is trying to get a public key via the `get_public_key` oracle call, but the PXE does not have the Complete Address (Complete Address contains the public key). This is what the error typically looks like: ``` -Simulation error: Unknown complete address for address 0x0d179a5f9bd4505f7dfb8ca37d64e0bd0cd31b5cb018e252fd647bdf88959b95. Add the information to Aztec RPC server by calling server.registerRecipient(...) or server.registerAccount(...) +Simulation error: Unknown complete address for address 0x0d179a5f9bd4505f7dfb8ca37d64e0bd0cd31b5cb018e252fd647bdf88959b95. Add the information to PXE by calling pxe.registerRecipient(...) or pxe.registerAccount(...) ``` Your contract typically needs a public key when it wants to send a note to a recipient because the public key is used to encrypt notes. :::info -Manually adding the recipient to the Aztec RPC Server should not be required in case the recipient contract has already been deployed and the Aztec RPC Server is fully synced. +Manually adding the recipient to the PXE should not be required in case the recipient contract has already been deployed and the PXE is fully synced. This is because this information is submitted on-chain when the recipient contract is deployed. ::: ### Unknown account -This error occurs when your contract is trying to get a secret via the `get_secret` oracle call, but the Aztec RPC Server does not have the secret for the public key. +This error occurs when your contract is trying to get a secret via the `get_secret` oracle call, but the PXE does not have the secret for the public key. This is what the error typically looks like: ``` diff --git a/docs/docs/dev_docs/contracts/compiling.md b/docs/docs/dev_docs/contracts/compiling.md index ac14588acfb..a9c1a346954 100644 --- a/docs/docs/dev_docs/contracts/compiling.md +++ b/docs/docs/dev_docs/contracts/compiling.md @@ -54,7 +54,7 @@ export class PrivateTokenContract extends ContractBase { public static async at(address: AztecAddress, wallet: Wallet) { ... } /** Creates a tx to deploy a new instance of this contract. */ - public static deploy(rpc: AztecRPC, initial_supply: FieldLike, owner: FieldLike) { ... } + public static deploy(pxe: PXE, initial_supply: FieldLike, owner: FieldLike) { ... } /** Type-safe wrappers for the public methods exposed by the contract. */ public methods!: { diff --git a/docs/docs/dev_docs/contracts/deploying.md b/docs/docs/dev_docs/contracts/deploying.md index a2e5795a8f9..0753fa10c61 100644 --- a/docs/docs/dev_docs/contracts/deploying.md +++ b/docs/docs/dev_docs/contracts/deploying.md @@ -41,7 +41,7 @@ Now you can import it to easily deploy and interact with the contract. ```ts import { ExampleContract } from './Example.js'; -const tx = ExampleContract.deploy(aztecRpc).send(); +const tx = ExampleContract.deploy(pxe).send(); await tx.wait({ interval: 0.5 }); const receipt = await tx.getReceipt(); const exampleContract = await ExampleContract.at(receipt.contractAddress!, myWallet); @@ -58,7 +58,7 @@ There are several optional arguments that can be passed: The command also takes the following optional arguments: - `-args ` (default: `[]`): Arguments to pass to the contract constructor. -- `--rpc-url ` (default: `http://localhost:8080`): URL of the Aztec node to connect to. +- `--rpc-url ` (default: `http://localhost:8080`): URL of the PXE to connect to. - `--public-key ` (default: `undefined`): Optional encryption public key for this contract. Set this only if this contract is expected to receive private notes (in such a case the public key is used during the note encryption). - `--salt ` (default: random value): Hexadecimal string used when computing the contract address of the contract being deployed. @@ -69,7 +69,7 @@ Set it, if you need a deterministic contract address (same functionality as Ethe The `deploy(...)` method is generated automatically with the typescript class representing your contract. -Its arguments are `AztecRPC` client and contract constructor arguments. +Its arguments are `PXE` client and contract constructor arguments. Additionally the `.send()` method can have a few optional arguments too, which are specified in an optional object: - `portalContract?: EthAddress`: The L1 portal address to link the contract to. See the section on [Portals to learn more about them](./portals/main.md). @@ -78,7 +78,7 @@ By default is set to a random value. Set it, if you need a deterministic contract address (same functionality as Ethereum's `CREATE2` opcode). ```ts -const tx = ExampleContract.deploy(aztecRpc).send({ +const tx = ExampleContract.deploy(pxe).send({ portalContract: EthAddress.from("0x1234..."), contractAddressSalt: new Fr(3n), }); @@ -91,7 +91,7 @@ const tx = ExampleContract.deploy(aztecRpc).send({ To give you a more complete example we will deploy the `PrivateToken` contract whose artifacts are included in the `@aztec/noir-contracts` package. The contract has `initial_supply` and `owner` as constructor arguments. -Because the contract sends a note to the owner specified inside the constructor, we need their public key to encrypt the note with. For this, we first need to register the owner as a recipient inside the Aztec RPC with the following command: +Because the contract sends a note to the owner specified inside the constructor, we need their public key to encrypt the note with. For this, we first need to register the owner as a recipient inside the PXE with the following command: @@ -109,18 +109,18 @@ const publicKey = Point.fromString("0x26e193aef4f83c70651485b5526c6d01a36d763223 const partialAddress = Fr.fromString("0x200e9a6c2d2e8352012e51c6637659713d336405c29386c7c4ac56779ab54fa7"); const completeAddress = CompleteAddress.create(aztecAddress, publicKey, partialKey); -await aztecRpc.registerRecipient(completeAddress); +await pxe.registerRecipient(completeAddress); ``` -When you create a new account, it gets automatically registered. It can be verified by calling `aztec-cli get-accounts` OR in aztec.js by using `await aztecRpc.getRegisteredAccounts()` +When you create a new account, it gets automatically registered. It can be verified by calling `aztec-cli get-accounts` OR in aztec.js by using `await pxe.getRegisteredAccounts()` > **NOTE 1**: If we didn't register owner as a recipient we could not encrypt a note for the owner and the contract deployment would fail because constructor execution would fail (we need owner's public key to encrypt a note). -> **NOTE 2**: If a note recipient is one of the accounts inside the Aztec RPC, we don't need to register it as a recipient because we already have the public key available. +> **NOTE 2**: If a note recipient is one of the accounts inside the PXE, we don't need to register it as a recipient because we already have the public key available. Once the recipient is registered we can deploy the contract: diff --git a/docs/docs/dev_docs/contracts/syntax/events.md b/docs/docs/dev_docs/contracts/syntax/events.md index c50526530f0..77bd761d968 100644 --- a/docs/docs/dev_docs/contracts/syntax/events.md +++ b/docs/docs/dev_docs/contracts/syntax/events.md @@ -15,7 +15,7 @@ Unlike on Ethereum, there are 2 types of events supported by Aztec: encrypted an ## Encrypted Events Encrypted events can only be emitted by private functions and are encrypted using a public key of a recipient. -For this reason it is necessary to register a recipient in the Aztec RPC Server before encrypting the events for them. +For this reason it is necessary to register a recipient in the Private Execution Environment (PXE) before encrypting the events for them. Recipients can be registered using the Aztec CLI or Aztec.js: import Tabs from '@theme/Tabs'; @@ -47,18 +47,18 @@ const completeAddress = CompleteAddress.create( publicKey, partialKey ); -await aztecRpc.registerRecipient(completeAddress); +await pxe.registerRecipient(completeAddress); ``` :::info -If a note recipient is one of the accounts inside the Aztec RPC Server, we don't need to register it as a recipient because we already have the public key available. You can register a recipient as shown [here](../deploying#deploying-private-token-contract) +If a note recipient is one of the accounts inside the PXE, we don't need to register it as a recipient because we already have the public key available. You can register a recipient as shown [here](../deploying#deploying-private-token-contract) At this point the Sandbox only enables the emitting of encrypted note preimages through encrypted events. In the future we will allow emitting arbitrary information. -(If you currently emit arbitrary information, Aztec RPC Server will fail to decrypt, process and store this data, so it will not be queryable). +(If you currently emit arbitrary information, PXE will fail to decrypt, process and store this data, so it will not be queryable). ::: To emit encrypted logs first import the `emit_encrypted_log` utility function which wraps an [oracle](./functions.md#oracle-functions): @@ -71,19 +71,19 @@ Then you can call the function: ### Processing Encrypted Events -One of the functions of the Aztec RPC Server is constantly loading encrypted logs from the `AztecNode` and decrypting them. -When new encrypted logs are obtained, the Aztec RPC Server will try to decrypt them using the private encryption key of all the accounts registered inside Aztec RPC Server. -If the decryption is successful, the Aztec RPC Server will store the decrypted note inside a database. +One of the functions of the PXE is constantly loading encrypted logs from the `AztecNode` and decrypting them. +When new encrypted logs are obtained, the PXE will try to decrypt them using the private encryption key of all the accounts registered inside PXE. +If the decryption is successful, the PXE will store the decrypted note inside a database. If the decryption fails, the specific log will be discarded. -For the Aztec RPC Server to successfully process the decrypted note we need to compute the note's 'note hash' and 'nullifier'. -Aztec.nr enables smart contract developers to design custom notes, meaning developers can also customize how a note's note hash and nullifier should be computed. Because of this customizability, and because there will be a potentially-unlimited number of smart contracts deployed to Aztec, an Aztec RPC Server needs to be 'taught' how to compute the custom note hashes and nullifiers for a particular contract. Therefore, developers will need to implement a `compute_note_hash_and_nullifier` function inside their contracts. +For the PXE to successfully process the decrypted note we need to compute the note's 'note hash' and 'nullifier'. +Aztec.nr enables smart contract developers to design custom notes, meaning developers can also customize how a note's note hash and nullifier should be computed. Because of this customizability, and because there will be a potentially-unlimited number of smart contracts deployed to Aztec, an PXE needs to be 'taught' how to compute the custom note hashes and nullifiers for a particular contract. Therefore, developers will need to implement a `compute_note_hash_and_nullifier` function inside their contracts. :::danger If your function has private state variables, you **MUST** include a `compute_note_hash_and_nullifier` function to allow the RPC to process encrypted events. ::: -Every time a new note is successfully decrypted, the Aztec RPC Server will expect the existence of a `compute_note_hash_and_nullifier` function, which must teach it how to correctly process the new note. +Every time a new note is successfully decrypted, the PXE will expect the existence of a `compute_note_hash_and_nullifier` function, which must teach it how to correctly process the new note. #include_code compute_note_hash_and_nullifier /yarn-project/noir-contracts/src/contracts/token_contract/src/main.nr rust diff --git a/docs/docs/dev_docs/contracts/syntax/functions.md b/docs/docs/dev_docs/contracts/syntax/functions.md index 32ef5f908ea..f6a9197a79f 100644 --- a/docs/docs/dev_docs/contracts/syntax/functions.md +++ b/docs/docs/dev_docs/contracts/syntax/functions.md @@ -114,7 +114,7 @@ Oracles introduce **non-determinism** into a circuit, and thus are `unconstraine ### Private -> Private In Aztec Private to Private function calls are handled by the [private kernel circuit](../../../concepts/advanced/circuits/kernels/private_kernel.md), and take place on the user's device. -Behind the scenes, the `Aztec RPC Server` (the beating heart of Aztec that runs in your wallet) will execute all of the functions in the desired order "simulating" them in sequence. For example, a very common use-case of Private to Private interaction is calling another private function from an `account contract` (Account contracts are a general concept, more information about them can be found [here](../../wallets/writing_an_account_contract.md)). +Behind the scenes, the `Private Execution Environment (PXE)` (the beating heart of Aztec that runs in your wallet) will execute all of the functions in the desired order "simulating" them in sequence. For example, a very common use-case of Private to Private interaction is calling another private function from an `account contract` (Account contracts are a general concept, more information about them can be found [here](../../wallets/writing_an_account_contract.md)). Take, for example, the following call stack: diff --git a/docs/docs/dev_docs/getting_started/quickstart.md b/docs/docs/dev_docs/getting_started/quickstart.md index ded6297b25e..48735d70aa0 100644 --- a/docs/docs/dev_docs/getting_started/quickstart.md +++ b/docs/docs/dev_docs/getting_started/quickstart.md @@ -15,8 +15,8 @@ This is a 1 page introduction to getting started with running the sandbox, and i Aztec's Layer 2 network is a fully programmable combined private/public ZK rollup. To achieve this, the network contains the following primary components: - Aztec Node - Aggregates all of the 'backend' services necessary for the building and publishing of rollups. This packages is currently in development and much of the functionality is mocked. -- [Aztec RPC Server](https://github.com/AztecProtocol/aztec-packages/tree/master/yarn-project/pxe) - Normally residing with the end client, this decrypts and stores a client's private state, executes simulations and submits transactions to the Aztec Node. -- [Aztec.js](https://github.com/AztecProtocol/aztec-packages/tree/master/yarn-project/aztec.js) - Aztec's client library for interacting with the Aztec RPC Server (think Ethers.js). See the getting started guide [here](./sandbox.md). +- [Private Execution Environment (PXE)](https://github.com/AztecProtocol/aztec-packages/tree/master/yarn-project/pxe) - Normally residing with the end client, this decrypts and stores a client's private state, executes simulations and submits transactions to the Aztec Node. +- [Aztec.js](https://github.com/AztecProtocol/aztec-packages/tree/master/yarn-project/aztec.js) - Aztec's client library for interacting with the PXE (think Ethers.js). See the getting started guide [here](./sandbox.md). All of this is included in the Sandbox, with the exception of Aztec.js which you can use to interact with it. @@ -114,7 +114,7 @@ Congratulations! You are all set up with the Aztec sandbox! Aztec's Layer 2 network is a fully programmable combined private/public ZK rollup. To achieve this, the network contains the following primary components: - Aztec Node - Aggregates all of the 'backend' services necessary for the building and publishing of rollups. -- Aztec RPC Server - Normally residing with the end client, this decrypts and stores a client's private state, executes simulations and submits transactions to the Aztec Node. -- [Aztec.js](./sandbox) - Aztec's client library for interacting with the Aztec RPC Server (think Ethers.js). +- Private Execution Environment (PXE) - Normally residing with the end client, this decrypts and stores a client's private state, executes simulations and submits transactions to the Aztec Node. +- [Aztec.js](./sandbox) - Aztec's client library for interacting with the PXE (think Ethers.js). - [Aztec.nr](../contracts/main.md) - Aztec's smart contract framework diff --git a/docs/docs/dev_docs/testing/cheat_codes.md b/docs/docs/dev_docs/testing/cheat_codes.md index 3fd12b18325..beab249668b 100644 --- a/docs/docs/dev_docs/testing/cheat_codes.md +++ b/docs/docs/dev_docs/testing/cheat_codes.md @@ -28,10 +28,10 @@ For this guide, the following Aztec packages are used: ### Initialisation ```ts -import { createAztecRpcClient, CheatCodes } from "@aztec/aztec.js"; -const aztecRpcUrl = "http://localhost:8080"; -const aztecRpcClient = createAztecRpcClient(aztecRpcUrl); -const cc = await CheatCodes.create(aztecRpcUrl, aztecRpcClient); +import { createPXEClient, CheatCodes } from "@aztec/aztec.js"; +const pxeRpcUrl = "http://localhost:8080"; +const pxe = createPXEClient(pxeRpcUrl); +const cc = await CheatCodes.create(pxeRpcUrl, pxe); ``` There are two properties of the CheatCodes class - `eth` and `aztec` for cheatcodes relating to the Ethereum blockchain (L1) and the Aztec network (L2) respectively. diff --git a/docs/docs/dev_docs/tutorials/testing.md b/docs/docs/dev_docs/tutorials/testing.md index e00bccd1a81..aa91c19fc66 100644 --- a/docs/docs/dev_docs/tutorials/testing.md +++ b/docs/docs/dev_docs/tutorials/testing.md @@ -12,7 +12,7 @@ Let's start with a simple example for a test using the [Sandbox](../getting_star #include_code sandbox-example /yarn-project/end-to-end/src/guides/dapp_testing.test.ts typescript -This test sets up the environment by creating a client to the Aztec RPC server running on the Sandbox on port 8080. It then creates two new accounts, dubbed `owner` and `recipient`. Last, it deploys an instance of the [`PrivateTokenContract`](https://github.com/AztecProtocol/aztec-packages/blob/master/yarn-project/noir-contracts/src/contracts/private_token_contract/src/main.nr), minting an initial 100 tokens to the owner. +This test sets up the environment by creating a client to the Private Execution Environment (PXE) running on the Sandbox on port 8080. It then creates two new accounts, dubbed `owner` and `recipient`. Last, it deploys an instance of the [`PrivateTokenContract`](https://github.com/AztecProtocol/aztec-packages/blob/master/yarn-project/noir-contracts/src/contracts/private_token_contract/src/main.nr), minting an initial 100 tokens to the owner. Once we have this setup, the test itself is simple. We check the balance of the `recipient` user to ensure it has no tokens, send and await a deployment transaction, and then check the balance again to ensure it was increased. Note that all numeric values are represented as [native bigints](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt) to avoid loss of precision. @@ -23,36 +23,36 @@ We are using the `PrivateTokenContract` [typescript interface](../contracts/comp To run the test, first make sure the Sandbox is running on port 8080, and then [run your tests using jest](https://jestjs.io/docs/getting-started#running-from-command-line). Your test should pass, and you should see the following output in the Sandbox logs, where each chunk corresponds to a transaction. Note how this test run has a total of four transactions: two for deploying the account contracts for the `owner` and `recipient`, another for deploying the token contract, and a last one for actually executing the transfer. ```text -rpc_server Registered account 0x2efa51d2e67581aef4578e8cc647a1af2e3f40e9872deeda0919e5f77cb8b2d2 -rpc_server Added contract SchnorrAccount at 0x2efa51d2e67581aef4578e8cc647a1af2e3f40e9872deeda0919e5f77cb8b2d2 +pxe_service Registered account 0x2efa51d2e67581aef4578e8cc647a1af2e3f40e9872deeda0919e5f77cb8b2d2 +pxe_service Added contract SchnorrAccount at 0x2efa51d2e67581aef4578e8cc647a1af2e3f40e9872deeda0919e5f77cb8b2d2 node Simulating tx 19bfe4fb2569be2168f01eefe5e5a4284d6c1678f17ab5e94c6ba9c811bcb214 node Simulated tx 19bfe4fb2569be2168f01eefe5e5a4284d6c1678f17ab5e94c6ba9c811bcb214 succeeds -rpc_server Executed local simulation for 19bfe4fb2569be2168f01eefe5e5a4284d6c1678f17ab5e94c6ba9c811bcb214 -rpc_server Sending transaction 19bfe4fb2569be2168f01eefe5e5a4284d6c1678f17ab5e94c6ba9c811bcb214 +pxe_service Executed local simulation for 19bfe4fb2569be2168f01eefe5e5a4284d6c1678f17ab5e94c6ba9c811bcb214 +pxe_service Sending transaction 19bfe4fb2569be2168f01eefe5e5a4284d6c1678f17ab5e94c6ba9c811bcb214 node Received tx 19bfe4fb2569be2168f01eefe5e5a4284d6c1678f17ab5e94c6ba9c811bcb214 sequencer Submitted rollup block 2 with 1 transactions -rpc_server Registered account 0x12ef7ceb5064da3a729f598a6a50585059794fdcf347a6fc9bb317002162e3db -rpc_server Added contract SchnorrAccount at 0x12ef7ceb5064da3a729f598a6a50585059794fdcf347a6fc9bb317002162e3db +pxe_service Registered account 0x12ef7ceb5064da3a729f598a6a50585059794fdcf347a6fc9bb317002162e3db +pxe_service Added contract SchnorrAccount at 0x12ef7ceb5064da3a729f598a6a50585059794fdcf347a6fc9bb317002162e3db node Simulating tx 0f195f8f6fb8fe29cf8159c5c664c1288788f1151a5413ec0e35cf378de74794 node Simulated tx 0f195f8f6fb8fe29cf8159c5c664c1288788f1151a5413ec0e35cf378de74794 succeeds -rpc_server Executed local simulation for 0f195f8f6fb8fe29cf8159c5c664c1288788f1151a5413ec0e35cf378de74794 -rpc_server Sending transaction 0f195f8f6fb8fe29cf8159c5c664c1288788f1151a5413ec0e35cf378de74794 +pxe_service Executed local simulation for 0f195f8f6fb8fe29cf8159c5c664c1288788f1151a5413ec0e35cf378de74794 +pxe_service Sending transaction 0f195f8f6fb8fe29cf8159c5c664c1288788f1151a5413ec0e35cf378de74794 node Received tx 0f195f8f6fb8fe29cf8159c5c664c1288788f1151a5413ec0e35cf378de74794 sequencer Submitted rollup block 3 with 1 transactions -rpc_server Added contract PrivateToken at 0x24e691d8bde970ab9e84fe669ea5ac8019c32c199a55aaa8a3e704db763af88f +pxe_service Added contract PrivateToken at 0x24e691d8bde970ab9e84fe669ea5ac8019c32c199a55aaa8a3e704db763af88f node Simulating tx 0101e1a3d73c3a112a18b7e4954edfe611d74ae0dc59e1688221ecda982ba943 node Simulated tx 0101e1a3d73c3a112a18b7e4954edfe611d74ae0dc59e1688221ecda982ba943 succeeds -rpc_server Executed local simulation for 0101e1a3d73c3a112a18b7e4954edfe611d74ae0dc59e1688221ecda982ba943 -rpc_server Sending transaction 0101e1a3d73c3a112a18b7e4954edfe611d74ae0dc59e1688221ecda982ba943 +pxe_service Executed local simulation for 0101e1a3d73c3a112a18b7e4954edfe611d74ae0dc59e1688221ecda982ba943 +pxe_service Sending transaction 0101e1a3d73c3a112a18b7e4954edfe611d74ae0dc59e1688221ecda982ba943 node Received tx 0101e1a3d73c3a112a18b7e4954edfe611d74ae0dc59e1688221ecda982ba943 sequencer Submitted rollup block 4 with 1 transactions node Simulating tx 2132767911fbbe67e24a3e51bc769ba2ae874eb1ba56e69cef8fc9e2c5eba04c node Simulated tx 2132767911fbbe67e24a3e51bc769ba2ae874eb1ba56e69cef8fc9e2c5eba04c succeeds -rpc_server Executed local simulation for 2132767911fbbe67e24a3e51bc769ba2ae874eb1ba56e69cef8fc9e2c5eba04c -rpc_server Sending transaction 2132767911fbbe67e24a3e51bc769ba2ae874eb1ba56e69cef8fc9e2c5eba04c +pxe_service Executed local simulation for 2132767911fbbe67e24a3e51bc769ba2ae874eb1ba56e69cef8fc9e2c5eba04c +pxe_service Sending transaction 2132767911fbbe67e24a3e51bc769ba2ae874eb1ba56e69cef8fc9e2c5eba04c node Received tx 2132767911fbbe67e24a3e51bc769ba2ae874eb1ba56e69cef8fc9e2c5eba04c sequencer Submitted rollup block 5 with 1 transactions ``` diff --git a/docs/docs/dev_docs/tutorials/writing_dapp/contract_deployment.md b/docs/docs/dev_docs/tutorials/writing_dapp/contract_deployment.md index 34ce039738d..6b90304d4d3 100644 --- a/docs/docs/dev_docs/tutorials/writing_dapp/contract_deployment.md +++ b/docs/docs/dev_docs/tutorials/writing_dapp/contract_deployment.md @@ -67,7 +67,7 @@ Create a new file `src/deploy.mjs`: ```js // src/deploy.mjs import { writeFileSync } from 'fs'; -import { Contract, ContractDeployer, createAztecRpcClient, getSandboxAccountsWallets } from '@aztec/aztec.js'; +import { Contract, ContractDeployer, createPXEClient, getSandboxAccountsWallets } from '@aztec/aztec.js'; import TokenContractAbi from "../contracts/token/target/Token.json" assert { type: "json" }; #include_code dapp-deploy yarn-project/end-to-end/src/sample-dapp/deploy.mjs raw diff --git a/docs/docs/dev_docs/tutorials/writing_dapp/project_setup.md b/docs/docs/dev_docs/tutorials/writing_dapp/project_setup.md index 02cb3be2de5..68a0e820300 100644 --- a/docs/docs/dev_docs/tutorials/writing_dapp/project_setup.md +++ b/docs/docs/dev_docs/tutorials/writing_dapp/project_setup.md @@ -28,4 +28,4 @@ yarn add @aztec/aztec.js ## Next steps -With your project already set up, let's [connect to the Sandbox RPC Server and grab an account to interact with it](./rpc_server.md). +With your project already set up, let's [connect to the Sandbox RPC Server and grab an account to interact with it](./pxe_service.md). diff --git a/docs/docs/dev_docs/tutorials/writing_dapp/rpc_server.md b/docs/docs/dev_docs/tutorials/writing_dapp/pxe_service.md similarity index 74% rename from docs/docs/dev_docs/tutorials/writing_dapp/rpc_server.md rename to docs/docs/dev_docs/tutorials/writing_dapp/pxe_service.md index fd759beee27..283a0466900 100644 --- a/docs/docs/dev_docs/tutorials/writing_dapp/rpc_server.md +++ b/docs/docs/dev_docs/tutorials/writing_dapp/pxe_service.md @@ -1,6 +1,6 @@ # Connecting to the RPC Server -As an app developer, the [Aztec RPC Server](https://github.com/AztecProtocol/aztec-packages/tree/master/yarn-project/pxe) interface provides you with access to the user's accounts and their private state, as well as a connection to the network for accessing public global state. +As an app developer, the [Private Execution Environment (PXE)](https://github.com/AztecProtocol/aztec-packages/tree/master/yarn-project/pxe) interface provides you with access to the user's accounts and their private state, as well as a connection to the network for accessing public global state. During the Sandbox phase, this role is fulfilled by the [Aztec Sandbox](../../getting_started/sandbox.md), which runs a local RPC Server and an Aztec Node, both connected to a local Ethereum development node like Anvil. The Sandbox also includes a set of pre-initialized accounts that you can use from your app. @@ -8,7 +8,7 @@ In this section, we'll connect to the Sandbox from our project. ## Create RPC client -We'll use the `createAztecRpcClient` function from `aztec.js` to connect to the Sandbox, which by default runs on `localhost:8080`. To test the connection works, we'll request and print the node's chain id. +We'll use the `createPXEClient` function from `aztec.js` to connect to the Sandbox, which by default runs on `localhost:8080`. To test the connection works, we'll request and print the node's chain id. Let's create our first file `src/index.mjs` with the following contents: diff --git a/docs/docs/dev_docs/tutorials/writing_token_contract.md b/docs/docs/dev_docs/tutorials/writing_token_contract.md index afac795f6cc..2f7f052549c 100644 --- a/docs/docs/dev_docs/tutorials/writing_token_contract.md +++ b/docs/docs/dev_docs/tutorials/writing_token_contract.md @@ -455,7 +455,7 @@ A getter function for checking the token `total_supply`. #### `balance_of_private` -A getter function for checking the private balance of the provided Aztec account. Note that the [Aztec RPC Server](https://github.com/AztecProtocol/aztec-packages/tree/master/yarn-project/pxe) must have access to the `owner`s decryption keys in order to decrypt their notes. +A getter function for checking the private balance of the provided Aztec account. Note that the [Private Execution Environment (PXE)](https://github.com/AztecProtocol/aztec-packages/tree/master/yarn-project/pxe) must have access to the `owner`s decryption keys in order to decrypt their notes. #include_code balance_of_private /yarn-project/noir-contracts/src/contracts/token_contract/src/main.nr rust diff --git a/docs/docs/dev_docs/wallets/architecture.md b/docs/docs/dev_docs/wallets/architecture.md index 736f9d0896f..55de4c160be 100644 --- a/docs/docs/dev_docs/wallets/architecture.md +++ b/docs/docs/dev_docs/wallets/architecture.md @@ -4,7 +4,7 @@ Wallets expose to dapps an interface that allows them to act on behalf of the us ## Overview -Architecture-wise, a wallet is an instance of an **Aztec RPC Server** which manages user keys and private state. The RPC server also communicates with an **Aztec Node** for retrieving public information or broadcasting transactions. Note that the RPC server requires a local database for keeping private state, and is also expected to be continuously syncing new blocks for trial-decryption of user notes. +Architecture-wise, a wallet is an instance of an **Private Execution Environment (PXE)** which manages user keys and private state. The RPC server also communicates with an **Aztec Node** for retrieving public information or broadcasting transactions. Note that the RPC server requires a local database for keeping private state, and is also expected to be continuously syncing new blocks for trial-decryption of user notes. Additionally, a wallet must be able to handle one or more [account contract implementations](../../concepts/foundation/accounts/main.md#account-contracts-and-wallets). When a user creates a new account, the account is represented on-chain by an account contract. The wallet is responsible for deploying and interacting with this contract. A wallet may support multiple flavours of accounts, such as an account that uses ECDSA signatures, or one that relies on WebAuthn, or one that requires multi-factor authentication. For a user, the choice of what account implementation to use is then determined by the wallet they interact with. @@ -18,11 +18,11 @@ The account interface is used for creating an _execution request_ out of one or Refer to the page on [writing an account contract](./writing_an_account_contract.md) for an example on how to implement this interface. -## RPC interface +## PXE interface -A wallet exposes the RPC interface to dapps by running an Aztec RPC Server instance. The Aztec RPC Server requires a keystore and a database implementation for storing keys, private state, and recipient encryption public keys. +A wallet exposes the PXE interface to dapps by running an PXE instance. The PXE requires a keystore and a database implementation for storing keys, private state, and recipient encryption public keys. -#include_code rpc-interface /yarn-project/types/src/interfaces/aztec_rpc.ts typescript +#include_code pxe-interface /yarn-project/types/src/interfaces/pxe.ts typescript diff --git a/docs/docs/dev_docs/wallets/writing_an_account_contract.md b/docs/docs/dev_docs/wallets/writing_an_account_contract.md index 9916cf790cb..8f14c62f1cc 100644 --- a/docs/docs/dev_docs/wallets/writing_an_account_contract.md +++ b/docs/docs/dev_docs/wallets/writing_an_account_contract.md @@ -74,7 +74,7 @@ More signing schemes are available in case you want to experiment with other typ Let's try creating a new account backed by our account contract, and interact with a simple token contract to test it works. -To create and deploy the account, we will use the `AccountManager` class, which takes an instance of an Aztec RPC server, a [privacy private key](../../concepts/foundation/accounts/keys.md#privacy-keys), and an instance of our `AccountContract` class: +To create and deploy the account, we will use the `AccountManager` class, which takes an instance of an Private Execution Environment (PXE), a [privacy private key](../../concepts/foundation/accounts/keys.md#privacy-keys), and an instance of our `AccountContract` class: #include_code account-contract-deploy yarn-project/end-to-end/src/guides/writing_an_account_contract.test.ts typescript diff --git a/docs/docusaurus.config.js b/docs/docusaurus.config.js index 11c79507e7b..19ab13a3b20 100644 --- a/docs/docusaurus.config.js +++ b/docs/docusaurus.config.js @@ -126,12 +126,12 @@ const config = { "docusaurus-plugin-typedoc", { id: "apis/pxe", - entryPoints: ["../yarn-project/types/src/interfaces/aztec_rpc.ts"], + entryPoints: ["../yarn-project/types/src/interfaces/pxe.ts"], tsconfig: "../yarn-project/types/tsconfig.json", entryPointStrategy: "expand", out: "apis/pxe", disableSources: true, - frontmatter: { sidebar_label: "Aztec RPC Server" }, + frontmatter: { sidebar_label: "Private Execution Environment (PXE)" }, }, ], [ diff --git a/docs/internal_notes/api.md b/docs/internal_notes/api.md index 113cfa1d133..d6c4767c0b6 100644 --- a/docs/internal_notes/api.md +++ b/docs/internal_notes/api.md @@ -4,6 +4,6 @@ title: API ## API Structure -- Discuss AztecRPC, it's purpose and what it's used for +- Discuss PXE, it's purpose and what it's used for - Discuss aztec.js and the generated typescript interfaces - Links to other pages within this api section diff --git a/docs/internal_notes/dev_docs/sandbox/components.md b/docs/internal_notes/dev_docs/sandbox/components.md index 0db084b6508..cc3f335c784 100644 --- a/docs/internal_notes/dev_docs/sandbox/components.md +++ b/docs/internal_notes/dev_docs/sandbox/components.md @@ -21,7 +21,7 @@ Responsibilities: - Holds and never exposes private keys. - Provides sign/decrypt functionality. -### AztecRpcClient (Previously Wallet/Private Client) +### PXEClient Responsibilities: @@ -136,13 +136,12 @@ Implementation notes for this milestone: - Exposes a single account, created by a private key given in the ctor, that defaults to some test key. - Can be used as both the spending and decryption key for early development. -### AztecRpcServer (Previously Wallet/Private Client) - +### Private Execution Environment (PXE) ![](https://hackmd.io/_uploads/ryS0sOLyh.png) Implements: -- `AztecRpcClient` (The server is a client, when used directly) +- `PXE` (The server is a client, when used directly) Injected: diff --git a/docs/sidebars.js b/docs/sidebars.js index 71f56f29406..ab75b2abe2a 100644 --- a/docs/sidebars.js +++ b/docs/sidebars.js @@ -218,7 +218,7 @@ const sidebars = { }, items: [ "dev_docs/tutorials/writing_dapp/project_setup", - "dev_docs/tutorials/writing_dapp/rpc_server", + "dev_docs/tutorials/writing_dapp/pxe_service", "dev_docs/tutorials/writing_dapp/contract_deployment", "dev_docs/tutorials/writing_dapp/contract_interaction", "dev_docs/tutorials/writing_dapp/testing", @@ -351,9 +351,9 @@ const sidebars = { type: "category", items: [ { - label: "Aztec RPC Server", + label: "Private Execution Environment (PXE)", type: "doc", - id: "apis/pxe/interfaces/AztecRPC", + id: "apis/pxe/interfaces/PXE", }, { label: "Aztec.js", diff --git a/yarn-project/aztec-node/src/bin/index.ts b/yarn-project/aztec-node/src/bin/index.ts index 7aac8514b81..9a793952ccc 100644 --- a/yarn-project/aztec-node/src/bin/index.ts +++ b/yarn-project/aztec-node/src/bin/index.ts @@ -21,7 +21,7 @@ async function createAndDeployAztecNode() { } /** - * Creates a router for helper API endpoints of the Aztec RPC Server. + * Creates a router for helper API endpoints of the Private Execution Environment (PXE). * @param apiPrefix - The prefix to use for all api requests * @returns - The router for handling status requests. */ diff --git a/yarn-project/aztec-rpc/src/bin/index.ts b/yarn-project/aztec-rpc/src/bin/index.ts deleted file mode 100644 index 80584d0a8e6..00000000000 --- a/yarn-project/aztec-rpc/src/bin/index.ts +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/env -S node --no-warnings -import { createDebugLogger } from '@aztec/foundation/log'; -import { createAztecNodeRpcClient } from '@aztec/types'; - -import { startHttpRpcServer } from '../aztec_rpc_http/index.js'; -import { createAztecRPCServer } from '../aztec_rpc_server/index.js'; -import { getConfigEnvVars } from '../config/index.js'; - -const { SERVER_PORT = 8080, AZTEC_NODE_RPC_URL = '' } = process.env; - -const logger = createDebugLogger('aztec:rpc_server'); - -/** - * Create and start a new Aztec RCP HTTP Server - */ -async function main() { - logger.info(`Setting up Aztec RPC Server...`); - - const rpcConfig = getConfigEnvVars(); - const nodeRpcClient = createAztecNodeRpcClient(AZTEC_NODE_RPC_URL); - const rpcServer = await createAztecRPCServer(nodeRpcClient, rpcConfig); - - const shutdown = async () => { - logger.info('Shutting down...'); - await rpcServer.stop(); - process.exit(0); - }; - - process.once('SIGINT', shutdown); - process.once('SIGTERM', shutdown); - - startHttpRpcServer(rpcServer, SERVER_PORT); - logger.info(`Aztec RPC Server listening on port ${SERVER_PORT}`); -} - -main().catch(err => { - logger.error(err); - process.exit(1); -}); diff --git a/yarn-project/aztec-sandbox/README.md b/yarn-project/aztec-sandbox/README.md index ed50c63fee6..92bde78b1ce 100644 --- a/yarn-project/aztec-sandbox/README.md +++ b/yarn-project/aztec-sandbox/README.md @@ -1,6 +1,6 @@ # aztec-sandbox -Aztec Sandbox is a package that allows for a simple development environment on Aztec stack. It creates an Aztec RPC server that listens for HTTP requests on `localhost:8080` by default. When started, it deploys all necessary L1 Aztec contracts and then starts listening for RPC requests. +Aztec Sandbox is a package that allows for a simple development environment on Aztec stack. It creates an Private Execution Environment (PXE) that listens for HTTP requests on `localhost:8080` by default. When started, it deploys all necessary L1 Aztec contracts and then starts listening for RPC requests. ## How to run: diff --git a/yarn-project/aztec-sandbox/docker-compose.yml b/yarn-project/aztec-sandbox/docker-compose.yml index 365e0626beb..935d0da224e 100644 --- a/yarn-project/aztec-sandbox/docker-compose.yml +++ b/yarn-project/aztec-sandbox/docker-compose.yml @@ -19,7 +19,7 @@ services: P2P_BLOCK_CHECK_INTERVAL_MS: 50 SEQ_TX_POLLING_INTERVAL_MS: 50 WS_BLOCK_CHECK_INTERVAL_MS: 50 - RPC_SERVER_BLOCK_POLLING_INTERVAL_MS: 50 + PXE_SERVICE_BLOCK_POLLING_INTERVAL_MS: 50 ARCHIVER_VIEM_POLLING_INTERVAL_MS: 500 volumes: - ./log:/usr/src/yarn-project/aztec-sandbox/log:rw diff --git a/yarn-project/aztec-sandbox/src/bin/index.ts b/yarn-project/aztec-sandbox/src/bin/index.ts index 2ab3b192b59..44387c6b36a 100644 --- a/yarn-project/aztec-sandbox/src/bin/index.ts +++ b/yarn-project/aztec-sandbox/src/bin/index.ts @@ -3,7 +3,7 @@ import { deployInitialSandboxAccounts } from '@aztec/aztec.js'; import { createDebugLogger } from '@aztec/foundation/log'; import { fileURLToPath } from '@aztec/foundation/url'; import NoirVersion from '@aztec/noir-compiler/noir-version'; -import { startHttpRpcServer } from '@aztec/pxe'; +import { startPXEHttpServer } from '@aztec/pxe'; import { readFileSync } from 'fs'; import { dirname, resolve } from 'path'; @@ -20,12 +20,12 @@ const logger = createDebugLogger('aztec:sandbox'); * Creates the sandbox from provided config and deploys any initial L1 and L2 contracts */ async function createAndInitialiseSandbox() { - const { l1Contracts, rpcServer, stop } = await createSandbox(); + const { l1Contracts, pxe, stop } = await createSandbox(); logger.info('Setting up test accounts...'); - const accounts = await deployInitialSandboxAccounts(rpcServer); + const accounts = await deployInitialSandboxAccounts(pxe); return { l1Contracts, - rpcServer, + pxe, stop, accounts, }; @@ -41,7 +41,7 @@ async function main() { logger.info(`Setting up Aztec Sandbox v${version} (nargo ${NoirVersion.tag}), please stand by...`); - const { rpcServer, stop, accounts } = await createAndInitialiseSandbox(); + const { pxe, stop, accounts } = await createAndInitialiseSandbox(); const shutdown = async () => { logger.info('Shutting down...'); @@ -52,12 +52,12 @@ async function main() { process.once('SIGINT', shutdown); process.once('SIGTERM', shutdown); - startHttpRpcServer(rpcServer, SERVER_PORT); + startPXEHttpServer(pxe, SERVER_PORT); logger.info(`Aztec Sandbox JSON-RPC Server listening on port ${SERVER_PORT}`); logger.info(`Debug logs will be written to ${logPath}`); const accountStrings = [`Initial Accounts:\n\n`]; - const registeredAccounts = await rpcServer.getRegisteredAccounts(); + const registeredAccounts = await pxe.getRegisteredAccounts(); for (const account of accounts) { const completeAddress = await account.account.getCompleteAddress(); if (registeredAccounts.find(a => a.equals(completeAddress))) { diff --git a/yarn-project/aztec-sandbox/src/examples/private_token_contract.ts b/yarn-project/aztec-sandbox/src/examples/private_token_contract.ts index d637d02d710..1617c170a08 100644 --- a/yarn-project/aztec-sandbox/src/examples/private_token_contract.ts +++ b/yarn-project/aztec-sandbox/src/examples/private_token_contract.ts @@ -3,7 +3,7 @@ import { AztecAddress, Contract, GrumpkinScalar, - createAztecRpcClient, + createPXEClient, createRecipient, getUnsafeSchnorrAccount, } from '@aztec/aztec.js'; @@ -16,7 +16,7 @@ export const privateKey = GrumpkinScalar.fromString('ac0974bec39a17e36ba4a6b4d23 const url = 'http://localhost:8080'; -const aztecRpcClient = createAztecRpcClient(url); +const pxe = createPXEClient(url); let wallet: AccountWallet; const INITIAL_BALANCE = 333n; @@ -29,7 +29,7 @@ const SECONDARY_AMOUNT = 33n; */ async function deployZKContract(owner: AztecAddress) { logger('Deploying L2 contract...'); - const contract = await PrivateTokenContract.deploy(aztecRpcClient, INITIAL_BALANCE, owner).send().deployed(); + const contract = await PrivateTokenContract.deploy(pxe, INITIAL_BALANCE, owner).send().deployed(); logger('L2 contract deployed'); return contract; } @@ -50,9 +50,9 @@ async function getBalance(contract: Contract, ownerAddress: AztecAddress) { async function main() { logger('Running ZK contract test on HTTP interface.'); - wallet = await getUnsafeSchnorrAccount(aztecRpcClient, privateKey).waitDeploy(); + wallet = await getUnsafeSchnorrAccount(pxe, privateKey).waitDeploy(); const owner = wallet.getCompleteAddress(); - const recipient = await createRecipient(aztecRpcClient); + const recipient = await createRecipient(pxe); logger(`Created Owner account ${owner.toString()}`); diff --git a/yarn-project/aztec-sandbox/src/examples/uniswap_trade_on_l1_from_l2.ts b/yarn-project/aztec-sandbox/src/examples/uniswap_trade_on_l1_from_l2.ts index 9feaa2d9b89..2f2a05b6173 100644 --- a/yarn-project/aztec-sandbox/src/examples/uniswap_trade_on_l1_from_l2.ts +++ b/yarn-project/aztec-sandbox/src/examples/uniswap_trade_on_l1_from_l2.ts @@ -4,7 +4,7 @@ import { EthAddress, Fr, computeMessageSecretHash, - createAztecRpcClient, + createPXEClient, createRecipient, getL1ContractAddresses, getUnsafeSchnorrAccount, @@ -13,7 +13,7 @@ import { GrumpkinScalar } from '@aztec/circuits.js'; import { createDebugLogger } from '@aztec/foundation/log'; import { UniswapPortalAbi, UniswapPortalBytecode } from '@aztec/l1-artifacts'; import { NonNativeTokenContract, UniswapContract } from '@aztec/noir-contracts/types'; -import { AztecRPC, TxStatus } from '@aztec/types'; +import { PXE, TxStatus } from '@aztec/types'; import { createPublicClient, createWalletClient, getContract, http, parseEther } from 'viem'; import { mnemonicToAccount } from 'viem/accounts'; @@ -33,7 +33,7 @@ const DAI_ADDRESS = EthAddress.fromString('0x6B175474E89094C44Da98b954EedeAC4952 const EXPECTED_FORKED_BLOCK = 17514288; -const aztecRpcUrl = 'http://localhost:8080'; +const pxeRpcUrl = 'http://localhost:8080'; const ethRpcUrl = 'http://localhost:8545'; const hdAccount = mnemonicToAccount(MNEMONIC); @@ -55,7 +55,7 @@ if (Number(await publicClient.getBlockNumber()) < EXPECTED_FORKED_BLOCK) { const ethAccount = EthAddress.fromString((await walletClient.getAddresses())[0]); -const aztecRpcClient = createAztecRpcClient(aztecRpcUrl); +const pxe = createPXEClient(pxeRpcUrl); let wallet: AccountWallet; /** @@ -63,7 +63,7 @@ let wallet: AccountWallet; * @param owner - Owner address. */ async function deployAllContracts(owner: AztecAddress) { - const l1ContractsAddresses = await getL1ContractAddresses(aztecRpcUrl); + const l1ContractsAddresses = await getL1ContractAddresses(pxeRpcUrl); logger('Deploying DAI Portal, initializing and deploying l2 contract...'); const daiContracts = await deployAndInitializeNonNativeL2TokenContracts( wallet, @@ -108,7 +108,7 @@ async function deployAllContracts(owner: AztecAddress) { }); // deploy l2 uniswap contract and attach to portal - const tx = UniswapContract.deploy(aztecRpcClient).send({ portalContract: uniswapPortalAddress }); + const tx = UniswapContract.deploy(pxe).send({ portalContract: uniswapPortalAddress }); await tx.isMined({ interval: 0.5 }); const receipt = await tx.getReceipt(); const uniswapL2Contract = await UniswapContract.at(receipt.contractAddress!, wallet); @@ -132,22 +132,22 @@ async function deployAllContracts(owner: AztecAddress) { }; } -const getL2BalanceOf = async (aztecRpcClient: AztecRPC, owner: AztecAddress, l2Contract: NonNativeTokenContract) => { +const getL2BalanceOf = async (pxe: PXE, owner: AztecAddress, l2Contract: NonNativeTokenContract) => { return await l2Contract.methods.getBalance(owner).view({ from: owner }); }; const logExpectedBalanceOnL2 = async ( - aztecRpcClient: AztecRPC, + pxe: PXE, owner: AztecAddress, expectedBalance: bigint, l2Contract: NonNativeTokenContract, ) => { - const balance = await getL2BalanceOf(aztecRpcClient, owner, l2Contract); + const balance = await getL2BalanceOf(pxe, owner, l2Contract); logger(`Account ${owner} balance: ${balance}. Expected to be: ${expectedBalance}`); }; const transferWethOnL2 = async ( - _aztecRpcClient: AztecRPC, + _pxe: PXE, wethL2Contract: NonNativeTokenContract, ownerAddress: AztecAddress, receiver: AztecAddress, @@ -166,9 +166,9 @@ const transferWethOnL2 = async ( async function main() { logger('Running L1/L2 messaging test on HTTP interface.'); - wallet = await getUnsafeSchnorrAccount(aztecRpcClient, privateKey).waitDeploy(); + wallet = await getUnsafeSchnorrAccount(pxe, privateKey).waitDeploy(); const owner = wallet.getCompleteAddress(); - const receiver = await createRecipient(aztecRpcClient); + const receiver = await createRecipient(pxe); const result = await deployAllContracts(owner.address); const { @@ -213,7 +213,7 @@ async function main() { await delay(5000); // send a transfer tx to force through rollup with the message included const transferAmount = 1n; - await transferWethOnL2(aztecRpcClient, wethL2Contract, owner.address, receiver.address, transferAmount); + await transferWethOnL2(pxe, wethL2Contract, owner.address, receiver.address, transferAmount); // 3. Claim WETH on L2 logger('Minting weth on L2'); @@ -228,8 +228,8 @@ async function main() { // await expectBalanceOnL2(ownerAddress, wethAmountToBridge + initialBalance - transferAmount, wethL2Contract); // Store balances - const wethBalanceBeforeSwap = await getL2BalanceOf(aztecRpcClient, owner.address, wethL2Contract); - const daiBalanceBeforeSwap = await getL2BalanceOf(aztecRpcClient, owner.address, daiL2Contract); + const wethBalanceBeforeSwap = await getL2BalanceOf(pxe, owner.address, wethL2Contract); + const daiBalanceBeforeSwap = await getL2BalanceOf(pxe, owner.address, daiL2Contract); // 4. Send L2 to L1 message to withdraw funds and another message to swap assets. logger('Send L2 tx to withdraw WETH to uniswap portal and send message to swap assets on L1'); @@ -257,7 +257,7 @@ async function main() { logger(`Withdraw receipt status: ${withdrawReceipt.status} should be ${TxStatus.MINED}`); // check weth balance of owner on L2 (we first bridged `wethAmountToBridge` into L2 and now withdrew it!) - await logExpectedBalanceOnL2(aztecRpcClient, owner.address, INITIAL_BALANCE - transferAmount, wethL2Contract); + await logExpectedBalanceOnL2(pxe, owner.address, INITIAL_BALANCE - transferAmount, wethL2Contract); // 5. Consume L2 to L1 message by calling uniswapPortal.swap() logger('Execute withdraw and swap on the uniswapPortal!'); @@ -294,7 +294,7 @@ async function main() { // Wait for the archiver to process the message await delay(5000); // send a transfer tx to force through rollup with the message included - await transferWethOnL2(aztecRpcClient, wethL2Contract, owner.address, receiver.address, transferAmount); + await transferWethOnL2(pxe, wethL2Contract, owner.address, receiver.address, transferAmount); // 6. claim dai on L2 logger('Consuming messages to mint dai on L2'); @@ -306,15 +306,10 @@ async function main() { const daiMintTxReceipt = await daiMintTx.getReceipt(); // expect(daiMintTxReceipt.status).toBe(TxStatus.MINED); logger(`DAI mint TX status: ${daiMintTxReceipt.status} should be ${TxStatus.MINED}`); - await logExpectedBalanceOnL2( - aztecRpcClient, - owner.address, - INITIAL_BALANCE + BigInt(daiAmountToBridge), - daiL2Contract, - ); + await logExpectedBalanceOnL2(pxe, owner.address, INITIAL_BALANCE + BigInt(daiAmountToBridge), daiL2Contract); - const wethBalanceAfterSwap = await getL2BalanceOf(aztecRpcClient, owner.address, wethL2Contract); - const daiBalanceAfterSwap = await getL2BalanceOf(aztecRpcClient, owner.address, daiL2Contract); + const wethBalanceAfterSwap = await getL2BalanceOf(pxe, owner.address, wethL2Contract); + const daiBalanceAfterSwap = await getL2BalanceOf(pxe, owner.address, daiL2Contract); logger('WETH balance before swap: ', wethBalanceBeforeSwap.toString()); logger('DAI balance before swap : ', daiBalanceBeforeSwap.toString()); diff --git a/yarn-project/aztec-sandbox/src/examples/util.ts b/yarn-project/aztec-sandbox/src/examples/util.ts index f6feb91507e..d3462673cce 100644 --- a/yarn-project/aztec-sandbox/src/examples/util.ts +++ b/yarn-project/aztec-sandbox/src/examples/util.ts @@ -7,7 +7,7 @@ import { Account, Chain, Hex, HttpTransport, PublicClient, WalletClient, getCont /** * Deploy L1 token and portal, initialize portal, deploy a non native l2 token contract and attach is to the portal. - * @param aztecRpcServer - the aztec rpc server instance + * @param wallet - A wallet instance. * @param walletClient - A viem WalletClient. * @param publicClient - A viem PublicClient. * @param rollupRegistryAddress - address of rollup registry to pass to initialize the token portal diff --git a/yarn-project/aztec-sandbox/src/routes.ts b/yarn-project/aztec-sandbox/src/routes.ts index 982fd37677d..91bbec88f10 100644 --- a/yarn-project/aztec-sandbox/src/routes.ts +++ b/yarn-project/aztec-sandbox/src/routes.ts @@ -2,7 +2,7 @@ import Koa from 'koa'; import Router from 'koa-router'; /** - * Creates a router for helper API endpoints of the Aztec RPC Server. + * Creates a router for helper API endpoints of the Private Execution Environment (PXE). * @param aztecNode - An instance of the aztec node. * @param config - The aztec node's configuration variables. */ diff --git a/yarn-project/aztec-sandbox/src/sandbox.ts b/yarn-project/aztec-sandbox/src/sandbox.ts index 463bf51e85f..81ba9429050 100644 --- a/yarn-project/aztec-sandbox/src/sandbox.ts +++ b/yarn-project/aztec-sandbox/src/sandbox.ts @@ -20,7 +20,7 @@ import { RollupAbi, RollupBytecode, } from '@aztec/l1-artifacts'; -import { createAztecRPCServer, getConfigEnvVars as getRpcConfigEnvVars } from '@aztec/pxe'; +import { createPXEService, getPXEServiceConfig } from '@aztec/pxe'; import { createPublicClient, http as httpViemTransport } from 'viem'; import { mnemonicToAccount } from 'viem/accounts'; @@ -72,13 +72,13 @@ export type SandboxConfig = AztecNodeConfig & { }; /** - * Create and start a new Aztec Node and RPC Server. Deploys L1 contracts. + * Create and start a new Aztec Node and PXE. Deploys L1 contracts. * Does not start any HTTP services nor populate any initial accounts. * @param config - Optional Sandbox settings. */ export async function createSandbox(config: Partial = {}) { const aztecNodeConfig: AztecNodeConfig = { ...getConfigEnvVars(), ...config }; - const rpcConfig = getRpcConfigEnvVars(); + const pxeServiceConfig = getPXEServiceConfig(); const hdAccount = mnemonicToAccount(config.l1Mnemonic ?? MNEMONIC); const privKey = hdAccount.getHdKey().privateKey; @@ -116,12 +116,12 @@ export async function createSandbox(config: Partial = {}) { aztecNodeConfig.l1Contracts.registryAddress = l1Contracts.l1ContractAddresses.registryAddress; const node = await AztecNodeService.createAndSync(aztecNodeConfig); - const rpcServer = await createAztecRPCServer(node, rpcConfig); + const pxe = await createPXEService(node, pxeServiceConfig); const stop = async () => { - await rpcServer.stop(); + await pxe.stop(); await node.stop(); }; - return { node, rpcServer, l1Contracts, stop }; + return { node, pxe, l1Contracts, stop }; } diff --git a/yarn-project/aztec-sandbox/src/server.ts b/yarn-project/aztec-sandbox/src/server.ts index d2e4805dd75..4affe2f2b21 100644 --- a/yarn-project/aztec-sandbox/src/server.ts +++ b/yarn-project/aztec-sandbox/src/server.ts @@ -1,18 +1,18 @@ -import { getHttpRpcServer } from '@aztec/pxe'; -import { AztecRPC } from '@aztec/types'; +import { createPXERpcServer } from '@aztec/pxe'; +import { PXE } from '@aztec/types'; import http from 'http'; import { createApiRouter } from './routes.js'; /** - * Creates an http server that forwards calls to the rpc server and starts it on the given port. - * @param aztecRpcServer - RPC server that answers queries to the created HTTP server. + * Creates an http server that forwards calls to the PXE and starts it on the given port. + * @param pxe - PXE that answers queries to the created HTTP server. * @param port - Port to listen in. * @returns A running http server. */ -export function startHttpRpcServer(aztecRpcServer: AztecRPC, port: string | number): http.Server { - const rpcServer = getHttpRpcServer(aztecRpcServer); +export function startHttpRpcServer(pxe: PXE, port: string | number): http.Server { + const rpcServer = createPXERpcServer(pxe); const app = rpcServer.getApp(); const apiRouter = createApiRouter(); diff --git a/yarn-project/aztec.js/README.md b/yarn-project/aztec.js/README.md index b678fb81216..14b0aa536dd 100644 --- a/yarn-project/aztec.js/README.md +++ b/yarn-project/aztec.js/README.md @@ -1,6 +1,6 @@ # Aztec.js -Aztec.js is a library that provides APIs for managing accounts and interacting with contracts on the Aztec network. It communicates with the [Aztec RPC Server](https://docs.aztec.network/apis/pxe/interfaces/AztecRPC) through an `AztecRPCClient` implementation, allowing developers to easily register new accounts, deploy contracts, view functions, and send transactions. +Aztec.js is a library that provides APIs for managing accounts and interacting with contracts on the Aztec network. It communicates with the [Private Execution Environment (PXE)](https://docs.aztec.network/apis/pxe/interfaces/PXE) through a `PXE` implementation, allowing developers to easily register new accounts, deploy contracts, view functions, and send transactions. ## Usage @@ -12,7 +12,7 @@ import { GrumpkinPrivateKey } from '@aztec/types'; const encryptionPrivateKey = GrumpkinPrivateKey.random(); const signingPrivateKey = GrumpkinPrivateKey.random(); -const wallet = getSchnorrAccount(rpc, encryptionPrivateKey, signingPrivateKey).waitDeploy(); +const wallet = getSchnorrAccount(pxe, encryptionPrivateKey, signingPrivateKey).waitDeploy(); console.log(`New account deployed at ${wallet.getAddress()}`); ``` diff --git a/yarn-project/aztec.js/src/account/index.ts b/yarn-project/aztec.js/src/account/index.ts index 4db12237ee8..9c240bba333 100644 --- a/yarn-project/aztec.js/src/account/index.ts +++ b/yarn-project/aztec.js/src/account/index.ts @@ -7,7 +7,7 @@ * ```ts * const encryptionPrivateKey = GrumpkinScalar.random(); * const signingPrivateKey = GrumpkinScalar.random(); - * const wallet = getSchnorrAccount(rpc, encryptionPrivateKey, signingPrivateKey).waitDeploy(); + * const wallet = getSchnorrAccount(pxe, encryptionPrivateKey, signingPrivateKey).waitDeploy(); * ``` * * For testing purposes, consider using the {@link createAccount} and {@link createAccounts} methods, @@ -19,7 +19,7 @@ * * @packageDocumentation */ -import { AztecRPC, CompleteAddress, GrumpkinPrivateKey } from '@aztec/types'; +import { CompleteAddress, GrumpkinPrivateKey, PXE } from '@aztec/types'; import { AccountContract, AccountWallet, AztecAddress, Fr } from '../index.js'; import { EcdsaAccountContract } from './contract/ecdsa_account_contract.js'; @@ -38,49 +38,49 @@ export type Salt = Fr | number | bigint; /** * Creates an Account that relies on an ECDSA signing key for authentication. - * @param rpc - An AztecRPC server instance. + * @param pxe - An PXE server instance. * @param encryptionPrivateKey - Grumpkin key used for note encryption. * @param signingPrivateKey - Secp256k1 key used for signing transactions. * @param saltOrAddress - Deployment salt or complete address if account contract is already deployed. */ export function getEcdsaAccount( - rpc: AztecRPC, + pxe: PXE, encryptionPrivateKey: GrumpkinPrivateKey, signingPrivateKey: Buffer, saltOrAddress?: Salt | CompleteAddress, ): AccountManager { - return new AccountManager(rpc, encryptionPrivateKey, new EcdsaAccountContract(signingPrivateKey), saltOrAddress); + return new AccountManager(pxe, encryptionPrivateKey, new EcdsaAccountContract(signingPrivateKey), saltOrAddress); } /** * Creates an Account that relies on a Grumpkin signing key for authentication. - * @param rpc - An AztecRPC server instance. + * @param pxe - An PXE server instance. * @param encryptionPrivateKey - Grumpkin key used for note encryption. * @param signingPrivateKey - Grumpkin key used for signing transactions. * @param saltOrAddress - Deployment salt or complete address if account contract is already deployed. */ export function getSchnorrAccount( - rpc: AztecRPC, + pxe: PXE, encryptionPrivateKey: GrumpkinPrivateKey, signingPrivateKey: GrumpkinPrivateKey, saltOrAddress?: Salt | CompleteAddress, ): AccountManager { - return new AccountManager(rpc, encryptionPrivateKey, new SchnorrAccountContract(signingPrivateKey), saltOrAddress); + return new AccountManager(pxe, encryptionPrivateKey, new SchnorrAccountContract(signingPrivateKey), saltOrAddress); } /** * Creates an Account that uses the same Grumpkin key for encryption and authentication. - * @param rpc - An AztecRPC server instance. + * @param pxe - An PXE server instance. * @param encryptionAndSigningPrivateKey - Grumpkin key used for note encryption and signing transactions. * @param saltOrAddress - Deployment salt or complete address if account contract is already deployed. */ export function getUnsafeSchnorrAccount( - rpc: AztecRPC, + pxe: PXE, encryptionAndSigningPrivateKey: GrumpkinPrivateKey, saltOrAddress?: Salt | CompleteAddress, ): AccountManager { return new AccountManager( - rpc, + pxe, encryptionAndSigningPrivateKey, new SingleKeyAccountContract(encryptionAndSigningPrivateKey), saltOrAddress, @@ -89,36 +89,36 @@ export function getUnsafeSchnorrAccount( /** * Gets a wallet for an already registered account using Schnorr signatures with a single key for encryption and authentication. - * @param rpc - An AztecRPC server instance. + * @param pxe - An PXE server instance. * @param address - Address for the account. * @param signingPrivateKey - Grumpkin key used for note encryption and signing transactions. * @returns A wallet for this account that can be used to interact with a contract instance. */ export function getUnsafeSchnorrWallet( - rpc: AztecRPC, + pxe: PXE, address: AztecAddress, signingKey: GrumpkinPrivateKey, ): Promise { - return getWallet(rpc, address, new SingleKeyAccountContract(signingKey)); + return getWallet(pxe, address, new SingleKeyAccountContract(signingKey)); } /** * Gets a wallet for an already registered account. - * @param rpc - An AztecRPC server instance. + * @param pxe - PXE Service instance. * @param address - Address for the account. * @param accountContract - Account contract implementation. * @returns A wallet for this account that can be used to interact with a contract instance. */ export async function getWallet( - rpc: AztecRPC, + pxe: PXE, address: AztecAddress, accountContract: AccountContract, ): Promise { - const completeAddress = await rpc.getRegisteredAccount(address); + const completeAddress = await pxe.getRegisteredAccount(address); if (!completeAddress) { throw new Error(`Account ${address} not found`); } - const nodeInfo = await rpc.getNodeInfo(); + const nodeInfo = await pxe.getNodeInfo(); const entrypoint = await accountContract.getInterface(completeAddress, nodeInfo); - return new AccountWallet(rpc, entrypoint); + return new AccountWallet(pxe, entrypoint); } diff --git a/yarn-project/aztec.js/src/account/manager/index.ts b/yarn-project/aztec.js/src/account/manager/index.ts index 4f2f066b30b..f4c4255e56a 100644 --- a/yarn-project/aztec.js/src/account/manager/index.ts +++ b/yarn-project/aztec.js/src/account/manager/index.ts @@ -1,5 +1,5 @@ import { Fr, PublicKey, getContractDeploymentInfo } from '@aztec/circuits.js'; -import { AztecRPC, CompleteAddress, GrumpkinPrivateKey } from '@aztec/types'; +import { CompleteAddress, GrumpkinPrivateKey, PXE } from '@aztec/types'; import { AccountWallet, ContractDeployer, DeployMethod, WaitOpts, generatePublicKey } from '../../index.js'; import { AccountContract, Salt } from '../index.js'; @@ -8,7 +8,7 @@ import { DeployAccountSentTx } from './deploy_account_sent_tx.js'; /** * Manages a user account. Provides methods for calculating the account's address, deploying the account contract, - * and creating and registering the user wallet in the RPC server. + * and creating and registering the user wallet in the PXE Service. */ export class AccountManager { /** Deployment salt for the account contract. */ @@ -19,7 +19,7 @@ export class AccountManager { private deployMethod?: DeployMethod; constructor( - private rpc: AztecRPC, + private pxe: PXE, private encryptionPrivateKey: GrumpkinPrivateKey, private accountContract: AccountContract, saltOrAddress?: Salt | CompleteAddress, @@ -43,7 +43,7 @@ export class AccountManager { * @returns An entrypoint. */ public async getAccount(): Promise { - const nodeInfo = await this.rpc.getNodeInfo(); + const nodeInfo = await this.pxe.getNodeInfo(); const completeAddress = await this.getCompleteAddress(); return this.accountContract.getInterface(completeAddress, nodeInfo); } @@ -74,18 +74,18 @@ export class AccountManager { */ public async getWallet(): Promise { const entrypoint = await this.getAccount(); - return new AccountWallet(this.rpc, entrypoint); + return new AccountWallet(this.pxe, entrypoint); } /** - * Registers this account in the RPC server and returns the associated wallet. Registering - * the account on the RPC server is required for managing private state associated with it. + * Registers this account in the PXE Service and returns the associated wallet. Registering + * the account on the PXE Service is required for managing private state associated with it. * Use the returned wallet to create Contract instances to be interacted with from this account. * @returns A Wallet instance. */ public async register(): Promise { const completeAddress = await this.getCompleteAddress(); - await this.rpc.registerAccount(this.encryptionPrivateKey, completeAddress.partialAddress); + await this.pxe.registerAccount(this.encryptionPrivateKey, completeAddress.partialAddress); return this.getWallet(); } @@ -100,7 +100,7 @@ export class AccountManager { if (!this.salt) throw new Error(`Cannot deploy account contract without known salt.`); await this.register(); const encryptionPublicKey = await this.getEncryptionPublicKey(); - const deployer = new ContractDeployer(this.accountContract.getContractAbi(), this.rpc, encryptionPublicKey); + const deployer = new ContractDeployer(this.accountContract.getContractAbi(), this.pxe, encryptionPublicKey); const args = await this.accountContract.getDeploymentArgs(); this.deployMethod = deployer.deploy(...args); } @@ -112,7 +112,7 @@ export class AccountManager { * Uses the salt provided in the constructor or a randomly generated one. * Note that if the Account is constructed with an explicit complete address * it is assumed that the account contract has already been deployed and this method will throw. - * Registers the account in the RPC server before deploying the contract. + * Registers the account in the PXE Service before deploying the contract. * @returns A SentTx object that can be waited to get the associated Wallet. */ public async deploy(): Promise { @@ -127,7 +127,7 @@ export class AccountManager { * Uses the salt provided in the constructor or a randomly generated one. * Note that if the Account is constructed with an explicit complete address * it is assumed that the account contract has already been deployed and this method will throw. - * Registers the account in the RPC server before deploying the contract. + * Registers the account in the PXE Service before deploying the contract. * @param opts - Options to wait for the tx to be mined. * @returns A Wallet instance. */ diff --git a/yarn-project/aztec.js/src/account/utils.ts b/yarn-project/aztec.js/src/account/utils.ts index fcf63096b3a..593ca2cdd8a 100644 --- a/yarn-project/aztec.js/src/account/utils.ts +++ b/yarn-project/aztec.js/src/account/utils.ts @@ -1,41 +1,41 @@ import { CompleteAddress, GrumpkinScalar } from '@aztec/circuits.js'; -import { AztecRPC } from '@aztec/types'; +import { PXE } from '@aztec/types'; import { getSchnorrAccount } from '../index.js'; import { AccountWallet } from '../wallet/account_wallet.js'; /** * Deploys and registers a new account using random private keys and returns the associated Schnorr account wallet. Useful for testing. - * @param rpc - RPC client. + * @param pxe - PXE. * @returns - A wallet for a fresh account. */ -export function createAccount(rpc: AztecRPC): Promise { - return getSchnorrAccount(rpc, GrumpkinScalar.random(), GrumpkinScalar.random()).waitDeploy(); +export function createAccount(pxe: PXE): Promise { + return getSchnorrAccount(pxe, GrumpkinScalar.random(), GrumpkinScalar.random()).waitDeploy(); } /** - * Creates a random address and registers it as a recipient on the RPC server. Useful for testing. - * @param rpc - RPC client. + * Creates a random address and registers it as a recipient on the pxe server. Useful for testing. + * @param pxe - PXE. * @returns Complete address of the registered recipient. */ -export async function createRecipient(rpc: AztecRPC): Promise { +export async function createRecipient(pxe: PXE): Promise { const completeAddress = await CompleteAddress.random(); - await rpc.registerRecipient(completeAddress); + await pxe.registerRecipient(completeAddress); return completeAddress; } /** * Creates a given number of random accounts using the Schnorr account wallet. - * @param rpc - RPC interface. + * @param pxe - PXE. * @param numberOfAccounts - How many accounts to create. * @returns The created account wallets. */ -export async function createAccounts(rpc: AztecRPC, numberOfAccounts = 1): Promise { +export async function createAccounts(pxe: PXE, numberOfAccounts = 1): Promise { const accounts = []; // Prepare deployments for (let i = 0; i < numberOfAccounts; ++i) { - const account = getSchnorrAccount(rpc, GrumpkinScalar.random(), GrumpkinScalar.random()); + const account = getSchnorrAccount(pxe, GrumpkinScalar.random(), GrumpkinScalar.random()); await account.getDeployMethod().then(d => d.simulate({ contractAddressSalt: account.salt })); accounts.push(account); } diff --git a/yarn-project/aztec.js/src/contract/base_contract_interaction.ts b/yarn-project/aztec.js/src/contract/base_contract_interaction.ts index 6a9458f27c5..800ae901c8d 100644 --- a/yarn-project/aztec.js/src/contract/base_contract_interaction.ts +++ b/yarn-project/aztec.js/src/contract/base_contract_interaction.ts @@ -1,4 +1,4 @@ -import { AztecRPC, Tx, TxExecutionRequest } from '@aztec/types'; +import { PXE, Tx, TxExecutionRequest } from '@aztec/types'; import { SentTx } from './sent_tx.js'; @@ -21,7 +21,7 @@ export abstract class BaseContractInteraction { protected tx?: Tx; protected txRequest?: TxExecutionRequest; - constructor(protected rpc: AztecRPC) {} + constructor(protected pxe: PXE) {} /** * Create a transaction execution request ready to be simulated. @@ -37,7 +37,7 @@ export abstract class BaseContractInteraction { */ public async simulate(options: SendMethodOptions = {}): Promise { const txRequest = this.txRequest ?? (await this.create(options)); - this.tx = await this.rpc.simulateTx(txRequest, !options.skipPublicSimulation); + this.tx = await this.pxe.simulateTx(txRequest, !options.skipPublicSimulation); return this.tx; } @@ -53,9 +53,9 @@ export abstract class BaseContractInteraction { public send(options: SendMethodOptions = {}) { const promise = (async () => { const tx = this.tx ?? (await this.simulate(options)); - return this.rpc.sendTx(tx); + return this.pxe.sendTx(tx); })(); - return new SentTx(this.rpc, promise); + return new SentTx(this.pxe, promise); } } diff --git a/yarn-project/aztec.js/src/contract/contract.test.ts b/yarn-project/aztec.js/src/contract/contract.test.ts index 6afe155e32e..3faef893055 100644 --- a/yarn-project/aztec.js/src/contract/contract.test.ts +++ b/yarn-project/aztec.js/src/contract/contract.test.ts @@ -156,7 +156,7 @@ describe('Contract Class', () => { expect(() => fooContract.methods.baz().view()).toThrow(); }); - it('should add contract and dependencies to aztec rpc', async () => { + it('should add contract and dependencies to PXE', async () => { const entry: DeployedContract = { abi: randomContractAbi(), completeAddress: resolvedExtendedContractData.getCompleteAddress(), diff --git a/yarn-project/aztec.js/src/contract/contract.ts b/yarn-project/aztec.js/src/contract/contract.ts index 640c0d47d19..4fa1a4f9ff7 100644 --- a/yarn-project/aztec.js/src/contract/contract.ts +++ b/yarn-project/aztec.js/src/contract/contract.ts @@ -10,7 +10,7 @@ import { ContractBase } from './contract_base.js'; * The Contract class represents a contract and provides utility methods for interacting with it. * It enables the creation of ContractFunctionInteraction instances for each function in the contract's ABI, * allowing users to call or send transactions to these functions. Additionally, the Contract class can be used - * to attach the contract instance to a deployed contract on-chain through the AztecRPCClient, which facilitates + * to attach the contract instance to a deployed contract on-chain through the PXE, which facilitates * interaction with Aztec's privacy protocol. */ export class Contract extends ContractBase { diff --git a/yarn-project/aztec.js/src/contract/contract_base.ts b/yarn-project/aztec.js/src/contract/contract_base.ts index 8062d178569..b408d386bf5 100644 --- a/yarn-project/aztec.js/src/contract/contract_base.ts +++ b/yarn-project/aztec.js/src/contract/contract_base.ts @@ -74,12 +74,12 @@ export class ContractBase { /** * Attach the current contract instance to a portal contract and optionally add its dependencies. - * The function will return a promise that resolves when all contracts have been added to the AztecRPCClient. + * The function will return a promise that resolves when all contracts have been added to the PXE. * This is useful when you need to interact with a deployed contract that has multiple nested contracts. * * @param portalContract - The Ethereum address of the portal contract. * @param dependencies - An optional array of additional DeployedContract instances to be attached. - * @returns A promise that resolves when all contracts are successfully added to the AztecRPCClient. + * @returns A promise that resolves when all contracts are successfully added to the PXE. */ public attach(portalContract: EthAddress, dependencies: DeployedContract[] = []) { const deployedContract: DeployedContract = { diff --git a/yarn-project/aztec.js/src/contract/index.ts b/yarn-project/aztec.js/src/contract/index.ts index 9ef6df45049..620c4d1e968 100644 --- a/yarn-project/aztec.js/src/contract/index.ts +++ b/yarn-project/aztec.js/src/contract/index.ts @@ -26,7 +26,7 @@ * or obtaining the `request` for aggregating into a {@link BatchCall}. * * The result of `send`ing a transaction is a {@link SentTx} object, from which you can get the - * transaction hash, or simply `wait` until the transaction is mined and the local RPC server + * transaction hash, or simply `wait` until the transaction is mined and the local PXE Service * has synchronised its changes. * * @remarks If you are using typescript, consider using the diff --git a/yarn-project/aztec.js/src/contract/sent_tx.test.ts b/yarn-project/aztec.js/src/contract/sent_tx.test.ts index e3bef6b7216..29cf7ef450f 100644 --- a/yarn-project/aztec.js/src/contract/sent_tx.test.ts +++ b/yarn-project/aztec.js/src/contract/sent_tx.test.ts @@ -1,30 +1,30 @@ -import { AztecRPC, TxHash, TxReceipt, TxStatus } from '@aztec/types'; +import { PXE, TxHash, TxReceipt, TxStatus } from '@aztec/types'; import { MockProxy, mock } from 'jest-mock-extended'; import { SentTx } from './sent_tx.js'; describe('SentTx', () => { - let rpc: MockProxy; + let pxe: MockProxy; let txHashPromise: Promise; let sentTx: SentTx; beforeEach(() => { - rpc = mock(); + pxe = mock(); txHashPromise = Promise.resolve(TxHash.fromBigInt(1n)); - sentTx = new SentTx(rpc, txHashPromise); + sentTx = new SentTx(pxe, txHashPromise); }); describe('wait', () => { let txReceipt: TxReceipt; beforeEach(() => { txReceipt = { status: TxStatus.MINED, blockNumber: 20 } as TxReceipt; - rpc.getTxReceipt.mockResolvedValue(txReceipt); + pxe.getTxReceipt.mockResolvedValue(txReceipt); }); it('waits for all notes accounts to be synced', async () => { - rpc.getSyncStatus + pxe.getSyncStatus .mockResolvedValueOnce({ blocks: 25, notes: { '0x1': 19, '0x2': 20 } }) .mockResolvedValueOnce({ blocks: 25, notes: { '0x1': 20, '0x2': 20 } }); @@ -33,19 +33,19 @@ describe('SentTx', () => { }); it('fails if an account is not synced', async () => { - rpc.getSyncStatus.mockResolvedValue({ blocks: 25, notes: { '0x1': 19, '0x2': 20 } }); + pxe.getSyncStatus.mockResolvedValue({ blocks: 25, notes: { '0x1': 19, '0x2': 20 } }); await expect(sentTx.wait({ timeout: 1, interval: 0.4 })).rejects.toThrowError(/timeout/i); }); it('does not wait for notes sync', async () => { - rpc.getSyncStatus.mockResolvedValue({ blocks: 19, notes: { '0x1': 19, '0x2': 19 } }); + pxe.getSyncStatus.mockResolvedValue({ blocks: 19, notes: { '0x1': 19, '0x2': 19 } }); const actual = await sentTx.wait({ timeout: 1, interval: 0.4, waitForNotesSync: false }); expect(actual).toEqual(txReceipt); }); it('throws if tx is dropped', async () => { - rpc.getTxReceipt.mockResolvedValue({ ...txReceipt, status: TxStatus.DROPPED } as TxReceipt); - rpc.getSyncStatus.mockResolvedValue({ blocks: 19, notes: { '0x1': 19, '0x2': 19 } }); + pxe.getTxReceipt.mockResolvedValue({ ...txReceipt, status: TxStatus.DROPPED } as TxReceipt); + pxe.getSyncStatus.mockResolvedValue({ blocks: 19, notes: { '0x1': 19, '0x2': 19 } }); await expect(sentTx.wait({ timeout: 1, interval: 0.4 })).rejects.toThrowError(/dropped/); }); }); diff --git a/yarn-project/aztec.js/src/contract/sent_tx.ts b/yarn-project/aztec.js/src/contract/sent_tx.ts index 1ef7f506a3c..9ab94c115e3 100644 --- a/yarn-project/aztec.js/src/contract/sent_tx.ts +++ b/yarn-project/aztec.js/src/contract/sent_tx.ts @@ -1,6 +1,6 @@ import { FieldsOf } from '@aztec/circuits.js'; import { retryUntil } from '@aztec/foundation/retry'; -import { AztecRPC, TxHash, TxReceipt, TxStatus } from '@aztec/types'; +import { PXE, TxHash, TxReceipt, TxStatus } from '@aztec/types'; import every from 'lodash.every'; @@ -11,7 +11,7 @@ export type WaitOpts = { /** The time interval (in seconds) between retries to fetch the transaction receipt. Defaults to 1. */ interval?: number; /** - * Whether to wait for the RPC server to sync all notes up to the block in which this tx was mined. + * Whether to wait for the PXE Service to sync all notes up to the block in which this tx was mined. * If false, then any queries that depend on state set by this transaction may return stale data. Defaults to true. **/ waitForNotesSync?: boolean; @@ -24,11 +24,11 @@ const DefaultWaitOpts: WaitOpts = { }; /** - * The SentTx class represents a sent transaction through the AztecRPCClient, providing methods to fetch + * The SentTx class represents a sent transaction through the PXE, providing methods to fetch * its hash, receipt, and mining status. */ export class SentTx { - constructor(protected arc: AztecRPC, protected txHashPromise: Promise) {} + constructor(protected pxe: PXE, protected txHashPromise: Promise) {} /** * Retrieves the transaction hash of the SentTx instance. @@ -43,13 +43,13 @@ export class SentTx { /** * Retrieve the transaction receipt associated with the current SentTx instance. * The function fetches the transaction hash using 'getTxHash' and then queries - * the AztecRPCClient to get the corresponding transaction receipt. + * the PXE to get the corresponding transaction receipt. * * @returns A promise that resolves to a TxReceipt object representing the fetched transaction receipt. */ public async getReceipt(): Promise { const txHash = await this.getTxHash(); - return await this.arc.getTxReceipt(txHash); + return await this.pxe.getTxReceipt(txHash); } /** @@ -84,7 +84,7 @@ export class SentTx { const txHash = await this.getTxHash(); return await retryUntil( async () => { - const txReceipt = await this.arc.getTxReceipt(txHash); + const txReceipt = await this.pxe.getTxReceipt(txHash); // If receipt is not yet available, try again if (txReceipt.status === TxStatus.PENDING) return undefined; // If the tx was dropped, return it @@ -92,8 +92,8 @@ export class SentTx { // If we don't care about waiting for notes to be synced, return the receipt const waitForNotesSync = opts?.waitForNotesSync ?? DefaultWaitOpts.waitForNotesSync; if (!waitForNotesSync) return txReceipt; - // Check if all sync blocks on the rpc server are greater or equal than the block in which the tx was mined - const { blocks, notes } = await this.arc.getSyncStatus(); + // Check if all sync blocks on the PXE Service are greater or equal than the block in which the tx was mined + const { blocks, notes } = await this.pxe.getSyncStatus(); const targetBlock = txReceipt.blockNumber!; const areNotesSynced = blocks >= targetBlock && every(notes, block => block >= targetBlock); return areNotesSynced ? txReceipt : undefined; diff --git a/yarn-project/aztec.js/src/contract_deployer/contract_deployer.test.ts b/yarn-project/aztec.js/src/contract_deployer/contract_deployer.test.ts index 36e2d8b5bac..a95e6c45b97 100644 --- a/yarn-project/aztec.js/src/contract_deployer/contract_deployer.test.ts +++ b/yarn-project/aztec.js/src/contract_deployer/contract_deployer.test.ts @@ -1,13 +1,13 @@ import { EthAddress, Fr, Point } from '@aztec/circuits.js'; import { ContractAbi, FunctionType } from '@aztec/foundation/abi'; -import { AztecRPC, PublicKey, Tx, TxHash, TxReceipt } from '@aztec/types'; +import { PXE, PublicKey, Tx, TxHash, TxReceipt } from '@aztec/types'; import { MockProxy, mock } from 'jest-mock-extended'; import { ContractDeployer } from './contract_deployer.js'; describe.skip('Contract Deployer', () => { - let arc: MockProxy; + let pxe: MockProxy; const abi: ContractAbi = { name: 'MyContract', @@ -33,13 +33,13 @@ describe.skip('Contract Deployer', () => { const mockTxReceipt = { type: 'TxReceipt' } as any as TxReceipt; beforeEach(() => { - arc = mock(); - arc.sendTx.mockResolvedValue(mockTxHash); - arc.getTxReceipt.mockResolvedValue(mockTxReceipt); + pxe = mock(); + pxe.sendTx.mockResolvedValue(mockTxHash); + pxe.getTxReceipt.mockResolvedValue(mockTxReceipt); }); it('should create and send a contract deployment tx', async () => { - const deployer = new ContractDeployer(abi, arc, publicKey); + const deployer = new ContractDeployer(abi, pxe, publicKey); const sentTx = deployer.deploy(args[0], args[1]).send({ portalContract, contractAddressSalt, @@ -49,7 +49,7 @@ describe.skip('Contract Deployer', () => { expect(txHash).toBe(mockTxHash); expect(receipt).toBe(mockTxReceipt); - expect(arc.sendTx).toHaveBeenCalledTimes(1); - expect(arc.sendTx).toHaveBeenCalledWith(mockTx); + expect(pxe.sendTx).toHaveBeenCalledTimes(1); + expect(pxe.sendTx).toHaveBeenCalledWith(mockTx); }); }); diff --git a/yarn-project/aztec.js/src/contract_deployer/contract_deployer.ts b/yarn-project/aztec.js/src/contract_deployer/contract_deployer.ts index c01f4490025..92ed8e23fc6 100644 --- a/yarn-project/aztec.js/src/contract_deployer/contract_deployer.ts +++ b/yarn-project/aztec.js/src/contract_deployer/contract_deployer.ts @@ -1,6 +1,6 @@ import { Point } from '@aztec/circuits.js'; import { ContractAbi } from '@aztec/foundation/abi'; -import { AztecRPC, PublicKey } from '@aztec/types'; +import { PXE, PublicKey } from '@aztec/types'; import { DeployMethod } from './deploy_method.js'; @@ -9,7 +9,7 @@ import { DeployMethod } from './deploy_method.js'; * @remarks Keeping this around even though we have Aztec.nr contract types because it can be useful for non-TS users. */ export class ContractDeployer { - constructor(private abi: ContractAbi, private arc: AztecRPC, private publicKey?: PublicKey) {} + constructor(private abi: ContractAbi, private pxe: PXE, private publicKey?: PublicKey) {} /** * Deploy a contract using the provided ABI and constructor arguments. @@ -18,9 +18,9 @@ export class ContractDeployer { * be passed to the contract's constructor during deployment. * * @param args - The constructor arguments for the contract being deployed. - * @returns A DeployMethod instance configured with the ABI, AztecRPCClient, and constructor arguments. + * @returns A DeployMethod instance configured with the ABI, PXE, and constructor arguments. */ public deploy(...args: any[]) { - return new DeployMethod(this.publicKey ?? Point.ZERO, this.arc, this.abi, args); + return new DeployMethod(this.publicKey ?? Point.ZERO, this.pxe, this.abi, args); } } diff --git a/yarn-project/aztec.js/src/contract_deployer/deploy_method.ts b/yarn-project/aztec.js/src/contract_deployer/deploy_method.ts index b10c6df43fc..2cf6dbd9ad6 100644 --- a/yarn-project/aztec.js/src/contract_deployer/deploy_method.ts +++ b/yarn-project/aztec.js/src/contract_deployer/deploy_method.ts @@ -8,7 +8,7 @@ import { import { ContractAbi, FunctionAbi, encodeArguments } from '@aztec/foundation/abi'; import { EthAddress } from '@aztec/foundation/eth-address'; import { Fr } from '@aztec/foundation/fields'; -import { AztecRPC, PackedArguments, PublicKey, Tx, TxExecutionRequest } from '@aztec/types'; +import { PXE, PackedArguments, PublicKey, Tx, TxExecutionRequest } from '@aztec/types'; import { BaseContractInteraction } from '../contract/base_contract_interaction.js'; import { Contract, ContractBase, SendMethodOptions } from '../contract/index.js'; @@ -40,8 +40,8 @@ export class DeployMethod extends Bas /** Constructor function to call. */ private constructorAbi: FunctionAbi; - constructor(private publicKey: PublicKey, private arc: AztecRPC, private abi: ContractAbi, private args: any[] = []) { - super(arc); + constructor(private publicKey: PublicKey, protected pxe: PXE, private abi: ContractAbi, private args: any[] = []) { + super(pxe); const constructorAbi = abi.functions.find(f => f.name === 'constructor'); if (!constructorAbi) throw new Error('Cannot find constructor in the ABI.'); this.constructorAbi = constructorAbi; @@ -60,7 +60,7 @@ export class DeployMethod extends Bas const portalContract = options.portalContract ?? EthAddress.ZERO; const contractAddressSalt = options.contractAddressSalt ?? Fr.random(); - const { chainId, protocolVersion } = await this.rpc.getNodeInfo(); + const { chainId, protocolVersion } = await this.pxe.getNodeInfo(); const { completeAddress, constructorHash, functionTreeRoot } = await getContractDeploymentInfo( this.abi, @@ -103,7 +103,7 @@ export class DeployMethod extends Bas this.completeAddress = completeAddress; // TODO: Should we add the contracts to the DB here, or once the tx has been sent or mined? - await this.rpc.addContracts([{ abi: this.abi, completeAddress, portalContract }]); + await this.pxe.addContracts([{ abi: this.abi, completeAddress, portalContract }]); return this.txRequest; } @@ -118,7 +118,7 @@ export class DeployMethod extends Bas */ public send(options: DeployOptions = {}): DeploySentTx { const txHashPromise = super.send(options).getTxHash(); - return new DeploySentTx(this.abi, this.arc, txHashPromise); + return new DeploySentTx(this.abi, this.pxe, txHashPromise); } /** diff --git a/yarn-project/aztec.js/src/contract_deployer/deploy_sent_tx.ts b/yarn-project/aztec.js/src/contract_deployer/deploy_sent_tx.ts index d6078190258..a442f3bee3c 100644 --- a/yarn-project/aztec.js/src/contract_deployer/deploy_sent_tx.ts +++ b/yarn-project/aztec.js/src/contract_deployer/deploy_sent_tx.ts @@ -2,7 +2,7 @@ import { FieldsOf } from '@aztec/circuits.js'; import { ContractAbi } from '@aztec/foundation/abi'; import { TxHash, TxReceipt } from '@aztec/types'; -import { AztecAddress, AztecRPC, Contract, ContractBase, SentTx, WaitOpts, Wallet } from '../index.js'; +import { AztecAddress, Contract, ContractBase, PXE, SentTx, WaitOpts, Wallet } from '../index.js'; /** Options related to waiting for a deployment tx. */ export type DeployedWaitOpts = WaitOpts & { @@ -20,7 +20,7 @@ export type DeployTxReceipt = FieldsO * A contract deployment transaction sent to the network, extending SentTx with methods to create a contract instance. */ export class DeploySentTx extends SentTx { - constructor(private abi: ContractAbi, wallet: AztecRPC | Wallet, txHashPromise: Promise) { + constructor(private abi: ContractAbi, wallet: PXE | Wallet, txHashPromise: Promise) { super(wallet, txHashPromise); } @@ -46,8 +46,8 @@ export class DeploySentTx extends Sen } protected getContractInstance(wallet?: Wallet, address?: AztecAddress): Promise { - const isWallet = (rpc: AztecRPC | Wallet): rpc is Wallet => !!(rpc as Wallet).createTxExecutionRequest; - const contractWallet = wallet ?? (isWallet(this.arc) && this.arc); + const isWallet = (pxe: PXE | Wallet): pxe is Wallet => !!(pxe as Wallet).createTxExecutionRequest; + const contractWallet = wallet ?? (isWallet(this.pxe) && this.pxe); if (!contractWallet) throw new Error(`A wallet is required for creating a contract instance`); if (!address) throw new Error(`Contract address is missing from transaction receipt`); return Contract.at(address, this.abi, contractWallet) as Promise; diff --git a/yarn-project/aztec.js/src/index.ts b/yarn-project/aztec.js/src/index.ts index 85f2a9ee9af..f4706d11bfa 100644 --- a/yarn-project/aztec.js/src/index.ts +++ b/yarn-project/aztec.js/src/index.ts @@ -1,7 +1,7 @@ export * from './contract/index.js'; export * from './contract_deployer/index.js'; export * from './utils/index.js'; -export * from './aztec_rpc_client.js'; +export * from './pxe_client.js'; export * from './account/index.js'; export * from './contract_deployer/deploy_method.js'; export * from './sandbox/index.js'; @@ -9,7 +9,7 @@ export * from './wallet/index.js'; export { AztecAddress, EthAddress, Point, Fr, GrumpkinScalar } from '@aztec/circuits.js'; export { - AztecRPC, + PXE, ContractData, ExtendedContractData as ExtendedContractData, DeployedContract, diff --git a/yarn-project/aztec.js/src/aztec_rpc_client.ts b/yarn-project/aztec.js/src/pxe_client.ts similarity index 84% rename from yarn-project/aztec.js/src/aztec_rpc_client.ts rename to yarn-project/aztec.js/src/pxe_client.ts index 511ed931282..0514626c1a9 100644 --- a/yarn-project/aztec.js/src/aztec_rpc_client.ts +++ b/yarn-project/aztec.js/src/pxe_client.ts @@ -2,12 +2,12 @@ import { AztecAddress, CompleteAddress, EthAddress, Fr, GrumpkinScalar, Point } import { createJsonRpcClient, makeFetch } from '@aztec/foundation/json-rpc/client'; import { AuthWitness, - AztecRPC, ContractData, ExtendedContractData, L2BlockL2Logs, L2Tx, NotePreimage, + PXE, Tx, TxExecutionRequest, TxHash, @@ -16,8 +16,8 @@ import { export { makeFetch } from '@aztec/foundation/json-rpc/client'; -export const createAztecRpcClient = (url: string, fetch = makeFetch([1, 2, 3], true)): AztecRPC => - createJsonRpcClient( +export const createPXEClient = (url: string, fetch = makeFetch([1, 2, 3], true)): PXE => + createJsonRpcClient( url, { CompleteAddress, diff --git a/yarn-project/aztec.js/src/sandbox/index.ts b/yarn-project/aztec.js/src/sandbox/index.ts index 2dd17107819..e94cbca275c 100644 --- a/yarn-project/aztec.js/src/sandbox/index.ts +++ b/yarn-project/aztec.js/src/sandbox/index.ts @@ -4,7 +4,7 @@ import { sleep } from '@aztec/foundation/sleep'; import zip from 'lodash.zip'; import SchnorrAccountContractAbi from '../abis/schnorr_account_contract.json' assert { type: 'json' }; -import { AccountWallet, AztecRPC, createAztecRpcClient, getSchnorrAccount } from '../index.js'; +import { AccountWallet, PXE, createPXEClient, getSchnorrAccount } from '../index.js'; export const INITIAL_SANDBOX_ENCRYPTION_KEYS = [ GrumpkinScalar.fromString('2153536ff6628eee01cf4024889ff977a18d9fa61d0e414422f7681cf085c281'), @@ -22,25 +22,25 @@ export const { SANDBOX_URL = 'http://localhost:8080' } = process.env; /** * Gets a collection of wallets for the Aztec accounts that are initially stored in the sandbox. - * @param aztecRpc - An instance of the Aztec RPC interface. + * @param pxe - PXE instance. * @returns A set of AccountWallet implementations for each of the initial accounts. */ -export function getSandboxAccountsWallets(aztecRpc: AztecRPC): Promise { +export function getSandboxAccountsWallets(pxe: PXE): Promise { return Promise.all( zip(INITIAL_SANDBOX_ENCRYPTION_KEYS, INITIAL_SANDBOX_SIGNING_KEYS, INITIAL_SANDBOX_SALTS).map( - ([encryptionKey, signingKey, salt]) => getSchnorrAccount(aztecRpc, encryptionKey!, signingKey!, salt).getWallet(), + ([encryptionKey, signingKey, salt]) => getSchnorrAccount(pxe, encryptionKey!, signingKey!, salt).getWallet(), ), ); } /** * Deploys the initial set of schnorr signature accounts to the sandbox - * @param aztecRpc - An instance of the Aztec RPC interface. + * @param pxe - PXE instance. * @returns The set of deployed Account objects and associated private encryption keys */ -export async function deployInitialSandboxAccounts(aztecRpc: AztecRPC) { +export async function deployInitialSandboxAccounts(pxe: PXE) { const accounts = INITIAL_SANDBOX_ENCRYPTION_KEYS.map((privateKey, i) => { - const account = getSchnorrAccount(aztecRpc, privateKey, INITIAL_SANDBOX_SIGNING_KEYS[i], INITIAL_SANDBOX_SALTS[i]); + const account = getSchnorrAccount(pxe, privateKey, INITIAL_SANDBOX_SIGNING_KEYS[i], INITIAL_SANDBOX_SALTS[i]); return { account, privateKey, @@ -70,13 +70,13 @@ export async function deployInitialSandboxAccounts(aztecRpc: AztecRPC) { /** * Function to wait until the sandbox becomes ready for use. - * @param rpc - The rpc client connected to the sandbox. + * @param pxe - The pxe client connected to the sandbox. */ -export async function waitForSandbox(rpc?: AztecRPC) { - rpc = rpc ?? createAztecRpcClient(SANDBOX_URL); +export async function waitForSandbox(pxe?: PXE) { + pxe = pxe ?? createPXEClient(SANDBOX_URL); while (true) { try { - await rpc.getNodeInfo(); + await pxe.getNodeInfo(); break; } catch (err) { await sleep(1000); diff --git a/yarn-project/aztec.js/src/utils/cheat_codes.ts b/yarn-project/aztec.js/src/utils/cheat_codes.ts index dc0dfee94fb..32013adebe6 100644 --- a/yarn-project/aztec.js/src/utils/cheat_codes.ts +++ b/yarn-project/aztec.js/src/utils/cheat_codes.ts @@ -3,7 +3,7 @@ import { pedersenPlookupCommitInputs } from '@aztec/circuits.js/barretenberg'; import { toBigIntBE, toHex } from '@aztec/foundation/bigint-buffer'; import { keccak } from '@aztec/foundation/crypto'; import { createDebugLogger } from '@aztec/foundation/log'; -import { AztecRPC, NotePreimage } from '@aztec/types'; +import { NotePreimage, PXE } from '@aztec/types'; import fs from 'fs'; @@ -22,9 +22,9 @@ export class CheatCodes { public aztec: AztecCheatCodes, ) {} - static async create(rpcUrl: string, aztecRpc: AztecRPC): Promise { + static async create(rpcUrl: string, pxe: PXE): Promise { const ethCheatCodes = new EthCheatCodes(rpcUrl); - const aztecCheatCodes = new AztecCheatCodes(aztecRpc, await CircuitsWasm.get(), ethCheatCodes); + const aztecCheatCodes = new AztecCheatCodes(pxe, await CircuitsWasm.get(), ethCheatCodes); return new CheatCodes(ethCheatCodes, aztecCheatCodes); } } @@ -35,7 +35,7 @@ export class CheatCodes { export class EthCheatCodes { constructor( /** - * The RPC client to use for interacting with the chain + * The RPC URL to use for interacting with the chain */ public rpcUrl: string, /** @@ -209,9 +209,9 @@ export class EthCheatCodes { export class AztecCheatCodes { constructor( /** - * The RPC client to use for interacting with the chain + * The PXE Service to use for interacting with the chain */ - public aztecRpc: AztecRPC, + public pxe: PXE, /** * The circuits wasm module used for pedersen hashing */ @@ -248,7 +248,7 @@ export class AztecCheatCodes { * @returns The current block number */ public async blockNumber(): Promise { - return await this.aztecRpc.getBlockNumber(); + return await this.pxe.getBlockNumber(); } /** @@ -257,7 +257,7 @@ export class AztecCheatCodes { * @param to - The timestamp to set the next block to (must be greater than current time) */ public async warp(to: number): Promise { - const rollupContract = (await this.aztecRpc.getNodeInfo()).l1ContractAddresses.rollupAddress; + const rollupContract = (await this.pxe.getNodeInfo()).l1ContractAddresses.rollupAddress; await this.eth.setNextBlockTimestamp(to); // also store this time on the rollup contract (slot 1 tracks `lastBlockTs`). // This is because when the sequencer executes public functions, it uses the timestamp stored in the rollup contract. @@ -273,7 +273,7 @@ export class AztecCheatCodes { * @returns The value stored at the given slot */ public async loadPublic(who: AztecAddress, slot: Fr | bigint): Promise { - const storageValue = await this.aztecRpc.getPublicStorageAt(who, new Fr(slot)); + const storageValue = await this.pxe.getPublicStorageAt(who, new Fr(slot)); if (storageValue === undefined) { throw new Error(`Storage slot ${slot} not found`); } @@ -288,6 +288,6 @@ export class AztecCheatCodes { * @returns The notes stored at the given slot */ public loadPrivate(owner: AztecAddress, contract: AztecAddress, slot: Fr | bigint): Promise { - return this.aztecRpc.getPrivateStorageAt(owner, contract, new Fr(slot)); + return this.pxe.getPrivateStorageAt(owner, contract, new Fr(slot)); } } diff --git a/yarn-project/aztec.js/src/utils/l2_contracts.ts b/yarn-project/aztec.js/src/utils/l2_contracts.ts index b15e5dd3c06..67fcdb2851b 100644 --- a/yarn-project/aztec.js/src/utils/l2_contracts.ts +++ b/yarn-project/aztec.js/src/utils/l2_contracts.ts @@ -1,12 +1,12 @@ import { AztecAddress } from '@aztec/foundation/aztec-address'; -import { AztecRPC } from '@aztec/types'; +import { PXE } from '@aztec/types'; /** * Checks whether a give contract is deployed on the network. - * @param aztecRpcClient - The aztec rpc client to use to obtain the information. + * @param pxe - The PXE to use to obtain the information. * @param contractAddress - The address of the contract to check. * @returns A flag indicating whether the contract is deployed. */ -export async function isContractDeployed(aztecRpcClient: AztecRPC, contractAddress: AztecAddress): Promise { - return !!(await aztecRpcClient.getContractData(contractAddress)); +export async function isContractDeployed(pxe: PXE, contractAddress: AztecAddress): Promise { + return !!(await pxe.getContractData(contractAddress)); } diff --git a/yarn-project/aztec.js/src/wallet/account_wallet.ts b/yarn-project/aztec.js/src/wallet/account_wallet.ts index de4902b1c84..f51fb13307b 100644 --- a/yarn-project/aztec.js/src/wallet/account_wallet.ts +++ b/yarn-project/aztec.js/src/wallet/account_wallet.ts @@ -1,6 +1,6 @@ import { Fr } from '@aztec/circuits.js'; import { ABIParameterVisibility, FunctionAbiHeader, FunctionType } from '@aztec/foundation/abi'; -import { AuthWitness, AztecRPC, FunctionCall, TxExecutionRequest } from '@aztec/types'; +import { AuthWitness, FunctionCall, PXE, TxExecutionRequest } from '@aztec/types'; import { AccountInterface } from '../account/interface.js'; import { ContractFunctionInteraction } from '../index.js'; @@ -10,8 +10,8 @@ import { BaseWallet } from './base_wallet.js'; * A wallet implementation that forwards authentication requests to a provided account. */ export class AccountWallet extends BaseWallet { - constructor(rpc: AztecRPC, protected account: AccountInterface) { - super(rpc); + constructor(pxe: PXE, protected account: AccountInterface) { + super(pxe); } createTxExecutionRequest(execs: FunctionCall[]): Promise { @@ -21,7 +21,7 @@ export class AccountWallet extends BaseWallet { async createAuthWitness(message: Fr | Buffer): Promise { message = Buffer.isBuffer(message) ? Fr.fromBuffer(message) : message; const witness = await this.account.createAuthWitness(message); - await this.rpc.addAuthWitness(witness); + await this.pxe.addAuthWitness(witness); return witness; } diff --git a/yarn-project/aztec.js/src/wallet/base_wallet.ts b/yarn-project/aztec.js/src/wallet/base_wallet.ts index fe17337651f..56cce1ea25c 100644 --- a/yarn-project/aztec.js/src/wallet/base_wallet.ts +++ b/yarn-project/aztec.js/src/wallet/base_wallet.ts @@ -1,7 +1,6 @@ import { AztecAddress, Fr, GrumpkinPrivateKey, PartialAddress, Point } from '@aztec/circuits.js'; import { AuthWitness, - AztecRPC, ContractData, DeployedContract, ExtendedContractData, @@ -10,6 +9,7 @@ import { L2Tx, NodeInfo, NotePreimage, + PXE, SyncStatus, Tx, TxExecutionRequest, @@ -24,7 +24,7 @@ import { Wallet } from './index.js'; * A base class for Wallet implementations */ export abstract class BaseWallet implements Wallet { - constructor(protected readonly rpc: AztecRPC) {} + constructor(protected readonly pxe: PXE) {} abstract getCompleteAddress(): CompleteAddress; @@ -33,81 +33,81 @@ export abstract class BaseWallet implements Wallet { abstract createAuthWitness(message: Fr): Promise; registerAccount(privKey: GrumpkinPrivateKey, partialAddress: PartialAddress): Promise { - return this.rpc.registerAccount(privKey, partialAddress); + return this.pxe.registerAccount(privKey, partialAddress); } registerRecipient(account: CompleteAddress): Promise { - return this.rpc.registerRecipient(account); + return this.pxe.registerRecipient(account); } getRegisteredAccounts(): Promise { - return this.rpc.getRegisteredAccounts(); + return this.pxe.getRegisteredAccounts(); } getRegisteredAccount(address: AztecAddress): Promise { - return this.rpc.getRegisteredAccount(address); + return this.pxe.getRegisteredAccount(address); } getRecipients(): Promise { - return this.rpc.getRecipients(); + return this.pxe.getRecipients(); } getRecipient(address: AztecAddress): Promise { - return this.rpc.getRecipient(address); + return this.pxe.getRecipient(address); } addContracts(contracts: DeployedContract[]): Promise { - return this.rpc.addContracts(contracts); + return this.pxe.addContracts(contracts); } getContracts(): Promise { - return this.rpc.getContracts(); + return this.pxe.getContracts(); } simulateTx(txRequest: TxExecutionRequest, simulatePublic: boolean): Promise { - return this.rpc.simulateTx(txRequest, simulatePublic); + return this.pxe.simulateTx(txRequest, simulatePublic); } sendTx(tx: Tx): Promise { - return this.rpc.sendTx(tx); + return this.pxe.sendTx(tx); } getTx(txHash: TxHash): Promise { - return this.rpc.getTx(txHash); + return this.pxe.getTx(txHash); } getTxReceipt(txHash: TxHash): Promise { - return this.rpc.getTxReceipt(txHash); + return this.pxe.getTxReceipt(txHash); } getPrivateStorageAt(owner: AztecAddress, contract: AztecAddress, storageSlot: Fr): Promise { - return this.rpc.getPrivateStorageAt(owner, contract, storageSlot); + return this.pxe.getPrivateStorageAt(owner, contract, storageSlot); } getPublicStorageAt(contract: AztecAddress, storageSlot: Fr): Promise { - return this.rpc.getPublicStorageAt(contract, storageSlot); + return this.pxe.getPublicStorageAt(contract, storageSlot); } addNote(contract: AztecAddress, storageSlot: Fr, preimage: NotePreimage, nonce: Fr, account: Point): Promise { - return this.rpc.addNote(contract, storageSlot, preimage, nonce, account); + return this.pxe.addNote(contract, storageSlot, preimage, nonce, account); } getNoteNonces(contract: AztecAddress, storageSlot: Fr, preimage: NotePreimage, txHash: TxHash): Promise { - return this.rpc.getNoteNonces(contract, storageSlot, preimage, txHash); + return this.pxe.getNoteNonces(contract, storageSlot, preimage, txHash); } viewTx(functionName: string, args: any[], to: AztecAddress, from?: AztecAddress | undefined): Promise { - return this.rpc.viewTx(functionName, args, to, from); + return this.pxe.viewTx(functionName, args, to, from); } getExtendedContractData(contractAddress: AztecAddress): Promise { - return this.rpc.getExtendedContractData(contractAddress); + return this.pxe.getExtendedContractData(contractAddress); } getContractData(contractAddress: AztecAddress): Promise { - return this.rpc.getContractData(contractAddress); + return this.pxe.getContractData(contractAddress); } getUnencryptedLogs(from: number, limit: number): Promise { - return this.rpc.getUnencryptedLogs(from, limit); + return this.pxe.getUnencryptedLogs(from, limit); } getBlockNumber(): Promise { - return this.rpc.getBlockNumber(); + return this.pxe.getBlockNumber(); } getNodeInfo(): Promise { - return this.rpc.getNodeInfo(); + return this.pxe.getNodeInfo(); } isGlobalStateSynchronized() { - return this.rpc.isGlobalStateSynchronized(); + return this.pxe.isGlobalStateSynchronized(); } isAccountStateSynchronized(account: AztecAddress) { - return this.rpc.isAccountStateSynchronized(account); + return this.pxe.isAccountStateSynchronized(account); } getSyncStatus(): Promise { - return this.rpc.getSyncStatus(); + return this.pxe.getSyncStatus(); } addAuthWitness(authWitness: AuthWitness) { - return this.rpc.addAuthWitness(authWitness); + return this.pxe.addAuthWitness(authWitness); } } diff --git a/yarn-project/aztec.js/src/wallet/index.ts b/yarn-project/aztec.js/src/wallet/index.ts index d1cab61cc62..fa43fcb1a97 100644 --- a/yarn-project/aztec.js/src/wallet/index.ts +++ b/yarn-project/aztec.js/src/wallet/index.ts @@ -1,4 +1,4 @@ -import { AccountInterface, AztecRPC } from '../index.js'; +import { AccountInterface, PXE } from '../index.js'; export * from './base_wallet.js'; export * from './account_wallet.js'; @@ -7,4 +7,4 @@ export * from './signerless_wallet.js'; /** * The wallet interface. */ -export type Wallet = AccountInterface & AztecRPC; +export type Wallet = AccountInterface & PXE; diff --git a/yarn-project/aztec.js/src/wallet/signerless_wallet.ts b/yarn-project/aztec.js/src/wallet/signerless_wallet.ts index 6de0eec702e..03368dd8611 100644 --- a/yarn-project/aztec.js/src/wallet/signerless_wallet.ts +++ b/yarn-project/aztec.js/src/wallet/signerless_wallet.ts @@ -15,7 +15,7 @@ export class SignerlessWallet extends BaseWallet { const [execution] = executions; const wasm = await CircuitsWasm.get(); const packedArguments = await PackedArguments.fromArgs(execution.args, wasm); - const { chainId, protocolVersion } = await this.rpc.getNodeInfo(); + const { chainId, protocolVersion } = await this.pxe.getNodeInfo(); const txContext = TxContext.empty(chainId, protocolVersion); return Promise.resolve( new TxExecutionRequest( diff --git a/yarn-project/boxes/blank-react/docker-compose.yml b/yarn-project/boxes/blank-react/docker-compose.yml index 082455b5d38..2417ca77775 100644 --- a/yarn-project/boxes/blank-react/docker-compose.yml +++ b/yarn-project/boxes/blank-react/docker-compose.yml @@ -19,7 +19,7 @@ services: P2P_BLOCK_CHECK_INTERVAL_MS: 50 SEQ_TX_POLLING_INTERVAL_MS: 50 WS_BLOCK_CHECK_INTERVAL_MS: 50 - RPC_SERVER_BLOCK_POLLING_INTERVAL_MS: 50 + PXE_SERVICE_BLOCK_POLLING_INTERVAL_MS: 50 ARCHIVER_VIEM_POLLING_INTERVAL_MS: 500 volumes: - ./log:/usr/src/yarn-project/aztec-sandbox/log:rw diff --git a/yarn-project/boxes/blank-react/src/app/components/wallet_dropdown.tsx b/yarn-project/boxes/blank-react/src/app/components/wallet_dropdown.tsx index 131dc2c8d72..852ae9ffcb4 100644 --- a/yarn-project/boxes/blank-react/src/app/components/wallet_dropdown.tsx +++ b/yarn-project/boxes/blank-react/src/app/components/wallet_dropdown.tsx @@ -1,7 +1,7 @@ import { Loader } from '@aztec/aztec-ui'; import { CompleteAddress } from '@aztec/aztec.js'; import { useEffect, useState } from 'react'; -import { rpcClient } from '../../config.js'; +import { pxe } from '../../config.js'; import { Select } from './select.js'; import styles from './wallet_dropdown.module.scss'; import { Copy } from './copy.js'; @@ -20,7 +20,7 @@ export function WalletDropdown({ selected, onSelectChange, onError }: Props) { return; } const loadOptions = async () => { - const fetchedOptions = await rpcClient.getRegisteredAccounts(); + const fetchedOptions = await pxe.getRegisteredAccounts(); setOptions(fetchedOptions); onSelectChange(fetchedOptions[0]); }; diff --git a/yarn-project/boxes/blank-react/src/artifacts/blank.ts b/yarn-project/boxes/blank-react/src/artifacts/blank.ts index ce41cd8e217..2003f379bfe 100644 --- a/yarn-project/boxes/blank-react/src/artifacts/blank.ts +++ b/yarn-project/boxes/blank-react/src/artifacts/blank.ts @@ -13,7 +13,7 @@ import { } from '@aztec/aztec.js'; import { ContractAbi } from '@aztec/foundation/abi'; import { Point } from '@aztec/foundation/fields'; -import { AztecRPC, PublicKey } from '@aztec/types'; +import { PXE, PublicKey } from '@aztec/types'; import BlankContractAbiJson from './blank_contract.json' assert { type: 'json' }; @@ -54,15 +54,15 @@ export class BlankContract extends ContractBase { /** * Creates a tx to deploy a new instance of this contract. */ - public static deploy(rpc: AztecRPC) { - return new DeployMethod(Point.ZERO, rpc, BlankContractAbi, Array.from(arguments).slice(1)); + public static deploy(pxe: PXE) { + return new DeployMethod(Point.ZERO, pxe, BlankContractAbi, Array.from(arguments).slice(1)); } /** * Creates a tx to deploy a new instance of this contract using the specified public key to derive the address. */ - public static deployWithPublicKey(rpc: AztecRPC, publicKey: PublicKey) { - return new DeployMethod(publicKey, rpc, BlankContractAbi, Array.from(arguments).slice(2)); + public static deployWithPublicKey(pxe: PXE, publicKey: PublicKey) { + return new DeployMethod(publicKey, pxe, BlankContractAbi, Array.from(arguments).slice(2)); } /** diff --git a/yarn-project/boxes/blank-react/src/config.ts b/yarn-project/boxes/blank-react/src/config.ts index ad3ac03c902..2c406a9302b 100644 --- a/yarn-project/boxes/blank-react/src/config.ts +++ b/yarn-project/boxes/blank-react/src/config.ts @@ -1,5 +1,5 @@ import { BlankContractAbi } from './artifacts/blank.js'; -import { AztecRPC, createAztecRpcClient } from '@aztec/aztec.js'; +import { PXE, createPXEClient } from '@aztec/aztec.js'; import { ContractAbi } from '@aztec/foundation/abi'; // update this if using a different contract @@ -7,7 +7,7 @@ import { ContractAbi } from '@aztec/foundation/abi'; export const contractAbi: ContractAbi = BlankContractAbi; export const SANDBOX_URL: string = process.env.SANDBOX_URL || 'http://localhost:8080'; -export const rpcClient: AztecRPC = createAztecRpcClient(SANDBOX_URL); +export const pxe: PXE = createPXEClient(SANDBOX_URL); export const CONTRACT_ADDRESS_PARAM_NAMES = ['address']; export const FILTERED_FUNCTION_NAMES = []; diff --git a/yarn-project/boxes/blank-react/src/scripts/call_contract_function.ts b/yarn-project/boxes/blank-react/src/scripts/call_contract_function.ts index dbc4d87e6fd..eee3953023a 100644 --- a/yarn-project/boxes/blank-react/src/scripts/call_contract_function.ts +++ b/yarn-project/boxes/blank-react/src/scripts/call_contract_function.ts @@ -1,4 +1,4 @@ -import { AztecAddress, AztecRPC, CompleteAddress, Contract, TxReceipt } from '@aztec/aztec.js'; +import { AztecAddress, PXE, CompleteAddress, Contract, TxReceipt } from '@aztec/aztec.js'; import { ContractAbi } from '@aztec/foundation/abi'; import { FieldsOf } from '@aztec/foundation/types'; import { getWallet } from './util.js'; @@ -8,11 +8,11 @@ export async function callContractFunction( abi: ContractAbi, functionName: string, typedArgs: any[], // for the exposed functions, this is an array of field elements Fr[] - rpc: AztecRPC, + pxe: PXE, wallet: CompleteAddress, ): Promise> { // selectedWallet is how we specify the "sender" of the transaction - const selectedWallet = await getWallet(wallet, rpc); + const selectedWallet = await getWallet(wallet, pxe); // TODO: switch to the generated typescript class? const contract = await Contract.at(address, abi, selectedWallet); diff --git a/yarn-project/boxes/blank-react/src/scripts/deploy_contract.ts b/yarn-project/boxes/blank-react/src/scripts/deploy_contract.ts index 2285937d2e1..7a0dc7d4d76 100644 --- a/yarn-project/boxes/blank-react/src/scripts/deploy_contract.ts +++ b/yarn-project/boxes/blank-react/src/scripts/deploy_contract.ts @@ -1,15 +1,15 @@ import { AztecAddress, CompleteAddress, DeployMethod, Fr } from '@aztec/aztec.js'; import { ContractAbi } from '@aztec/foundation/abi'; -import { AztecRPC } from '@aztec/types'; +import { PXE } from '@aztec/types'; export async function deployContract( activeWallet: CompleteAddress, contractAbi: ContractAbi, typedArgs: Fr[], // encode prior to passing in salt: Fr, - client: AztecRPC, + pxe: PXE, ): Promise { - const tx = new DeployMethod(activeWallet.publicKey, client, contractAbi, typedArgs).send({ + const tx = new DeployMethod(activeWallet.publicKey, pxe, contractAbi, typedArgs).send({ contractAddressSalt: salt, }); await tx.wait(); diff --git a/yarn-project/boxes/blank-react/src/scripts/util.ts b/yarn-project/boxes/blank-react/src/scripts/util.ts index cadf2d05afa..cac4d8afddc 100644 --- a/yarn-project/boxes/blank-react/src/scripts/util.ts +++ b/yarn-project/boxes/blank-react/src/scripts/util.ts @@ -1,6 +1,6 @@ import { AccountWallet, Fr, getSandboxAccountsWallets } from '@aztec/aztec.js'; import { FunctionAbi, encodeArguments } from '@aztec/foundation/abi'; -import { AztecRPC, CompleteAddress } from '@aztec/types'; +import { PXE, CompleteAddress } from '@aztec/types'; export function convertArgs(functionAbi: FunctionAbi, args: any): Fr[] { const untypedArgs = functionAbi.parameters.map(param => { @@ -23,14 +23,14 @@ export function convertArgs(functionAbi: FunctionAbi, args: any): Fr[] { * while the "wallet" has the account's private key and is used to sign transactions * we need the "wallet" to actually submit transactions using the "account" identity * @param account - * @param rpc + * @param pxe * @returns */ -export async function getWallet(account: CompleteAddress, rpc: AztecRPC): Promise { - const accountWallets: AccountWallet[] = await getSandboxAccountsWallets(rpc); +export async function getWallet(account: CompleteAddress, pxe: PXE): Promise { + const accountWallets: AccountWallet[] = await getSandboxAccountsWallets(pxe); const selectedWallet: AccountWallet = accountWallets.find(w => w.getAddress().equals(account.address))!; if (!selectedWallet) { - throw new Error(`Wallet for account ${account.address.toShortString()} not found in the RPC server.`); + throw new Error(`Wallet for account ${account.address.toShortString()} not found in the PXE.`); } return selectedWallet; } diff --git a/yarn-project/boxes/blank-react/src/scripts/view_contract_function.ts b/yarn-project/boxes/blank-react/src/scripts/view_contract_function.ts index 8c6d966861a..79bd9b16f92 100644 --- a/yarn-project/boxes/blank-react/src/scripts/view_contract_function.ts +++ b/yarn-project/boxes/blank-react/src/scripts/view_contract_function.ts @@ -1,5 +1,5 @@ import { getWallet } from './util.js'; -import { AztecAddress, AztecRPC, CompleteAddress, Contract } from '@aztec/aztec.js'; +import { AztecAddress, PXE, CompleteAddress, Contract } from '@aztec/aztec.js'; import { ContractAbi } from '@aztec/foundation/abi'; export async function viewContractFunction( @@ -7,11 +7,11 @@ export async function viewContractFunction( abi: ContractAbi, functionName: string, typedArgs: any[], - rpc: AztecRPC, + pxe: PXE, wallet: CompleteAddress, ) { // we specify the account that is calling the view function by passing in the wallet to the Contract - const selectedWallet = await getWallet(wallet, rpc); + const selectedWallet = await getWallet(wallet, pxe); const contract = await Contract.at(address, abi, selectedWallet); return await contract.methods[functionName](...typedArgs).view({ from: wallet.address }); diff --git a/yarn-project/boxes/blank-react/src/tests/blank.contract.test.ts b/yarn-project/boxes/blank-react/src/tests/blank.contract.test.ts index fd75a97b07d..7f1eed6e2c8 100644 --- a/yarn-project/boxes/blank-react/src/tests/blank.contract.test.ts +++ b/yarn-project/boxes/blank-react/src/tests/blank.contract.test.ts @@ -3,32 +3,32 @@ import { callContractFunction, deployContract, getWallet } from '../scripts/inde import { AccountWallet, AztecAddress, - AztecRPC, + PXE, CompleteAddress, Contract, Fr, TxStatus, Wallet, - createAztecRpcClient, + createPXEClient, waitForSandbox, } from '@aztec/aztec.js'; import { createDebugLogger } from '@aztec/foundation/log'; -const logger = createDebugLogger('aztec:http-rpc-client'); +const logger = createDebugLogger('aztec:http-pxe-client'); // assumes sandbox is running locally, which this script does not trigger // as well as anvil. anvil can be started with yarn test:integration const setupSandbox = async () => { const { SANDBOX_URL = 'http://localhost:8080' } = process.env; - const aztecRpc = createAztecRpcClient(SANDBOX_URL); - await waitForSandbox(aztecRpc); + const pxe = createPXEClient(SANDBOX_URL); + await waitForSandbox(pxe); - return aztecRpc; + return pxe; }; -async function deployZKContract(owner: CompleteAddress, wallet: Wallet, rpcClient: AztecRPC) { +async function deployZKContract(owner: CompleteAddress, wallet: Wallet, pxe: PXE) { logger('Deploying Blank contract...'); - const contractAddress = await deployContract(owner, BlankContract.abi, [], Fr.random(), rpcClient); + const contractAddress = await deployContract(owner, BlankContract.abi, [], Fr.random(), pxe); logger(`L2 contract deployed at ${contractAddress}`); return BlankContract.at(contractAddress, wallet); @@ -41,16 +41,16 @@ describe('ZK Contract Tests', () => { let _account3: CompleteAddress; let contract: Contract; let contractAddress: AztecAddress; - let rpcClient: AztecRPC; + let pxe: PXE; beforeAll(async () => { - rpcClient = await setupSandbox(); - const accounts = await rpcClient.getRegisteredAccounts(); + pxe = await setupSandbox(); + const accounts = await pxe.getRegisteredAccounts(); [owner, _account2, _account3] = accounts; - wallet = await getWallet(owner, rpcClient); + wallet = await getWallet(owner, pxe); - contract = await deployZKContract(owner, wallet, rpcClient); + contract = await deployZKContract(owner, wallet, pxe); contractAddress = contract.address; }, 60000); @@ -60,7 +60,7 @@ describe('ZK Contract Tests', () => { contract.abi, 'getPublicKey', [owner.address.toField()], - rpcClient, + pxe, owner, ); diff --git a/yarn-project/boxes/blank/docker-compose.yml b/yarn-project/boxes/blank/docker-compose.yml index a4a84bbb4da..923aed602d3 100644 --- a/yarn-project/boxes/blank/docker-compose.yml +++ b/yarn-project/boxes/blank/docker-compose.yml @@ -19,7 +19,7 @@ services: P2P_BLOCK_CHECK_INTERVAL_MS: 50 SEQ_TX_POLLING_INTERVAL_MS: 50 WS_BLOCK_CHECK_INTERVAL_MS: 50 - RPC_SERVER_BLOCK_POLLING_INTERVAL_MS: 50 + PXE_SERVICE_BLOCK_POLLING_INTERVAL_MS: 50 ARCHIVER_VIEM_POLLING_INTERVAL_MS: 500 volumes: - ./log:/usr/src/yarn-project/aztec-sandbox/log:rw diff --git a/yarn-project/boxes/blank/src/artifacts/blank.ts b/yarn-project/boxes/blank/src/artifacts/blank.ts index ce41cd8e217..2003f379bfe 100644 --- a/yarn-project/boxes/blank/src/artifacts/blank.ts +++ b/yarn-project/boxes/blank/src/artifacts/blank.ts @@ -13,7 +13,7 @@ import { } from '@aztec/aztec.js'; import { ContractAbi } from '@aztec/foundation/abi'; import { Point } from '@aztec/foundation/fields'; -import { AztecRPC, PublicKey } from '@aztec/types'; +import { PXE, PublicKey } from '@aztec/types'; import BlankContractAbiJson from './blank_contract.json' assert { type: 'json' }; @@ -54,15 +54,15 @@ export class BlankContract extends ContractBase { /** * Creates a tx to deploy a new instance of this contract. */ - public static deploy(rpc: AztecRPC) { - return new DeployMethod(Point.ZERO, rpc, BlankContractAbi, Array.from(arguments).slice(1)); + public static deploy(pxe: PXE) { + return new DeployMethod(Point.ZERO, pxe, BlankContractAbi, Array.from(arguments).slice(1)); } /** * Creates a tx to deploy a new instance of this contract using the specified public key to derive the address. */ - public static deployWithPublicKey(rpc: AztecRPC, publicKey: PublicKey) { - return new DeployMethod(publicKey, rpc, BlankContractAbi, Array.from(arguments).slice(2)); + public static deployWithPublicKey(pxe: PXE, publicKey: PublicKey) { + return new DeployMethod(publicKey, pxe, BlankContractAbi, Array.from(arguments).slice(2)); } /** diff --git a/yarn-project/boxes/blank/src/index.ts b/yarn-project/boxes/blank/src/index.ts index a3bde8b5c11..67f3b7bbc10 100644 --- a/yarn-project/boxes/blank/src/index.ts +++ b/yarn-project/boxes/blank/src/index.ts @@ -1,13 +1,13 @@ import { AccountWallet, AztecAddress, - AztecRPC, + PXE, CompleteAddress, Contract, DeployMethod, Fr, TxReceipt, - createAztecRpcClient, + createPXEClient, getSandboxAccountsWallets, } from '@aztec/aztec.js'; import { ContractAbi, FunctionAbi, encodeArguments } from '@aztec/foundation/abi'; @@ -16,7 +16,7 @@ import { BlankContractAbi } from './artifacts/blank.js'; export const contractAbi: ContractAbi = BlankContractAbi; export const SANDBOX_URL: string = process.env.SANDBOX_URL || 'http://localhost:8080'; -export const rpcClient: AztecRPC = createAztecRpcClient(SANDBOX_URL); +export const pxe: PXE = createPXEClient(SANDBOX_URL); export const CONTRACT_ADDRESS_PARAM_NAMES = ['owner', 'contract_address', 'recipient']; export const FILTERED_FUNCTION_NAMES = []; @@ -40,21 +40,15 @@ if (typeof document !== 'undefined') { export async function handleDeployClick(): Promise { console.log('Deploying Contract'); - const [wallet, ..._rest] = await getSandboxAccountsWallets(rpcClient); + const [wallet, ..._rest] = await getSandboxAccountsWallets(pxe); - const contractAztecAddress = await deployContract( - wallet.getCompleteAddress(), - contractAbi, - [], - Fr.random(), - rpcClient, - ); + const contractAztecAddress = await deployContract(wallet.getCompleteAddress(), contractAbi, [], Fr.random(), pxe); return contractAztecAddress.toString(); } export async function handleInteractClick(contractAddress: string) { - const [wallet, ..._rest] = await getSandboxAccountsWallets(rpcClient); + const [wallet, ..._rest] = await getSandboxAccountsWallets(pxe); const callArgs = { address: wallet.getCompleteAddress().address }; const getPkAbi = getFunctionAbi(BlankContractAbi, 'getPublicKey'); const typedArgs = convertArgs(getPkAbi, callArgs); @@ -65,7 +59,7 @@ export async function handleInteractClick(contractAddress: string) { contractAbi, 'getPublicKey', typedArgs, - rpcClient, + pxe, wallet.getCompleteAddress(), ); } @@ -81,11 +75,11 @@ export async function callContractFunction( abi: ContractAbi, functionName: string, typedArgs: any[], // for the exposed functions, this is an array of field elements Fr[] - rpc: AztecRPC, + pxe: PXE, wallet: CompleteAddress, ): Promise> { // selectedWallet is how we specify the "sender" of the transaction - const selectedWallet = await getWallet(wallet, rpc); + const selectedWallet = await getWallet(wallet, pxe); // TODO: switch to the generated typescript class? const contract = await Contract.at(address, abi, selectedWallet); @@ -100,14 +94,14 @@ export async function callContractFunction( * while the "wallet" has the account's private key and is used to sign transactions * we need the "wallet" to actually submit transactions using the "account" identity * @param account - * @param rpc + * @param pxe * @returns */ -export async function getWallet(account: CompleteAddress, rpc: AztecRPC): Promise { - const accountWallets: AccountWallet[] = await getSandboxAccountsWallets(rpc); +export async function getWallet(account: CompleteAddress, pxe: PXE): Promise { + const accountWallets: AccountWallet[] = await getSandboxAccountsWallets(pxe); const selectedWallet: AccountWallet = accountWallets.find(w => w.getAddress().equals(account.address))!; if (!selectedWallet) { - throw new Error(`Wallet for account ${account.address.toShortString()} not found in the RPC server.`); + throw new Error(`Wallet for account ${account.address.toShortString()} not found in the PXE.`); } return selectedWallet; } @@ -117,7 +111,7 @@ export async function deployContract( contractAbi: ContractAbi, typedArgs: Fr[], // encode prior to passing in salt: Fr, - client: AztecRPC, + client: PXE, ): Promise { const tx = new DeployMethod(activeWallet.publicKey, client, contractAbi, typedArgs).send({ contractAddressSalt: salt, diff --git a/yarn-project/boxes/blank/src/tests/blank.contract.test.ts b/yarn-project/boxes/blank/src/tests/blank.contract.test.ts index 06dbe51ce95..883ef265369 100644 --- a/yarn-project/boxes/blank/src/tests/blank.contract.test.ts +++ b/yarn-project/boxes/blank/src/tests/blank.contract.test.ts @@ -1,13 +1,13 @@ import { AccountWallet, AztecAddress, - AztecRPC, + PXE, CompleteAddress, Contract, Fr, TxStatus, Wallet, - createAztecRpcClient, + createPXEClient, waitForSandbox, } from '@aztec/aztec.js'; import { createDebugLogger } from '@aztec/foundation/log'; @@ -19,14 +19,14 @@ const logger = createDebugLogger('aztec:blank-box-test'); // as well as anvil. anvil can be started with yarn test:integration const setupSandbox = async () => { const { SANDBOX_URL = 'http://localhost:8080' } = process.env; - const aztecRpc = createAztecRpcClient(SANDBOX_URL); - await waitForSandbox(aztecRpc); - return aztecRpc; + const pxe = createPXEClient(SANDBOX_URL); + await waitForSandbox(pxe); + return pxe; }; -async function deployZKContract(owner: CompleteAddress, wallet: Wallet, rpcClient: AztecRPC) { +async function deployZKContract(owner: CompleteAddress, wallet: Wallet, pxe: PXE) { logger('Deploying Blank contract...'); - const contractAddress = await deployContract(owner, BlankContract.abi, [], Fr.random(), rpcClient); + const contractAddress = await deployContract(owner, BlankContract.abi, [], Fr.random(), pxe); logger(`L2 contract deployed at ${contractAddress}`); return BlankContract.at(contractAddress, wallet); @@ -39,16 +39,16 @@ describe('ZK Contract Tests', () => { let _account3: CompleteAddress; let contract: Contract; let contractAddress: AztecAddress; - let rpcClient: AztecRPC; + let pxe: PXE; beforeAll(async () => { - rpcClient = await setupSandbox(); - const accounts = await rpcClient.getRegisteredAccounts(); + pxe = await setupSandbox(); + const accounts = await pxe.getRegisteredAccounts(); [owner, _account2, _account3] = accounts; - wallet = await getWallet(owner, rpcClient); + wallet = await getWallet(owner, pxe); - contract = await deployZKContract(owner, wallet, rpcClient); + contract = await deployZKContract(owner, wallet, pxe); contractAddress = contract.address; }, 60000); @@ -58,7 +58,7 @@ describe('ZK Contract Tests', () => { contract.abi, 'getPublicKey', [owner.address.toField()], - rpcClient, + pxe, owner, ); expect(callTxReceipt.status).toBe(TxStatus.MINED); diff --git a/yarn-project/boxes/private-token/docker-compose.yml b/yarn-project/boxes/private-token/docker-compose.yml index 52a8d9f5814..997eed0992b 100644 --- a/yarn-project/boxes/private-token/docker-compose.yml +++ b/yarn-project/boxes/private-token/docker-compose.yml @@ -19,7 +19,7 @@ services: P2P_BLOCK_CHECK_INTERVAL_MS: 50 SEQ_TX_POLLING_INTERVAL_MS: 50 WS_BLOCK_CHECK_INTERVAL_MS: 50 - RPC_SERVER_BLOCK_POLLING_INTERVAL_MS: 50 + PXE_SERVICE_BLOCK_POLLING_INTERVAL_MS: 50 ARCHIVER_VIEM_POLLING_INTERVAL_MS: 500 volumes: - ./log:/usr/src/yarn-project/aztec-sandbox/log:rw diff --git a/yarn-project/boxes/private-token/src/app/components/contract_function_form.tsx b/yarn-project/boxes/private-token/src/app/components/contract_function_form.tsx index 69916e7061e..860c99e45b0 100644 --- a/yarn-project/boxes/private-token/src/app/components/contract_function_form.tsx +++ b/yarn-project/boxes/private-token/src/app/components/contract_function_form.tsx @@ -1,12 +1,12 @@ +import { CONTRACT_ADDRESS_PARAM_NAMES, pxe } from '../../config.js'; +import { callContractFunction, deployContract, viewContractFunction } from '../../scripts/index.js'; +import { convertArgs } from '../../scripts/util.js'; +import styles from './contract_function_form.module.scss'; import { Button, Loader } from '@aztec/aztec-ui'; import { AztecAddress, CompleteAddress, Fr } from '@aztec/aztec.js'; import { ContractAbi, FunctionAbi } from '@aztec/foundation/abi'; import { useFormik } from 'formik'; import * as Yup from 'yup'; -import { CONTRACT_ADDRESS_PARAM_NAMES, rpcClient } from '../../config.js'; -import { callContractFunction, deployContract, viewContractFunction } from '../../scripts/index.js'; -import { convertArgs } from '../../scripts/util.js'; -import styles from './contract_function_form.module.scss'; type NoirFunctionYupSchema = { // hack: add `any` at the end to get the array schema to typecheck @@ -80,20 +80,13 @@ async function handleFunctionCall( // for now, dont let user change the salt. requires some change to the form generation if we want to let user choose one // since everything is currently based on parsing the contractABI, and the salt parameter is not present there const salt = Fr.random(); - return await deployContract(wallet, contractAbi, typedArgs, salt, rpcClient); + return await deployContract(wallet, contractAbi, typedArgs, salt, pxe); } if (functionAbi.functionType === 'unconstrained') { - return await viewContractFunction(contractAddress!, contractAbi, functionName, typedArgs, rpcClient, wallet); + return await viewContractFunction(contractAddress!, contractAbi, functionName, typedArgs, pxe, wallet); } else { - const txnReceipt = await callContractFunction( - contractAddress!, - contractAbi, - functionName, - typedArgs, - rpcClient, - wallet, - ); + const txnReceipt = await callContractFunction(contractAddress!, contractAbi, functionName, typedArgs, pxe, wallet); return `Transaction ${txnReceipt.status} on block number ${txnReceipt.blockNumber}`; } } diff --git a/yarn-project/boxes/private-token/src/app/components/copy.tsx b/yarn-project/boxes/private-token/src/app/components/copy.tsx index 4c497833bab..6caa3312159 100644 --- a/yarn-project/boxes/private-token/src/app/components/copy.tsx +++ b/yarn-project/boxes/private-token/src/app/components/copy.tsx @@ -1,5 +1,5 @@ -import { useState } from 'react'; import styles from './copy.module.scss'; +import { useState } from 'react'; export function Copy({ value }: { value: string }) { const [copied, setCopied] = useState(false); diff --git a/yarn-project/boxes/private-token/src/app/components/dropdown.tsx b/yarn-project/boxes/private-token/src/app/components/dropdown.tsx index 2d74e687c93..6470d2c80f3 100644 --- a/yarn-project/boxes/private-token/src/app/components/dropdown.tsx +++ b/yarn-project/boxes/private-token/src/app/components/dropdown.tsx @@ -1,7 +1,6 @@ -import { CSSProperties, useEffect, useRef } from 'react'; -import classnames from 'classnames'; - import style from './dropdown.module.scss'; +import classnames from 'classnames'; +import { CSSProperties, useEffect, useRef } from 'react'; export enum DropdownType { Simple = 'Simple', diff --git a/yarn-project/boxes/private-token/src/app/components/popup.tsx b/yarn-project/boxes/private-token/src/app/components/popup.tsx index cf9a1d8962a..bfbdc7d3f58 100644 --- a/yarn-project/boxes/private-token/src/app/components/popup.tsx +++ b/yarn-project/boxes/private-token/src/app/components/popup.tsx @@ -1,5 +1,5 @@ -import { Button } from '@aztec/aztec-ui'; import styles from './popup.module.scss'; +import { Button } from '@aztec/aztec-ui'; interface Props { children: string; diff --git a/yarn-project/boxes/private-token/src/app/components/select.tsx b/yarn-project/boxes/private-token/src/app/components/select.tsx index 81a4c0c7a97..562f5e12fdf 100644 --- a/yarn-project/boxes/private-token/src/app/components/select.tsx +++ b/yarn-project/boxes/private-token/src/app/components/select.tsx @@ -1,8 +1,7 @@ -import { useState, useEffect, useRef } from 'react'; -import classnames from 'classnames'; - import { DropdownOption, DropdownType, Dropdown } from './dropdown.js'; import style from './select.module.scss'; +import classnames from 'classnames'; +import { useState, useEffect, useRef } from 'react'; interface SelectProps { options: DropdownOption[]; diff --git a/yarn-project/boxes/private-token/src/app/components/wallet_dropdown.tsx b/yarn-project/boxes/private-token/src/app/components/wallet_dropdown.tsx index 131dc2c8d72..28cba3e570a 100644 --- a/yarn-project/boxes/private-token/src/app/components/wallet_dropdown.tsx +++ b/yarn-project/boxes/private-token/src/app/components/wallet_dropdown.tsx @@ -1,10 +1,10 @@ +import { pxe } from '../../config.js'; +import { Copy } from './copy.js'; +import { Select } from './select.js'; +import styles from './wallet_dropdown.module.scss'; import { Loader } from '@aztec/aztec-ui'; import { CompleteAddress } from '@aztec/aztec.js'; import { useEffect, useState } from 'react'; -import { rpcClient } from '../../config.js'; -import { Select } from './select.js'; -import styles from './wallet_dropdown.module.scss'; -import { Copy } from './copy.js'; interface Props { selected: CompleteAddress | undefined; @@ -20,7 +20,7 @@ export function WalletDropdown({ selected, onSelectChange, onError }: Props) { return; } const loadOptions = async () => { - const fetchedOptions = await rpcClient.getRegisteredAccounts(); + const fetchedOptions = await pxe.getRegisteredAccounts(); setOptions(fetchedOptions); onSelectChange(fetchedOptions[0]); }; diff --git a/yarn-project/boxes/private-token/src/app/contract.tsx b/yarn-project/boxes/private-token/src/app/contract.tsx index 87495ef8cf3..3b9e3c3c80b 100644 --- a/yarn-project/boxes/private-token/src/app/contract.tsx +++ b/yarn-project/boxes/private-token/src/app/contract.tsx @@ -1,11 +1,11 @@ -import { Button, ButtonSize, ButtonTheme, Card, CardTheme, ImageButton, ImageButtonIcon } from '@aztec/aztec-ui'; -import { AztecAddress, CompleteAddress } from '@aztec/aztec.js'; -import { FunctionAbi } from '@aztec/foundation/abi'; -import { ReactNode, useState } from 'react'; import { FILTERED_FUNCTION_NAMES, contractAbi } from '../config.js'; import { Copy } from './components/copy.js'; import { ContractFunctionForm, Popup } from './components/index.js'; import styles from './contract.module.scss'; +import { Button, ButtonSize, ButtonTheme, Card, CardTheme, ImageButton, ImageButtonIcon } from '@aztec/aztec-ui'; +import { AztecAddress, CompleteAddress } from '@aztec/aztec.js'; +import { FunctionAbi } from '@aztec/foundation/abi'; +import { ReactNode, useState } from 'react'; const functionTypeSortOrder = { secret: 0, diff --git a/yarn-project/boxes/private-token/src/app/home.tsx b/yarn-project/boxes/private-token/src/app/home.tsx index f6d7186fcb1..64e73a44d12 100644 --- a/yarn-project/boxes/private-token/src/app/home.tsx +++ b/yarn-project/boxes/private-token/src/app/home.tsx @@ -1,10 +1,10 @@ -import { Loader } from '@aztec/aztec-ui'; -import { CompleteAddress } from '@aztec/aztec.js'; -import { useEffect, useRef, useState } from 'react'; import { SANDBOX_URL } from '../config.js'; import { WalletDropdown } from './components/wallet_dropdown.js'; import { Contract } from './contract.js'; import styles from './home.module.scss'; +import { Loader } from '@aztec/aztec-ui'; +import { CompleteAddress } from '@aztec/aztec.js'; +import { useEffect, useRef, useState } from 'react'; export function Home() { const [isLoadingWallet, setIsLoadingWallet] = useState(true); diff --git a/yarn-project/boxes/private-token/src/app/index.tsx b/yarn-project/boxes/private-token/src/app/index.tsx index c5f7c020418..451c1c89648 100644 --- a/yarn-project/boxes/private-token/src/app/index.tsx +++ b/yarn-project/boxes/private-token/src/app/index.tsx @@ -1,7 +1,7 @@ -import * as React from 'react'; -import * as ReactDOM from 'react-dom/client'; import { Home } from './home.js'; import './index.css'; +import * as React from 'react'; +import * as ReactDOM from 'react-dom/client'; const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement); root.render( diff --git a/yarn-project/boxes/private-token/src/artifacts/private_token.ts b/yarn-project/boxes/private-token/src/artifacts/private_token.ts index 16a0a5de990..7796d8f86b4 100644 --- a/yarn-project/boxes/private-token/src/artifacts/private_token.ts +++ b/yarn-project/boxes/private-token/src/artifacts/private_token.ts @@ -13,7 +13,7 @@ import { } from '@aztec/aztec.js'; import { ContractAbi } from '@aztec/foundation/abi'; import { Point } from '@aztec/foundation/fields'; -import { AztecRPC, PublicKey } from '@aztec/types'; +import { PXE, PublicKey } from '@aztec/types'; import PrivateTokenContractAbiJson from './private_token_contract.json' assert { type: 'json' }; @@ -54,10 +54,10 @@ export class PrivateTokenContract extends ContractBase { /** * Creates a tx to deploy a new instance of this contract. */ - public static deploy(rpc: AztecRPC, initial_supply: FieldLike, owner: FieldLike) { + public static deploy(pxe: PXE, initial_supply: FieldLike, owner: FieldLike) { return new DeployMethod( Point.ZERO, - rpc, + pxe, PrivateTokenContractAbi, Array.from(arguments).slice(1), ); @@ -66,10 +66,10 @@ export class PrivateTokenContract extends ContractBase { /** * Creates a tx to deploy a new instance of this contract using the specified public key to derive the address. */ - public static deployWithPublicKey(rpc: AztecRPC, publicKey: PublicKey, initial_supply: FieldLike, owner: FieldLike) { + public static deployWithPublicKey(pxe: PXE, publicKey: PublicKey, initial_supply: FieldLike, owner: FieldLike) { return new DeployMethod( publicKey, - rpc, + pxe, PrivateTokenContractAbi, Array.from(arguments).slice(2), ); diff --git a/yarn-project/boxes/private-token/src/config.ts b/yarn-project/boxes/private-token/src/config.ts index d52df5238cb..074f5eea5fa 100644 --- a/yarn-project/boxes/private-token/src/config.ts +++ b/yarn-project/boxes/private-token/src/config.ts @@ -1,11 +1,13 @@ -import { AztecRPC, createAztecRpcClient } from '@aztec/aztec.js'; +import { PrivateTokenContractAbi } from './artifacts/private_token.js'; +import { PXE, createPXEClient } from '@aztec/aztec.js'; import { ContractAbi } from '@aztec/foundation/abi'; -import { PrivateTokenContractAbi } from './artifacts/private_token.js'; // update this if using a different contract + +// update this if using a different contract export const contractAbi: ContractAbi = PrivateTokenContractAbi; export const SANDBOX_URL: string = process.env.SANDBOX_URL || 'http://localhost:8080'; -export const rpcClient: AztecRPC = createAztecRpcClient(SANDBOX_URL); +export const pxe: PXE = createPXEClient(SANDBOX_URL); export const CONTRACT_ADDRESS_PARAM_NAMES = ['owner', 'contract_address', 'recipient']; export const FILTERED_FUNCTION_NAMES = ['compute_note_hash_and_nullifier']; diff --git a/yarn-project/boxes/private-token/src/scripts/call_contract_function.ts b/yarn-project/boxes/private-token/src/scripts/call_contract_function.ts index 8b242a06456..86fc722777a 100644 --- a/yarn-project/boxes/private-token/src/scripts/call_contract_function.ts +++ b/yarn-project/boxes/private-token/src/scripts/call_contract_function.ts @@ -1,17 +1,17 @@ -import { AztecAddress, AztecRPC, CompleteAddress, Contract } from '@aztec/aztec.js'; -import { ContractAbi } from '@aztec/foundation/abi'; import { getWallet } from './util.js'; +import { AztecAddress, PXE, CompleteAddress, Contract } from '@aztec/aztec.js'; +import { ContractAbi } from '@aztec/foundation/abi'; export async function callContractFunction( address: AztecAddress, abi: ContractAbi, functionName: string, typedArgs: any[], // for the exposed functions, this is an array of field elements Fr[] - rpc: AztecRPC, + pxe: PXE, wallet: CompleteAddress, ) { // selectedWallet is how we specify the "sender" of the transaction - const selectedWallet = await getWallet(wallet, rpc); + const selectedWallet = await getWallet(wallet, pxe); // TODO: switch to the generated typescript class? const contract = await Contract.at(address, abi, selectedWallet); diff --git a/yarn-project/boxes/private-token/src/scripts/deploy_contract.ts b/yarn-project/boxes/private-token/src/scripts/deploy_contract.ts index 2285937d2e1..7a0dc7d4d76 100644 --- a/yarn-project/boxes/private-token/src/scripts/deploy_contract.ts +++ b/yarn-project/boxes/private-token/src/scripts/deploy_contract.ts @@ -1,15 +1,15 @@ import { AztecAddress, CompleteAddress, DeployMethod, Fr } from '@aztec/aztec.js'; import { ContractAbi } from '@aztec/foundation/abi'; -import { AztecRPC } from '@aztec/types'; +import { PXE } from '@aztec/types'; export async function deployContract( activeWallet: CompleteAddress, contractAbi: ContractAbi, typedArgs: Fr[], // encode prior to passing in salt: Fr, - client: AztecRPC, + pxe: PXE, ): Promise { - const tx = new DeployMethod(activeWallet.publicKey, client, contractAbi, typedArgs).send({ + const tx = new DeployMethod(activeWallet.publicKey, pxe, contractAbi, typedArgs).send({ contractAddressSalt: salt, }); await tx.wait(); diff --git a/yarn-project/boxes/private-token/src/scripts/util.ts b/yarn-project/boxes/private-token/src/scripts/util.ts index cadf2d05afa..cac4d8afddc 100644 --- a/yarn-project/boxes/private-token/src/scripts/util.ts +++ b/yarn-project/boxes/private-token/src/scripts/util.ts @@ -1,6 +1,6 @@ import { AccountWallet, Fr, getSandboxAccountsWallets } from '@aztec/aztec.js'; import { FunctionAbi, encodeArguments } from '@aztec/foundation/abi'; -import { AztecRPC, CompleteAddress } from '@aztec/types'; +import { PXE, CompleteAddress } from '@aztec/types'; export function convertArgs(functionAbi: FunctionAbi, args: any): Fr[] { const untypedArgs = functionAbi.parameters.map(param => { @@ -23,14 +23,14 @@ export function convertArgs(functionAbi: FunctionAbi, args: any): Fr[] { * while the "wallet" has the account's private key and is used to sign transactions * we need the "wallet" to actually submit transactions using the "account" identity * @param account - * @param rpc + * @param pxe * @returns */ -export async function getWallet(account: CompleteAddress, rpc: AztecRPC): Promise { - const accountWallets: AccountWallet[] = await getSandboxAccountsWallets(rpc); +export async function getWallet(account: CompleteAddress, pxe: PXE): Promise { + const accountWallets: AccountWallet[] = await getSandboxAccountsWallets(pxe); const selectedWallet: AccountWallet = accountWallets.find(w => w.getAddress().equals(account.address))!; if (!selectedWallet) { - throw new Error(`Wallet for account ${account.address.toShortString()} not found in the RPC server.`); + throw new Error(`Wallet for account ${account.address.toShortString()} not found in the PXE.`); } return selectedWallet; } diff --git a/yarn-project/boxes/private-token/src/scripts/view_contract_function.ts b/yarn-project/boxes/private-token/src/scripts/view_contract_function.ts index e9adba3ecd1..79bd9b16f92 100644 --- a/yarn-project/boxes/private-token/src/scripts/view_contract_function.ts +++ b/yarn-project/boxes/private-token/src/scripts/view_contract_function.ts @@ -1,17 +1,17 @@ -import { AztecAddress, AztecRPC, CompleteAddress, Contract } from '@aztec/aztec.js'; -import { ContractAbi } from '@aztec/foundation/abi'; import { getWallet } from './util.js'; +import { AztecAddress, PXE, CompleteAddress, Contract } from '@aztec/aztec.js'; +import { ContractAbi } from '@aztec/foundation/abi'; export async function viewContractFunction( address: AztecAddress, abi: ContractAbi, functionName: string, typedArgs: any[], - rpc: AztecRPC, + pxe: PXE, wallet: CompleteAddress, ) { // we specify the account that is calling the view function by passing in the wallet to the Contract - const selectedWallet = await getWallet(wallet, rpc); + const selectedWallet = await getWallet(wallet, pxe); const contract = await Contract.at(address, abi, selectedWallet); return await contract.methods[functionName](...typedArgs).view({ from: wallet.address }); diff --git a/yarn-project/boxes/private-token/src/tests/privatetoken.sandbox.test.ts b/yarn-project/boxes/private-token/src/tests/privatetoken.sandbox.test.ts index 2e92e139dcd..bfbe139e133 100644 --- a/yarn-project/boxes/private-token/src/tests/privatetoken.sandbox.test.ts +++ b/yarn-project/boxes/private-token/src/tests/privatetoken.sandbox.test.ts @@ -1,18 +1,18 @@ +import { PrivateTokenContract } from '../artifacts/private_token.js'; +import { pxe } from '../config.js'; +import { callContractFunction, deployContract, getWallet, viewContractFunction } from '../scripts/index.js'; import { AccountWallet, AztecAddress, - AztecRPC, + PXE, CompleteAddress, Contract, Fr, Wallet, - createAztecRpcClient, + createPXEClient, waitForSandbox, } from '@aztec/aztec.js'; import { createDebugLogger } from '@aztec/foundation/log'; -import { PrivateTokenContract } from '../artifacts/private_token.js'; -import { rpcClient } from '../config.js'; -import { callContractFunction, deployContract, getWallet, viewContractFunction } from '../scripts/index.js'; const logger = createDebugLogger('aztec:private-token-box-sandbox-test'); @@ -24,16 +24,16 @@ const MINT_AMOUNT = 11n; // as well as anvil. anvil can be started with yarn test:integration const setupSandbox = async () => { const { SANDBOX_URL = 'http://localhost:8080' } = process.env; - const aztecRpc = createAztecRpcClient(SANDBOX_URL); - await waitForSandbox(aztecRpc); - return aztecRpc; + const pxe = createPXEClient(SANDBOX_URL); + await waitForSandbox(pxe); + return pxe; }; -async function deployZKContract(owner: CompleteAddress, wallet: Wallet, rpcClient: AztecRPC) { +async function deployZKContract(owner: CompleteAddress, wallet: Wallet, pxe: PXE) { logger('Deploying PrivateToken contract...'); const typedArgs = [new Fr(INITIAL_BALANCE), owner.address.toField()]; - const contractAddress = await deployContract(owner, PrivateTokenContract.abi, typedArgs, Fr.random(), rpcClient); + const contractAddress = await deployContract(owner, PrivateTokenContract.abi, typedArgs, Fr.random(), pxe); logger(`L2 contract deployed at ${contractAddress}`); return PrivateTokenContract.at(contractAddress, wallet); @@ -42,14 +42,7 @@ async function deployZKContract(owner: CompleteAddress, wallet: Wallet, rpcClien async function getBalance(contractAddress: AztecAddress, privateTokenContract: Contract, owner: CompleteAddress) { const typedArgs = [owner.address.toField()]; - return await viewContractFunction( - contractAddress, - privateTokenContract.abi, - 'getBalance', - typedArgs, - rpcClient, - owner, - ); + return await viewContractFunction(contractAddress, privateTokenContract.abi, 'getBalance', typedArgs, pxe, owner); } async function mint( @@ -61,7 +54,7 @@ async function mint( ) { const typedArgs = [new Fr(amount), to.address.toField()]; - return await callContractFunction(contractAddress, privateTokenContract.abi, 'mint', typedArgs, rpcClient, from); + return await callContractFunction(contractAddress, privateTokenContract.abi, 'mint', typedArgs, pxe, from); } async function transfer( @@ -73,7 +66,7 @@ async function transfer( ) { const typedArgs = [new Fr(amount), to.address.toField()]; - return await callContractFunction(contractAddress, privateTokenContract.abi, 'transfer', typedArgs, rpcClient, from); + return await callContractFunction(contractAddress, privateTokenContract.abi, 'transfer', typedArgs, pxe, from); } describe('ZK Contract Tests', () => { @@ -83,16 +76,16 @@ describe('ZK Contract Tests', () => { let _account3: CompleteAddress; let privateTokenContract: Contract; let contractAddress: AztecAddress; - let rpcClient: AztecRPC; + let pxe: PXE; beforeAll(async () => { - rpcClient = await setupSandbox(); - const accounts = await rpcClient.getRegisteredAccounts(); + pxe = await setupSandbox(); + const accounts = await pxe.getRegisteredAccounts(); [owner, account2, _account3] = accounts; - wallet = await getWallet(owner, rpcClient); + wallet = await getWallet(owner, pxe); - privateTokenContract = await deployZKContract(owner, wallet, rpcClient); + privateTokenContract = await deployZKContract(owner, wallet, pxe); contractAddress = privateTokenContract.address; }, 60000); diff --git a/yarn-project/canary/scripts/docker-compose-browser.yml b/yarn-project/canary/scripts/docker-compose-browser.yml index 04ab2d5c2fc..e7db3336acc 100644 --- a/yarn-project/canary/scripts/docker-compose-browser.yml +++ b/yarn-project/canary/scripts/docker-compose-browser.yml @@ -22,7 +22,7 @@ services: P2P_BLOCK_CHECK_INTERVAL_MS: 50 SEQ_TX_POLLING_INTERVAL_MS: 50 WS_BLOCK_CHECK_INTERVAL_MS: 50 - RPC_SERVER_BLOCK_POLLING_INTERVAL_MS: 50 + PXE_SERVICE_BLOCK_POLLING_INTERVAL_MS: 50 ARCHIVER_VIEM_POLLING_INTERVAL_MS: 500 SEARCH_START_BLOCK: ${FORK_BLOCK_NUMBER:-0} ports: diff --git a/yarn-project/canary/scripts/docker-compose-e2e-sandbox.yml b/yarn-project/canary/scripts/docker-compose-e2e-sandbox.yml index bd97f00d823..7f3d8162382 100644 --- a/yarn-project/canary/scripts/docker-compose-e2e-sandbox.yml +++ b/yarn-project/canary/scripts/docker-compose-e2e-sandbox.yml @@ -22,7 +22,7 @@ services: P2P_BLOCK_CHECK_INTERVAL_MS: 50 SEQ_TX_POLLING_INTERVAL_MS: 50 WS_BLOCK_CHECK_INTERVAL_MS: 50 - RPC_SERVER_BLOCK_POLLING_INTERVAL_MS: 50 + PXE_SERVICE_BLOCK_POLLING_INTERVAL_MS: 50 ARCHIVER_VIEM_POLLING_INTERVAL_MS: 500 SEARCH_START_BLOCK: ${FORK_BLOCK_NUMBER:-0} ports: diff --git a/yarn-project/canary/scripts/docker-compose.yml b/yarn-project/canary/scripts/docker-compose.yml index e22f63d3fb4..ccba483c3ac 100644 --- a/yarn-project/canary/scripts/docker-compose.yml +++ b/yarn-project/canary/scripts/docker-compose.yml @@ -22,7 +22,7 @@ services: P2P_BLOCK_CHECK_INTERVAL_MS: 50 SEQ_TX_POLLING_INTERVAL_MS: 50 WS_BLOCK_CHECK_INTERVAL_MS: 50 - RPC_SERVER_BLOCK_POLLING_INTERVAL_MS: 50 + PXE_SERVICE_BLOCK_POLLING_INTERVAL_MS: 50 ARCHIVER_VIEM_POLLING_INTERVAL_MS: 500 SEARCH_START_BLOCK: ${FORK_BLOCK_NUMBER:-0} ports: diff --git a/yarn-project/canary/src/cli.test.ts b/yarn-project/canary/src/cli.test.ts index 309dddca662..a7fef24cc07 100644 --- a/yarn-project/canary/src/cli.test.ts +++ b/yarn-project/canary/src/cli.test.ts @@ -1,4 +1,4 @@ -import { createAztecRpcClient, createDebugLogger, makeFetch, waitForSandbox } from '@aztec/aztec.js'; +import { createDebugLogger, createPXEClient, makeFetch, waitForSandbox } from '@aztec/aztec.js'; import { cliTestSuite } from '@aztec/end-to-end'; const { SANDBOX_URL = 'http://localhost:8080' } = process.env; @@ -6,9 +6,9 @@ const { SANDBOX_URL = 'http://localhost:8080' } = process.env; const debug = createDebugLogger('aztec:canary_cli'); const setupRPC = async () => { - const aztecRpcClient = createAztecRpcClient(SANDBOX_URL, makeFetch([1, 2, 3, 4, 5], true)); - await waitForSandbox(aztecRpcClient); - return aztecRpcClient; + const pxe = createPXEClient(SANDBOX_URL, makeFetch([1, 2, 3, 4, 5], true)); + await waitForSandbox(pxe); + return pxe; }; cliTestSuite('CLI Canary', setupRPC, () => Promise.resolve(), debug, SANDBOX_URL); diff --git a/yarn-project/canary/src/uniswap_trade_on_l1_from_l2.test.ts b/yarn-project/canary/src/uniswap_trade_on_l1_from_l2.test.ts index 5bcd696168c..f53765b96eb 100644 --- a/yarn-project/canary/src/uniswap_trade_on_l1_from_l2.test.ts +++ b/yarn-project/canary/src/uniswap_trade_on_l1_from_l2.test.ts @@ -5,8 +5,8 @@ import { TxStatus, Wallet, computeMessageSecretHash, - createAztecRpcClient, createDebugLogger, + createPXEClient, getL1ContractAddresses, getSandboxAccountsWallets, sleep, @@ -45,12 +45,12 @@ const DAI_ADDRESS = EthAddress.fromString('0x6B175474E89094C44Da98b954EedeAC4952 const EXPECTED_FORKED_BLOCK = 17514288; -const aztecRpcUrl = SANDBOX_URL; +const pxeRpcUrl = SANDBOX_URL; const ethRpcUrl = ETHEREUM_HOST; const hdAccount = mnemonicToAccount(MNEMONIC); -const aztecRpcClient = createAztecRpcClient(aztecRpcUrl); +const pxe = createPXEClient(pxeRpcUrl); let wallet: Wallet; /** @@ -62,7 +62,7 @@ async function deployAllContracts( publicClient: PublicClient, walletClient: WalletClient, ) { - const l1ContractsAddresses = await getL1ContractAddresses(aztecRpcUrl); + const l1ContractsAddresses = await getL1ContractAddresses(pxeRpcUrl); logger('Deploying DAI Portal, initializing and deploying l2 contract...'); const daiContracts = await deployAndInitializeNonNativeL2TokenContracts( wallet, @@ -107,7 +107,7 @@ async function deployAllContracts( }); // deploy l2 uniswap contract and attach to portal - const tx = UniswapContract.deploy(aztecRpcClient).send({ + const tx = UniswapContract.deploy(pxe).send({ portalContract: uniswapPortalAddress, }); await tx.isMined(); @@ -163,7 +163,7 @@ describe.skip('uniswap_trade_on_l1_from_l2', () => { let publicClient: PublicClient; let walletClient: WalletClient; beforeAll(async () => { - await waitForSandbox(aztecRpcClient); + await waitForSandbox(pxe); walletClient = createWalletClient({ account: hdAccount, @@ -184,7 +184,7 @@ describe.skip('uniswap_trade_on_l1_from_l2', () => { it('should uniswap trade on L1 from L2 funds privately (swaps WETH -> DAI)', async () => { logger('Running L1/L2 messaging test on HTTP interface.'); - [wallet] = await getSandboxAccountsWallets(aztecRpcClient); + [wallet] = await getSandboxAccountsWallets(pxe); const accounts = await wallet.getRegisteredAccounts(); const owner = accounts[0].address; const receiver = accounts[1].address; diff --git a/yarn-project/canary/src/utils.ts b/yarn-project/canary/src/utils.ts index 52868eee329..d5404a0fdae 100644 --- a/yarn-project/canary/src/utils.ts +++ b/yarn-project/canary/src/utils.ts @@ -7,7 +7,7 @@ import { Account, Chain, Hex, HttpTransport, PublicClient, WalletClient, getCont /** * Deploy L1 token and portal, initialize portal, deploy a non native l2 token contract and attach is to the portal. - * @param aztecRpcServer - the aztec rpc server instance + * @param wallet - A wallet instance. * @param walletClient - A viem WalletClient. * @param publicClient - A viem PublicClient. * @param rollupRegistryAddress - address of rollup registry to pass to initialize the token portal diff --git a/yarn-project/cli/README.md b/yarn-project/cli/README.md index 08bc07e5f0a..e4544aec0e2 100644 --- a/yarn-project/cli/README.md +++ b/yarn-project/cli/README.md @@ -43,14 +43,14 @@ These options are: - `PRIVATE_KEY` -> `-k, --private-key` for all commands that require a private key. - `PUBLIC_KEY` -> `-k, --public-key` for all commands that require a public key. -- `AZTEC_RPC_HOST` -> `-u, --rpc-url` for commands that require an Aztec RPC URL. +- `PXE_HOST` -> `-u, --rpc-url` for commands that require a PXE - `API_KEY` -> `a, --api-key` for `deploy-l1-contracts`. - `ETHEREUM_RPC_HOST` -> `-u, --rpc-url` for `deploy-l1-contracts`. -So if for example you are running your Aztec RPC server remotely you can do: +So if for example you are running your Private Execution Environment (PXE) remotely you can do: ```shell -export AZTEC_RPC_HOST=http://external.site/rpc:8080 +export PXE_HOST=http://external.site/rpc:8080 aztec-cli deploy my_contract.json ``` @@ -123,7 +123,7 @@ aztec-cli create-account [options] Options: - `-k, --private-key`: Private key to use for the account generation. Uses a random key by default. -- `-u, --rpc-url `: URL of the Aztec RPC. Default: `http://localhost:8080`. +- `-u, --rpc-url `: URL of PXE Service. Default: `http://localhost:8080`. This command creates an Aztec account that can be used for transactions. It generates a new account with a private key or uses the provided private key. The command displays the account's address and public key. @@ -147,7 +147,7 @@ Options: - `-c, --contract-abi `: Path to the compiled Aztec.nr contract's ABI file in JSON format. You can also use one of Aztec's example contracts found in [@aztec/noir-contracts](https://www.npmjs.com/package/@aztec/noir-contracts), e.g. PrivateTokenContractAbi. You can get a full ist of the available contracts with `aztec-cli example-contracts` - `-a, --args ` (optional): Contract constructor arguments Default: []. -- `-u, --rpc-url `: URL of the Aztec RPC. Default: `http://localhost:8080`. +- `-u, --rpc-url `: URL of PXE Service. Default: `http://localhost:8080`. - `-k, --public-key `: Public key of the deployer. If not provided, it will check the RPC for existing ones. This command deploys a compiled Aztec.nr contract to Aztec. It requires the path to the contract's ABI file in JSON format. Optionally, you can specify the public key of the deployer and provide constructor arguments for the contract. The command displays the address of the deployed contract. @@ -177,7 +177,7 @@ aztec-cli check-deploy [options] Options: - `-ca, --contract-address
`: An Aztec address to check if the contract has been deployed to. -- `-u, --rpc-url `: URL of the Aztec RPC. Default: `http://localhost:8080`. +- `-u, --rpc-url `: URL of PXE Service. Default: `http://localhost:8080`. This command checks if a contract is deployed to the specified Aztec address. It verifies if the contract is present at the given address and displays the result. @@ -201,7 +201,7 @@ aztec-cli get-tx-receipt [options] Options: -- `-u, --rpc-url `: URL of the Aztec RPC. Default: `http://localhost:8080`. +- `-u, --rpc-url `: URL of PXE Service. Default: `http://localhost:8080`. This command retrieves and displays the receipt for the specified transaction hash. It shows details such as the transaction status, block number, and block hash. @@ -225,7 +225,7 @@ aztec-cli get-contract-data [options] Options: -- `-u, --rpc-url `: URL of the Aztec RPC. Default: `http://localhost:8080`. +- `-u, --rpc-url `: URL of PXE Service. Default: `http://localhost:8080`. - `-b, --include-bytecode`: Include the contract's public function bytecode, if any. This command retrieves and displays information about the Aztec contract deployed at the specified address. It shows the contract address, portal contract address, and optionally, the bytecode of the contract's public functions. @@ -238,7 +238,7 @@ aztec-cli get-contract-data 0x123456789abcdef123456789abcdef12345678 ### register-recipient -Register a recipient account on the RPC server (called recipient because we can only send notes to this account and not receive them via this RPC server). +Register a recipient account on the PXE (called recipient because we can only send notes to this account and not receive them via this PXE). To read about how keys are generated and used, head to our docs [here](https://github.com/AztecProtocol/aztec-packages/blob/master/docs/docs/aztec/developer/wallet-providers/keys.md#addresses-partial-addresses-and-public-keys). Syntax: @@ -252,7 +252,7 @@ Options: - `-a, --address `: The account's Aztec address. - `-p, --public-key `: 'The account public key.' - `-pa, --partial-address `: URL of the Aztec RPC. Default: `http://localhost:8080`. +- `-u, --rpc-url `: URL of PXE Service. Default: `http://localhost:8080`. Example usage: @@ -262,7 +262,7 @@ aztec-cli register-recipient -p 0x20d9d93c4a9eb2b4bdb70ead07d28d1edb74bfd78443a8 ### get-accounts -Gets all the Aztec accounts stored in an Aztec RPC. +Gets all the Aztec accounts stored in a PXE. Syntax: @@ -272,7 +272,7 @@ aztec-cli get-accounts [options] Options: -- `-u, --rpc-url `: URL of the Aztec RPC. Default: `http://localhost:8080`. +- `-u, --rpc-url `: URL of PXE Service. Default: `http://localhost:8080`. This command retrieves and displays all the Aztec accounts available in the system. @@ -296,7 +296,7 @@ aztec-cli get-account
[options] Options: -- `-u, --rpc-url `: URL of the Aztec RPC. Default: `http://localhost:8080`. +- `-u, --rpc-url `: URL of PXE Service. Default: `http://localhost:8080`. This command retrieves and displays the public key of an account given its Aztec address. @@ -324,7 +324,7 @@ Options: - `-c, --contract-abi `: The compiled contract's ABI in JSON format. You can also use one of Aztec's example contracts found in (@aztec/noir-contracts)[https://www.npmjs.com/package/@aztec/noir-contracts], e.g. PrivateTokenContractAbi. - `-ca, --contract-address
`: Address of the contract. - `-k, --private-key `: The sender's private key. -- `-u, --rpc-url `: URL of the Aztec RPC. Default: `http://localhost:8080`. +- `-u, --rpc-url `: URL of PXE Service. Default: `http://localhost:8080`. This command calls a function on an Aztec contract. It requires the contract's ABI, address, function name, and optionally, function arguments. The command executes the function call and displays the transaction details. @@ -352,8 +352,8 @@ Options: - `'-a, --args [functionArgs...]` (optional): Function arguments. Default: []. - `-c, --contract-abi `: The compiled contract's ABI in JSON format. You can also use one of Aztec's example contracts found in (@aztec/noir-contracts)[https://www.npmjs.com/package/@aztec/noir-contracts], e.g. PrivateTokenContractAbi. - `-ca, --contract-address
`: Address of the contract. -- `-f, --from `: Address of the caller. If empty, first account in the Aztec RPC Server will be used. -- `-u, --rpc-url `: URL of the Aztec RPC. Default: `http://localhost:8080`. +- `-f, --from `: Address of the caller. If empty, first account in the Private Execution Environment (PXE) will be used. +- `-u, --rpc-url `: URL of PXE Service. Default: `http://localhost:8080`. This command simulates the execution of a view function on a deployed contract without modifying the state. It requires the contract's ABI, address, function name, and optionally, function arguments. The command displays the result of the view function. @@ -400,7 +400,7 @@ aztec-cli get-logs --from --limit [options] Options: -- `-u, --rpc-url `: URL of the Aztec RPC. Default: `http://localhost:8080`. +- `-u, --rpc-url `: URL of PXE Service. Default: `http://localhost:8080`. This command retrieves and displays all the unencrypted logs from L2 blocks in the specified range. It shows the logs found in the blocks and unrolls them for readability. @@ -422,7 +422,7 @@ aztec-cli block-number Options: -- `-u, --rpc-url `: URL of the Aztec RPC. Default: `http://localhost:8080`. +- `-u, --rpc-url `: URL of PXE Service. Default: `http://localhost:8080`. This command retrieves and displays the current Aztec L2 block number. @@ -448,7 +448,7 @@ aztec-cli get-node-info Options: -- `-u, --rpc-url `: URL of the Aztec RPC. Default: `http://localhost:8080`. +- `-u, --rpc-url `: URL of PXE Service. Default: `http://localhost:8080`. ## Conclusion diff --git a/yarn-project/cli/src/client.test.ts b/yarn-project/cli/src/client.test.ts index 10a8445acf9..acb23c96e0a 100644 --- a/yarn-project/cli/src/client.test.ts +++ b/yarn-project/cli/src/client.test.ts @@ -1,4 +1,4 @@ -import { AztecRPC, NodeInfo } from '@aztec/types'; +import { NodeInfo, PXE } from '@aztec/types'; import { MockProxy, mock } from 'jest-mock-extended'; @@ -6,27 +6,27 @@ import { checkServerVersion } from './client.js'; describe('client', () => { describe('checkServerVersion', () => { - let rpc: MockProxy; + let pxe: MockProxy; beforeEach(() => { - rpc = mock(); + pxe = mock(); }); it('checks versions match', async () => { - rpc.getNodeInfo.mockResolvedValue({ sandboxVersion: '0.1.0-alpha47' } as NodeInfo); - await checkServerVersion(rpc, '0.1.0-alpha47'); + pxe.getNodeInfo.mockResolvedValue({ sandboxVersion: '0.1.0-alpha47' } as NodeInfo); + await checkServerVersion(pxe, '0.1.0-alpha47'); }); - it('reports mismatch on older rpc version', async () => { - rpc.getNodeInfo.mockResolvedValue({ sandboxVersion: '0.1.0-alpha47' } as NodeInfo); - await expect(checkServerVersion(rpc, '0.1.0-alpha48')).rejects.toThrowError( + it('reports mismatch on older pxe version', async () => { + pxe.getNodeInfo.mockResolvedValue({ sandboxVersion: '0.1.0-alpha47' } as NodeInfo); + await expect(checkServerVersion(pxe, '0.1.0-alpha48')).rejects.toThrowError( /is older than the expected by this CLI/, ); }); - it('reports mismatch on newer rpc version', async () => { - rpc.getNodeInfo.mockResolvedValue({ sandboxVersion: '0.1.0-alpha48' } as NodeInfo); - await expect(checkServerVersion(rpc, '0.1.0-alpha47')).rejects.toThrowError( + it('reports mismatch on newer pxe version', async () => { + pxe.getNodeInfo.mockResolvedValue({ sandboxVersion: '0.1.0-alpha48' } as NodeInfo); + await expect(checkServerVersion(pxe, '0.1.0-alpha47')).rejects.toThrowError( /is newer than the expected by this CLI/, ); }); diff --git a/yarn-project/cli/src/client.ts b/yarn-project/cli/src/client.ts index 05580cb90ef..c30b129419f 100644 --- a/yarn-project/cli/src/client.ts +++ b/yarn-project/cli/src/client.ts @@ -1,4 +1,4 @@ -import { AztecRPC, createAztecRpcClient } from '@aztec/aztec.js'; +import { PXE, createPXEClient } from '@aztec/aztec.js'; import { DebugLogger } from '@aztec/foundation/log'; import { fileURLToPath } from '@aztec/foundation/url'; @@ -7,29 +7,20 @@ import { dirname, resolve } from 'path'; import { gtr, ltr, satisfies, valid } from 'semver'; /** - * Creates an Aztec RPC client with a given set of retries on non-server errors. - * @param rpcUrl - URL of the RPC server. - * @returns An RPC client. - */ -export function createClient(rpcUrl: string) { - return createAztecRpcClient(rpcUrl); -} - -/** - * Creates an Aztec RPC client with a given set of retries on non-server errors. - * Checks that the RPC server matches the expected version, and warns if not. - * @param rpcUrl - URL of the RPC server. + * Creates a PXE client with a given set of retries on non-server errors. + * Checks that PXE matches the expected version, and warns if not. + * @param rpcUrl - URL of the RPC server wrapping the PXE. * @param logger - Debug logger to warn version incompatibilities. - * @returns An RPC client. + * @returns A PXE client. */ export async function createCompatibleClient(rpcUrl: string, logger: DebugLogger) { - const client = createClient(rpcUrl); + const pxe = createPXEClient(rpcUrl); const packageJsonPath = resolve(dirname(fileURLToPath(import.meta.url)), '../package.json'); const packageJsonContents = JSON.parse(readFileSync(packageJsonPath).toString()); const expectedVersionRange = packageJsonContents.version; // During sandbox, we'll expect exact matches try { - await checkServerVersion(client, expectedVersionRange); + await checkServerVersion(pxe, expectedVersionRange); } catch (err) { if (err instanceof VersionMismatchError) { logger.warn(err.message); @@ -38,20 +29,20 @@ export async function createCompatibleClient(rpcUrl: string, logger: DebugLogger } } - return client; + return pxe; } /** Mismatch between server and client versions. */ class VersionMismatchError extends Error {} /** - * Checks that the RPC server version matches the expected one by this CLI. Throws if not. - * @param rpc - RPC server connection. + * Checks that Private Execution Environment (PXE) version matches the expected one by this CLI. Throws if not. + * @param pxe - PXE client. * @param expectedVersionRange - Expected version by CLI. */ -export async function checkServerVersion(rpc: AztecRPC, expectedVersionRange: string) { +export async function checkServerVersion(pxe: PXE, expectedVersionRange: string) { const serverName = 'Aztec Sandbox'; - const { sandboxVersion } = await rpc.getNodeInfo(); + const { sandboxVersion } = await pxe.getNodeInfo(); if (!sandboxVersion) { throw new VersionMismatchError(`Couldn't determine ${serverName} version. You may run into issues.`); } diff --git a/yarn-project/cli/src/index.ts b/yarn-project/cli/src/index.ts index 6e048412cb7..35847632d76 100644 --- a/yarn-project/cli/src/index.ts +++ b/yarn-project/cli/src/index.ts @@ -40,7 +40,7 @@ const accountCreationSalt = Fr.ZERO; const { ETHEREUM_HOST = 'http://localhost:8545', - AZTEC_RPC_HOST = 'http://localhost:8080', + PXE_HOST = 'http://localhost:8080', PRIVATE_KEY, API_KEY, } = process.env; @@ -131,7 +131,7 @@ export function getProgram(log: LogFn, debugLogger: DebugLogger): Command { program .command('create-account') .description( - 'Creates an aztec account that can be used for sending transactions. Registers the account on the RPC server and deploys an account contract. Uses a Schnorr single-key account which uses the same key for encryption and authentication (not secure for production usage).', + 'Creates an aztec account that can be used for sending transactions. Registers the account on the PXE and deploys an account contract. Uses a Schnorr single-key account which uses the same key for encryption and authentication (not secure for production usage).', ) .summary('Creates an aztec account that can be used for sending transactions.') .option( @@ -139,7 +139,7 @@ export function getProgram(log: LogFn, debugLogger: DebugLogger): Command { 'Private key for note encryption and transaction signing. Uses random by default.', PRIVATE_KEY, ) - .requiredOption('-u, --rpc-url ', 'URL of the Aztec RPC', AZTEC_RPC_HOST) + .requiredOption('-u, --rpc-url ', 'URL of the PXE', PXE_HOST) .action(async options => { const client = await createCompatibleClient(options.rpcUrl, debugLogger); const privateKey = options.privateKey @@ -165,7 +165,7 @@ export function getProgram(log: LogFn, debugLogger: DebugLogger): Command { "A compiled Aztec.nr contract's ABI in JSON format or name of a contract ABI exported by @aztec/noir-contracts", ) .option('-a, --args ', 'Contract constructor arguments', []) - .requiredOption('-u, --rpc-url ', 'URL of the Aztec RPC', AZTEC_RPC_HOST) + .requiredOption('-u, --rpc-url ', 'URL of the PXE', PXE_HOST) .option( '-k, --public-key ', 'Optional encryption public key for this address. Set this value only if this contract is expected to receive private notes, which will be encrypted using this public key.', @@ -208,7 +208,7 @@ export function getProgram(log: LogFn, debugLogger: DebugLogger): Command { .command('check-deploy') .description('Checks if a contract is deployed to the specified Aztec address.') .requiredOption('-ca, --contract-address
', 'An Aztec address to check if contract has been deployed to.') - .requiredOption('-u, --rpc-url ', 'URL of the Aztec RPC', AZTEC_RPC_HOST) + .requiredOption('-u, --rpc-url ', 'URL of the PXE', PXE_HOST) .action(async options => { const client = await createCompatibleClient(options.rpcUrl, debugLogger); const address = AztecAddress.fromString(options.contractAddress); @@ -221,7 +221,7 @@ export function getProgram(log: LogFn, debugLogger: DebugLogger): Command { .command('get-tx-receipt') .description('Gets the receipt for the specified transaction hash.') .argument('', 'A transaction hash to get the receipt for.') - .requiredOption('-u, --rpc-url ', 'URL of the Aztec RPC', AZTEC_RPC_HOST) + .requiredOption('-u, --rpc-url ', 'URL of the PXE', PXE_HOST) .action(async (_txHash, options) => { const client = await createCompatibleClient(options.rpcUrl, debugLogger); const txHash = TxHash.fromString(_txHash); @@ -237,7 +237,7 @@ export function getProgram(log: LogFn, debugLogger: DebugLogger): Command { .command('get-contract-data') .description('Gets information about the Aztec contract deployed at the specified address.') .argument('', 'Aztec address of the contract.') - .requiredOption('-u, --rpc-url ', 'URL of the Aztec RPC', AZTEC_RPC_HOST) + .requiredOption('-u, --rpc-url ', 'URL of the PXE', PXE_HOST) .option('-b, --include-bytecode ', "Include the contract's public function bytecode, if any.", false) .action(async (contractAddress, options) => { const client = await createCompatibleClient(options.rpcUrl, debugLogger); @@ -270,7 +270,7 @@ export function getProgram(log: LogFn, debugLogger: DebugLogger): Command { .description('Gets all the unencrypted logs from L2 blocks in the range specified.') .option('-f, --from ', 'Initial block number for getting logs (defaults to 1).') .option('-l, --limit ', 'How many blocks to fetch (defaults to 100).') - .requiredOption('-u, --rpc-url ', 'URL of the Aztec RPC', AZTEC_RPC_HOST) + .requiredOption('-u, --rpc-url ', 'URL of the PXE', PXE_HOST) .action(async options => { const { from, limit } = options; const fromBlock = from ? parseInt(from) : 1; @@ -288,11 +288,11 @@ export function getProgram(log: LogFn, debugLogger: DebugLogger): Command { program .command('register-recipient') - .description('Register a recipient in the Aztec RPC.') + .description('Register a recipient in the PXE.') .requiredOption('-a, --address ', "The account's Aztec address.") .requiredOption('-p, --public-key ', 'The account public key.') .requiredOption('-pa, --partial-address ', 'URL of the Aztec RPC', AZTEC_RPC_HOST) + .requiredOption('-u, --rpc-url ', 'URL of the PXE', PXE_HOST) .action(async options => { const client = await createCompatibleClient(options.rpcUrl, debugLogger); const address = AztecAddress.fromString(options.address); @@ -305,8 +305,8 @@ export function getProgram(log: LogFn, debugLogger: DebugLogger): Command { program .command('get-accounts') - .description('Gets all the Aztec accounts stored in the Aztec RPC.') - .requiredOption('-u, --rpc-url ', 'URL of the Aztec RPC', AZTEC_RPC_HOST) + .description('Gets all the Aztec accounts stored in the PXE.') + .requiredOption('-u, --rpc-url ', 'URL of the PXE', PXE_HOST) .action(async (options: any) => { const client = await createCompatibleClient(options.rpcUrl, debugLogger); const accounts = await client.getRegisteredAccounts(); @@ -324,7 +324,7 @@ export function getProgram(log: LogFn, debugLogger: DebugLogger): Command { .command('get-account') .description('Gets an account given its Aztec address.') .argument('
', 'The Aztec address to get account for') - .requiredOption('-u, --rpc-url ', 'URL of the Aztec RPC', AZTEC_RPC_HOST) + .requiredOption('-u, --rpc-url ', 'URL of the PXE', PXE_HOST) .action(async (_address, options) => { const client = await createCompatibleClient(options.rpcUrl, debugLogger); const address = AztecAddress.fromString(_address); @@ -339,8 +339,8 @@ export function getProgram(log: LogFn, debugLogger: DebugLogger): Command { program .command('get-recipients') - .description('Gets all the recipients stored in the Aztec RPC.') - .requiredOption('-u, --rpc-url ', 'URL of the Aztec RPC', AZTEC_RPC_HOST) + .description('Gets all the recipients stored in the PXE.') + .requiredOption('-u, --rpc-url ', 'URL of the PXE', PXE_HOST) .action(async (options: any) => { const client = await createCompatibleClient(options.rpcUrl, debugLogger); const recipients = await client.getRecipients(); @@ -358,7 +358,7 @@ export function getProgram(log: LogFn, debugLogger: DebugLogger): Command { .command('get-recipient') .description('Gets a recipient given its Aztec address.') .argument('
', 'The Aztec address to get recipient for') - .requiredOption('-u, --rpc-url ', 'URL of the Aztec RPC', AZTEC_RPC_HOST) + .requiredOption('-u, --rpc-url ', 'URL of the PXE', PXE_HOST) .action(async (_address, options) => { const client = await createCompatibleClient(options.rpcUrl, debugLogger); const address = AztecAddress.fromString(_address); @@ -382,7 +382,7 @@ export function getProgram(log: LogFn, debugLogger: DebugLogger): Command { ) .requiredOption('-ca, --contract-address
', 'Aztec address of the contract.') .requiredOption('-k, --private-key ', "The sender's private key.", PRIVATE_KEY) - .requiredOption('-u, --rpc-url ', 'URL of the Aztec RPC', AZTEC_RPC_HOST) + .requiredOption('-u, --rpc-url ', 'URL of the PXE', PXE_HOST) .option('--no-wait', 'Print transaction hash without waiting for it to be mined') .action(async (functionName, options) => { const { contractAddress, functionArgs, contractAbi } = await prepTx( @@ -427,7 +427,7 @@ export function getProgram(log: LogFn, debugLogger: DebugLogger): Command { ) .requiredOption('-ca, --contract-address
', 'Aztec address of the contract.') .option('-f, --from ', 'Aztec address of the caller. If empty, will use the first account from RPC.') - .requiredOption('-u, --rpc-url ', 'URL of the Aztec RPC', AZTEC_RPC_HOST) + .requiredOption('-u, --rpc-url ', 'URL of the PXE', PXE_HOST) .action(async (functionName, options) => { const { contractAddress, functionArgs, contractAbi } = await prepTx( options.contractAbi, @@ -475,7 +475,7 @@ export function getProgram(log: LogFn, debugLogger: DebugLogger): Command { program .command('block-number') .description('Gets the current Aztec L2 block number.') - .requiredOption('-u, --rpc-url ', 'URL of the Aztec RPC', AZTEC_RPC_HOST) + .requiredOption('-u, --rpc-url ', 'URL of the PXE', PXE_HOST) .action(async (options: any) => { const client = await createCompatibleClient(options.rpcUrl, debugLogger); const num = await client.getBlockNumber(); @@ -506,7 +506,7 @@ export function getProgram(log: LogFn, debugLogger: DebugLogger): Command { program .command('get-node-info') .description('Gets the information of an aztec node at a URL.') - .requiredOption('-u, --rpc-url ', 'URL of the Aztec RPC', AZTEC_RPC_HOST) + .requiredOption('-u, --rpc-url ', 'URL of the PXE', PXE_HOST) .action(async options => { const client = await createCompatibleClient(options.rpcUrl, debugLogger); const info = await client.getNodeInfo(); diff --git a/yarn-project/cli/src/test/utils.test.ts b/yarn-project/cli/src/test/utils.test.ts index 70e1a9c7d10..2e04691cba2 100644 --- a/yarn-project/cli/src/test/utils.test.ts +++ b/yarn-project/cli/src/test/utils.test.ts @@ -1,5 +1,5 @@ import { AztecAddress, Fr } from '@aztec/aztec.js'; -import { AztecRPC, CompleteAddress } from '@aztec/types'; +import { CompleteAddress, PXE } from '@aztec/types'; import { InvalidArgumentError } from 'commander'; import { MockProxy, mock } from 'jest-mock-extended'; @@ -9,7 +9,7 @@ import { getSaltFromHexString, getTxSender, stripLeadingHex } from '../utils.js' import { mockContractAbi } from './mocks.js'; describe('CLI Utils', () => { - let client: MockProxy; + let client: MockProxy; // test values const addr1 = AztecAddress.random(); @@ -23,7 +23,7 @@ describe('CLI Utils', () => { subField2: 'true', }; beforeEach(() => { - client = mock(); + client = mock(); }); it('Gets a txSender correctly or throw error', async () => { // returns a parsed Aztec Address @@ -53,7 +53,7 @@ describe('CLI Utils', () => { (async () => { await getTxSender(client); })(), - ).rejects.toThrow('No accounts found in Aztec RPC instance.'); + ).rejects.toThrow('No accounts found in PXE instance.'); }); it('Encodes args correctly', () => { diff --git a/yarn-project/cli/src/utils.ts b/yarn-project/cli/src/utils.ts index 7bb19a4f8db..54cde4490de 100644 --- a/yarn-project/cli/src/utils.ts +++ b/yarn-project/cli/src/utils.ts @@ -1,4 +1,4 @@ -import { AztecAddress, AztecRPC, Fr } from '@aztec/aztec.js'; +import { AztecAddress, Fr, PXE } from '@aztec/aztec.js'; import { L1ContractArtifactsForDeployment, createEthereumChain, deployL1Contracts } from '@aztec/ethereum'; import { ContractAbi } from '@aztec/foundation/abi'; import { DebugLogger, LogFn } from '@aztec/foundation/log'; @@ -21,7 +21,6 @@ import { mnemonicToAccount, privateKeyToAccount } from 'viem/accounts'; import { encodeArgs } from './encoding.js'; -export { createClient } from './client.js'; /** * Helper type to dynamically import contracts. */ @@ -125,12 +124,12 @@ export async function getContractAbi(fileDir: string, log: LogFn) { /** * Utility to select a TX sender either from user input - * or from the first account that is found in an Aztec RPC instance. - * @param client - The Aztec RPC instance that will be checked for an account. + * or from the first account that is found in a PXE instance. + * @param pxe - The PXE instance that will be checked for an account. * @param _from - The user input. * @returns An Aztec address. Will throw if one can't be found in either options. */ -export async function getTxSender(client: AztecRPC, _from?: string) { +export async function getTxSender(pxe: PXE, _from?: string) { let from: AztecAddress; if (_from) { try { @@ -139,9 +138,9 @@ export async function getTxSender(client: AztecRPC, _from?: string) { throw new Error(`Invalid option 'from' passed: ${_from}`); } } else { - const accounts = await client.getRegisteredAccounts(); + const accounts = await pxe.getRegisteredAccounts(); if (!accounts.length) { - throw new Error('No accounts found in Aztec RPC instance.'); + throw new Error('No accounts found in PXE instance.'); } from = accounts[0].address; } diff --git a/yarn-project/end-to-end/scripts/docker-compose-e2e-sandbox-browser.yml b/yarn-project/end-to-end/scripts/docker-compose-e2e-sandbox-browser.yml index cbee1a7bbfd..54424e6c93e 100644 --- a/yarn-project/end-to-end/scripts/docker-compose-e2e-sandbox-browser.yml +++ b/yarn-project/end-to-end/scripts/docker-compose-e2e-sandbox-browser.yml @@ -22,7 +22,7 @@ services: P2P_BLOCK_CHECK_INTERVAL_MS: 50 SEQ_TX_POLLING_INTERVAL_MS: 50 WS_BLOCK_CHECK_INTERVAL_MS: 50 - RPC_SERVER_BLOCK_POLLING_INTERVAL_MS: 50 + PXE_SERVICE_BLOCK_POLLING_INTERVAL_MS: 50 ARCHIVER_VIEM_POLLING_INTERVAL_MS: 500 SEARCH_START_BLOCK: ${FORK_BLOCK_NUMBER:-0} ports: diff --git a/yarn-project/end-to-end/scripts/docker-compose-e2e-sandbox.yml b/yarn-project/end-to-end/scripts/docker-compose-e2e-sandbox.yml index 3ab4dc4a37b..53eb4fde6d2 100644 --- a/yarn-project/end-to-end/scripts/docker-compose-e2e-sandbox.yml +++ b/yarn-project/end-to-end/scripts/docker-compose-e2e-sandbox.yml @@ -22,7 +22,7 @@ services: P2P_BLOCK_CHECK_INTERVAL_MS: 50 SEQ_TX_POLLING_INTERVAL_MS: 50 WS_BLOCK_CHECK_INTERVAL_MS: 50 - RPC_SERVER_BLOCK_POLLING_INTERVAL_MS: 50 + PXE_SERVICE_BLOCK_POLLING_INTERVAL_MS: 50 ARCHIVER_VIEM_POLLING_INTERVAL_MS: 500 SEARCH_START_BLOCK: ${FORK_BLOCK_NUMBER:-0} ports: diff --git a/yarn-project/end-to-end/scripts/docker-compose.yml b/yarn-project/end-to-end/scripts/docker-compose.yml index cf73156c000..a20f4ffb02f 100644 --- a/yarn-project/end-to-end/scripts/docker-compose.yml +++ b/yarn-project/end-to-end/scripts/docker-compose.yml @@ -22,7 +22,7 @@ services: P2P_BLOCK_CHECK_INTERVAL_MS: 50 SEQ_TX_POLLING_INTERVAL_MS: 50 WS_BLOCK_CHECK_INTERVAL_MS: 50 - RPC_SERVER_BLOCK_POLLING_INTERVAL_MS: 50 + PXE_SERVICE_BLOCK_POLLING_INTERVAL_MS: 50 ARCHIVER_VIEM_POLLING_INTERVAL_MS: 500 SEARCH_START_BLOCK: ${FORK_BLOCK_NUMBER:-0} command: ${TEST:-./src/e2e_deploy_contract.test.ts} diff --git a/yarn-project/end-to-end/src/aztec_rpc_sandbox.test.ts b/yarn-project/end-to-end/src/aztec_rpc_sandbox.test.ts deleted file mode 100644 index c6becb31dc5..00000000000 --- a/yarn-project/end-to-end/src/aztec_rpc_sandbox.test.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { createAztecRpcClient, waitForSandbox } from '@aztec/aztec.js'; -import { aztecRpcTestSuite } from '@aztec/pxe'; - -const { SANDBOX_URL = 'http://localhost:8080' } = process.env; - -const setup = async () => { - const aztecRpc = createAztecRpcClient(SANDBOX_URL); - await waitForSandbox(aztecRpc); - return aztecRpc; -}; - -aztecRpcTestSuite('aztec_rpc_sandbox', setup); diff --git a/yarn-project/end-to-end/src/canary/browser.ts b/yarn-project/end-to-end/src/canary/browser.ts index c3f16ff9861..2053fbfab21 100644 --- a/yarn-project/end-to-end/src/canary/browser.ts +++ b/yarn-project/end-to-end/src/canary/browser.ts @@ -38,7 +38,7 @@ export const browserTestSuite = (setup: () => Server, pageLogger: AztecJs.DebugL let contractAddress: AztecJs.AztecAddress; let app: Koa; - let testClient: AztecJs.AztecRPC; + let testClient: AztecJs.PXE; let server: Server; let browser: Browser; @@ -46,7 +46,7 @@ export const browserTestSuite = (setup: () => Server, pageLogger: AztecJs.DebugL beforeAll(async () => { server = setup(); - testClient = AztecJs.createAztecRpcClient(SANDBOX_URL!); + testClient = AztecJs.createPXEClient(SANDBOX_URL!); await AztecJs.waitForSandbox(testClient); app = new Koa(); @@ -90,10 +90,10 @@ export const browserTestSuite = (setup: () => Server, pageLogger: AztecJs.DebugL it('Creates an account', async () => { const result = await page.evaluate( async (rpcUrl, privateKeyString) => { - const { GrumpkinScalar, createAztecRpcClient, getUnsafeSchnorrAccount } = window.AztecJs; - const client = createAztecRpcClient(rpcUrl!); + const { GrumpkinScalar, createPXEClient: createPXEClient, getUnsafeSchnorrAccount } = window.AztecJs; + const pxe = createPXEClient(rpcUrl!); const privateKey = GrumpkinScalar.fromString(privateKeyString); - const account = getUnsafeSchnorrAccount(client, privateKey); + const account = getUnsafeSchnorrAccount(pxe, privateKey); await account.waitDeploy(); const completeAddress = await account.getCompleteAddress(); const addressString = completeAddress.address.toString(); @@ -115,10 +115,10 @@ export const browserTestSuite = (setup: () => Server, pageLogger: AztecJs.DebugL it("Gets the owner's balance", async () => { const result = await page.evaluate( async (rpcUrl, contractAddress, TokenContractAbi) => { - const { Contract, AztecAddress, createAztecRpcClient } = window.AztecJs; - const client = createAztecRpcClient(rpcUrl!); - const owner = (await client.getRegisteredAccounts())[0].address; - const [wallet] = await AztecJs.getSandboxAccountsWallets(client); + const { Contract, AztecAddress, createPXEClient: createPXEClient } = window.AztecJs; + const pxe = createPXEClient(rpcUrl!); + const owner = (await pxe.getRegisteredAccounts())[0].address; + const [wallet] = await AztecJs.getSandboxAccountsWallets(pxe); const contract = await Contract.at(AztecAddress.fromString(contractAddress), TokenContractAbi, wallet); const balance = await contract.methods.balance_of_private(owner).view({ from: owner }); return balance; @@ -134,11 +134,11 @@ export const browserTestSuite = (setup: () => Server, pageLogger: AztecJs.DebugL const result = await page.evaluate( async (rpcUrl, contractAddress, transferAmount, TokenContractAbi) => { console.log(`Starting transfer tx`); - const { AztecAddress, Contract, createAztecRpcClient } = window.AztecJs; - const client = createAztecRpcClient(rpcUrl!); - const accounts = await client.getRegisteredAccounts(); + const { AztecAddress, Contract, createPXEClient: createPXEClient } = window.AztecJs; + const pxe = createPXEClient(rpcUrl!); + const accounts = await pxe.getRegisteredAccounts(); const receiver = accounts[1].address; - const [wallet] = await AztecJs.getSandboxAccountsWallets(client); + const [wallet] = await AztecJs.getSandboxAccountsWallets(pxe); const contract = await Contract.at(AztecAddress.fromString(contractAddress), TokenContractAbi, wallet); await contract.methods.transfer(accounts[0].address, receiver, transferAmount, 0).send().wait(); console.log(`Transferred ${transferAmount} tokens to new Account`); @@ -158,23 +158,23 @@ export const browserTestSuite = (setup: () => Server, pageLogger: AztecJs.DebugL const { GrumpkinScalar, DeployMethod, - createAztecRpcClient, + createPXEClient: createPXEClient, getUnsafeSchnorrAccount, Contract, Fr, computeMessageSecretHash, getSandboxAccountsWallets, } = window.AztecJs; - const client = createAztecRpcClient(rpcUrl!); - let accounts = await client.getRegisteredAccounts(); + const pxe = createPXEClient(rpcUrl!); + let accounts = await pxe.getRegisteredAccounts(); if (accounts.length === 0) { - // This test needs an account for deployment. We create one in case there is none available in the RPC server. + // This test needs an account for deployment. We create one in case there is none available in the PXE. const privateKey = GrumpkinScalar.fromString(privateKeyString); - await getUnsafeSchnorrAccount(client, privateKey).waitDeploy(); - accounts = await client.getRegisteredAccounts(); + await getUnsafeSchnorrAccount(pxe, privateKey).waitDeploy(); + accounts = await pxe.getRegisteredAccounts(); } - const [owner] = await getSandboxAccountsWallets(client); - const tx = new DeployMethod(accounts[0].publicKey, client, TokenContractAbi).send(); + const [owner] = await getSandboxAccountsWallets(pxe); + const tx = new DeployMethod(accounts[0].publicKey, pxe, TokenContractAbi).send(); await tx.wait(); const receipt = await tx.getReceipt(); console.log(`Contract Deployed: ${receipt.contractAddress}`); diff --git a/yarn-project/end-to-end/src/canary/cli.ts b/yarn-project/end-to-end/src/canary/cli.ts index 2cc7442ef29..cffc82ff952 100644 --- a/yarn-project/end-to-end/src/canary/cli.ts +++ b/yarn-project/end-to-end/src/canary/cli.ts @@ -1,4 +1,4 @@ -import { AztecAddress, AztecRPC, CompleteAddress, DebugLogger, Fr, computeMessageSecretHash } from '@aztec/aztec.js'; +import { AztecAddress, CompleteAddress, DebugLogger, Fr, PXE, computeMessageSecretHash } from '@aztec/aztec.js'; import { getProgram } from '@aztec/cli'; import stringArgv from 'string-argv'; @@ -9,14 +9,14 @@ const TRANSFER_BALANCE = 3000; export const cliTestSuite = ( name: string, - setup: () => Promise, + setup: () => Promise, cleanup: () => Promise, debug: DebugLogger, rpcUrl = 'http://localhost:8080', ) => describe(name, () => { let cli: ReturnType; - let aztecRpcClient: AztecRPC; + let pxe: PXE; let existingAccounts: CompleteAddress[]; let contractAddress: AztecAddress; let log: (...args: any[]) => void; @@ -25,7 +25,7 @@ export const cliTestSuite = ( const logs: string[] = []; beforeAll(async () => { - aztecRpcClient = await setup(); + pxe = await setup(); log = (...args: any[]) => { logs.push(format(...args)); debug(...args); @@ -79,14 +79,14 @@ export const cliTestSuite = ( }; it('creates & retrieves an account', async () => { - existingAccounts = await aztecRpcClient.getRegisteredAccounts(); + existingAccounts = await pxe.getRegisteredAccounts(); debug('Create an account'); await run(`create-account`); const foundAddress = findInLogs(/Address:\s+(?
0x[a-fA-F0-9]+)/)?.groups?.address; expect(foundAddress).toBeDefined(); const newAddress = AztecAddress.fromString(foundAddress!); - const accountsAfter = await aztecRpcClient.getRegisteredAccounts(); + const accountsAfter = await pxe.getRegisteredAccounts(); const expectedAccounts = [...existingAccounts.map(a => a.address), newAddress]; expect(accountsAfter.map(a => a.address)).toEqual(expectedAccounts); const newCompleteAddress = accountsAfter[accountsAfter.length - 1]; @@ -123,7 +123,7 @@ export const cliTestSuite = ( expect(loggedAddress).toBeDefined(); contractAddress = AztecAddress.fromString(loggedAddress!); - const deployedContract = await aztecRpcClient.getContractData(contractAddress); + const deployedContract = await pxe.getContractData(contractAddress); expect(deployedContract?.contractAddress).toEqual(contractAddress); debug('Check contract can be found in returned address'); @@ -161,7 +161,7 @@ export const cliTestSuite = ( expect(balance!).toEqual(`${BigInt(INITIAL_BALANCE).toString()}n`); debug('Transfer some tokens'); - const existingAccounts = await aztecRpcClient.getRegisteredAccounts(); + const existingAccounts = await pxe.getRegisteredAccounts(); // ensure we pick a different acc const receiver = existingAccounts.find(acc => acc.address.toString() !== ownerAddress.toString()); diff --git a/yarn-project/end-to-end/src/e2e_2_rpc_servers.test.ts b/yarn-project/end-to-end/src/e2e_2_pxes.test.ts similarity index 80% rename from yarn-project/end-to-end/src/e2e_2_rpc_servers.test.ts rename to yarn-project/end-to-end/src/e2e_2_pxes.test.ts index 88be20741da..e81995f0239 100644 --- a/yarn-project/end-to-end/src/e2e_2_rpc_servers.test.ts +++ b/yarn-project/end-to-end/src/e2e_2_pxes.test.ts @@ -4,23 +4,23 @@ import { DebugLogger } from '@aztec/foundation/log'; import { retryUntil } from '@aztec/foundation/retry'; import { toBigInt } from '@aztec/foundation/serialize'; import { ChildContract, TokenContract } from '@aztec/noir-contracts/types'; -import { AztecRPCServer, EthAddress, Fr } from '@aztec/pxe'; -import { AztecRPC, CompleteAddress, TxStatus } from '@aztec/types'; +import { EthAddress, Fr, PXEService } from '@aztec/pxe'; +import { CompleteAddress, PXE, TxStatus } from '@aztec/types'; import { jest } from '@jest/globals'; -import { expectsNumOfEncryptedLogsInTheLastBlockToBe, setup, setupAztecRPCServer } from './fixtures/utils.js'; +import { expectsNumOfEncryptedLogsInTheLastBlockToBe, setup, setupPXEService } from './fixtures/utils.js'; const { SANDBOX_URL = '' } = process.env; const TIMEOUT = 60_000; -describe('e2e_2_rpc_servers', () => { +describe('e2e_2_pxes', () => { jest.setTimeout(TIMEOUT); let aztecNode: AztecNodeService | undefined; - let aztecRpcServerA: AztecRPC; - let aztecRpcServerB: AztecRPC; + let pxeA: PXE; + let pxeB: PXE; let walletA: Wallet; let walletB: Wallet; let userA: CompleteAddress; @@ -29,14 +29,14 @@ describe('e2e_2_rpc_servers', () => { let teardownA: () => Promise; beforeEach(async () => { - // this test can't be run against the sandbox as it requires 2 RPC servers + // this test can't be run against the sandbox as it requires 2 PXEs if (SANDBOX_URL) { - throw new Error(`Test can't be run against the sandbox as 2 RPC servers are required`); + throw new Error(`Test can't be run against the sandbox as 2 PXEs are required`); } let accounts: CompleteAddress[] = []; ({ aztecNode, - aztecRpcServer: aztecRpcServerA, + pxe: pxeA, accounts, wallets: [walletA], logger, @@ -45,16 +45,16 @@ describe('e2e_2_rpc_servers', () => { [userA] = accounts; ({ - aztecRpcServer: aztecRpcServerB, + pxe: pxeB, accounts: accounts, wallets: [walletB], - } = await setupAztecRPCServer(1, aztecNode!, undefined, true)); + } = await setupPXEService(1, aztecNode!, undefined, true)); [userB] = accounts; }, 100_000); afterEach(async () => { await teardownA(); - if (aztecRpcServerB instanceof AztecRPCServer) await aztecRpcServerB.stop(); + if (pxeB instanceof PXEService) await pxeB.stop(); }); const awaitUserSynchronized = async (wallet: Wallet, owner: AztecAddress) => { @@ -72,7 +72,7 @@ describe('e2e_2_rpc_servers', () => { checkIfSynchronized = true, ) => { if (checkIfSynchronized) { - // First wait until the corresponding RPC server has synchronized the account + // First wait until the corresponding PXE has synchronized the account await awaitUserSynchronized(wallet, owner); } @@ -107,7 +107,7 @@ describe('e2e_2_rpc_servers', () => { ); }; - it('transfers fund from user A to B via RPC server A followed by transfer from B to A via RPC server B', async () => { + it('transfers fund from user A to B via PXE A followed by transfer from B to A via PXE B', async () => { const initialBalance = 987n; const transferAmount1 = 654n; const transferAmount2 = 323n; @@ -116,12 +116,12 @@ describe('e2e_2_rpc_servers', () => { const tokenAddress = completeTokenAddress.address; // Add account B to wallet A - await aztecRpcServerA.registerRecipient(userB); + await pxeA.registerRecipient(userB); // Add account A to wallet B - await aztecRpcServerB.registerRecipient(userA); + await pxeB.registerRecipient(userA); - // Add token to RPC server B (RPC server A already has it because it was deployed through it) - await aztecRpcServerB.addContracts([ + // Add token to PXE B (PXE A already has it because it was deployed through it) + await pxeB.addContracts([ { abi: TokenContract.abi, completeAddress: completeTokenAddress, @@ -134,7 +134,7 @@ describe('e2e_2_rpc_servers', () => { await expectTokenBalance(walletB, tokenAddress, userB.address, 0n); await expectsNumOfEncryptedLogsInTheLastBlockToBe(aztecNode, 1); - // Transfer funds from A to B via RPC server A + // Transfer funds from A to B via PXE A const contractWithWalletA = await TokenContract.at(tokenAddress, walletA); const receiptAToB = await contractWithWalletA.methods .transfer(userA.address, userB.address, transferAmount1, 0) @@ -147,7 +147,7 @@ describe('e2e_2_rpc_servers', () => { await expectTokenBalance(walletB, tokenAddress, userB.address, transferAmount1); await expectsNumOfEncryptedLogsInTheLastBlockToBe(aztecNode, 2); - // Transfer funds from B to A via RPC server B + // Transfer funds from B to A via PXE B const contractWithWalletB = await TokenContract.at(tokenAddress, walletB); await contractWithWalletB.methods .transfer(userB.address, userA.address, transferAmount2, 0) @@ -168,23 +168,23 @@ describe('e2e_2_rpc_servers', () => { return contract.completeAddress; }; - const awaitServerSynchronized = async (server: AztecRPC) => { + const awaitServerSynchronized = async (server: PXE) => { const isServerSynchronized = async () => { return await server.isGlobalStateSynchronized(); }; await retryUntil(isServerSynchronized, 'server sync', 10); }; - const getChildStoredValue = (child: { address: AztecAddress }, aztecRpcServer: AztecRPC) => - aztecRpcServer.getPublicStorageAt(child.address, new Fr(1)).then(x => toBigInt(x!)); + const getChildStoredValue = (child: { address: AztecAddress }, pxe: PXE) => + pxe.getPublicStorageAt(child.address, new Fr(1)).then(x => toBigInt(x!)); - it('user calls a public function on a contract deployed by a different user using a different RPC server', async () => { + it('user calls a public function on a contract deployed by a different user using a different PXE', async () => { const childCompleteAddress = await deployChildContractViaServerA(); - await awaitServerSynchronized(aztecRpcServerA); + await awaitServerSynchronized(pxeA); - // Add Child to RPC server B - await aztecRpcServerB.addContracts([ + // Add Child to PXE B + await pxeB.addContracts([ { abi: ChildContract.abi, completeAddress: childCompleteAddress, @@ -197,13 +197,13 @@ describe('e2e_2_rpc_servers', () => { const childContractWithWalletB = await ChildContract.at(childCompleteAddress.address, walletB); await childContractWithWalletB.methods.pubIncValue(newValueToSet).send().wait({ interval: 0.1 }); - await awaitServerSynchronized(aztecRpcServerA); + await awaitServerSynchronized(pxeA); - const storedValue = await getChildStoredValue(childCompleteAddress, aztecRpcServerB); + const storedValue = await getChildStoredValue(childCompleteAddress, pxeB); expect(storedValue).toBe(newValueToSet); }); - it('private state is "zero" when Aztec RPC Server does not have the account private key', async () => { + it('private state is "zero" when Private Execution Environment (PXE) does not have the account private key', async () => { const userABalance = 100n; const userBBalance = 150n; @@ -211,12 +211,12 @@ describe('e2e_2_rpc_servers', () => { const contractWithWalletA = await TokenContract.at(completeTokenAddress.address, walletA); // Add account B to wallet A - await aztecRpcServerA.registerRecipient(userB); + await pxeA.registerRecipient(userB); // Add account A to wallet B - await aztecRpcServerB.registerRecipient(userA); + await pxeB.registerRecipient(userA); - // Add token to RPC server B (RPC server A already has it because it was deployed through it) - await aztecRpcServerB.addContracts([ + // Add token to PXE B (PXE A already has it because it was deployed through it) + await pxeB.addContracts([ { abi: TokenContract.abi, completeAddress: completeTokenAddress, diff --git a/yarn-project/end-to-end/src/e2e_account_contracts.test.ts b/yarn-project/end-to-end/src/e2e_account_contracts.test.ts index 51a1b1773bc..aaca09892b7 100644 --- a/yarn-project/end-to-end/src/e2e_account_contracts.test.ts +++ b/yarn-project/end-to-end/src/e2e_account_contracts.test.ts @@ -1,9 +1,9 @@ import { AccountContract, AccountManager, - AztecRPC, EcdsaAccountContract, Fr, + PXE, SchnorrAccountContract, SingleKeyAccountContract, Wallet, @@ -19,7 +19,7 @@ import { setup } from './fixtures/utils.js'; function itShouldBehaveLikeAnAccountContract( getAccountContract: (encryptionKey: GrumpkinPrivateKey) => AccountContract, walletSetup: ( - rpc: AztecRPC, + pxe: PXE, encryptionPrivateKey: GrumpkinPrivateKey, accountContract: AccountContract, address?: CompleteAddress, @@ -37,7 +37,7 @@ function itShouldBehaveLikeAnAccountContract( encryptionPrivateKey = GrumpkinScalar.random(); ({ account, wallet } = await walletSetup( - context.aztecRpcServer, + context.pxe, encryptionPrivateKey, getAccountContract(encryptionPrivateKey), )); @@ -53,16 +53,16 @@ function itShouldBehaveLikeAnAccountContract( }, 60_000); it('calls a public function', async () => { - const { logger, aztecRpcServer } = context; + const { logger, pxe } = context; logger('Calling public function...'); await child.methods.pubIncValue(42).send().wait({ interval: 0.1 }); - expect(toBigInt((await aztecRpcServer.getPublicStorageAt(child.address, new Fr(1)))!)).toEqual(42n); + expect(toBigInt((await pxe.getPublicStorageAt(child.address, new Fr(1)))!)).toEqual(42n); }, 60_000); it('fails to call a function using an invalid signature', async () => { const accountAddress = await account.getCompleteAddress(); const { wallet: invalidWallet } = await walletSetup( - context.aztecRpcServer, + context.pxe, encryptionPrivateKey, getAccountContract(GrumpkinScalar.random()), accountAddress, @@ -77,12 +77,12 @@ function itShouldBehaveLikeAnAccountContract( describe('e2e_account_contracts', () => { const base = async ( - rpc: AztecRPC, + pxe: PXE, encryptionPrivateKey: GrumpkinPrivateKey, accountContract: AccountContract, address?: CompleteAddress, ) => { - const account = new AccountManager(rpc, encryptionPrivateKey, accountContract, address); + const account = new AccountManager(pxe, encryptionPrivateKey, accountContract, address); const wallet = !address ? await account.deploy().then(tx => tx.getWallet()) : await account.getWallet(); return { account, wallet }; }; diff --git a/yarn-project/end-to-end/src/e2e_block_building.test.ts b/yarn-project/end-to-end/src/e2e_block_building.test.ts index 7aad5d37038..a7e589d08ff 100644 --- a/yarn-project/end-to-end/src/e2e_block_building.test.ts +++ b/yarn-project/end-to-end/src/e2e_block_building.test.ts @@ -4,14 +4,14 @@ import { pedersenPlookupCommitInputs } from '@aztec/circuits.js/barretenberg'; import { DebugLogger } from '@aztec/foundation/log'; import { TestContractAbi } from '@aztec/noir-contracts/artifacts'; import { TestContract } from '@aztec/noir-contracts/types'; -import { AztecRPC, TxStatus } from '@aztec/types'; +import { PXE, TxStatus } from '@aztec/types'; import times from 'lodash.times'; import { setup } from './fixtures/utils.js'; describe('e2e_block_building', () => { - let aztecRpcServer: AztecRPC; + let pxe: PXE; let logger: DebugLogger; let wallet: Wallet; let teardown: () => Promise; @@ -20,7 +20,7 @@ describe('e2e_block_building', () => { const abi = TestContractAbi; beforeAll(async () => { - ({ teardown, aztecRpcServer, logger, wallet } = await setup(1)); + ({ teardown, pxe, logger, wallet } = await setup(1)); }, 100_000); afterAll(() => teardown()); @@ -48,7 +48,7 @@ describe('e2e_block_building', () => { expect(receipts.map(r => r.blockNumber)).toEqual(times(TX_COUNT, () => receipts[0].blockNumber)); // Assert all contracts got deployed - const areDeployed = await Promise.all(receipts.map(r => isContractDeployed(aztecRpcServer, r.contractAddress!))); + const areDeployed = await Promise.all(receipts.map(r => isContractDeployed(pxe, r.contractAddress!))); expect(areDeployed).toEqual(times(TX_COUNT, () => true)); }, 60_000); }); @@ -59,7 +59,7 @@ describe('e2e_block_building', () => { let teardown: () => Promise; beforeAll(async () => { - ({ teardown, aztecRpcServer, logger, wallet } = await setup(1)); + ({ teardown, pxe, logger, wallet } = await setup(1)); contract = await TestContract.deploy(wallet).send().deployed(); }, 100_000); diff --git a/yarn-project/end-to-end/src/e2e_card_game.test.ts b/yarn-project/end-to-end/src/e2e_card_game.test.ts index b6bdcb19d7b..5ff8b15c591 100644 --- a/yarn-project/end-to-end/src/e2e_card_game.test.ts +++ b/yarn-project/end-to-end/src/e2e_card_game.test.ts @@ -1,7 +1,7 @@ import { AccountWallet, AztecAddress, Wallet, deployInitialSandboxAccounts } from '@aztec/aztec.js'; import { DebugLogger } from '@aztec/foundation/log'; import { CardGameContract } from '@aztec/noir-contracts/types'; -import { AztecRPC } from '@aztec/types'; +import { PXE } from '@aztec/types'; import { setup } from './fixtures/utils.js'; @@ -44,7 +44,7 @@ function unwrapOptions(options: NoirOption[]): T[] { const GAME_ID = 42; describe('e2e_card_game', () => { - let aztecRpcServer: AztecRPC; + let pxe: PXE; let logger: DebugLogger; let teardown: () => Promise; @@ -64,8 +64,8 @@ describe('e2e_card_game', () => { beforeEach(async () => { // Card stats are derived from the users' private keys, so to get consistent values, we set up the // initial sandbox accounts that always use the same private keys, instead of random ones. - ({ aztecRpcServer, logger, teardown } = await setup(0)); - wallets = await Promise.all((await deployInitialSandboxAccounts(aztecRpcServer)).map(a => a.account.getWallet())); + ({ pxe, logger, teardown } = await setup(0)); + wallets = await Promise.all((await deployInitialSandboxAccounts(pxe)).map(a => a.account.getWallet())); [firstPlayerWallet, secondPlayerWallet, thirdPlayerWallet] = wallets; [firstPlayer, secondPlayer, thirdPlayer] = wallets.map(a => a.getAddress()); await deployContract(); diff --git a/yarn-project/end-to-end/src/e2e_cheat_codes.test.ts b/yarn-project/end-to-end/src/e2e_cheat_codes.test.ts index 75cf2245ee9..3cc9079d287 100644 --- a/yarn-project/end-to-end/src/e2e_cheat_codes.test.ts +++ b/yarn-project/end-to-end/src/e2e_cheat_codes.test.ts @@ -2,14 +2,14 @@ import { CheatCodes, Wallet } from '@aztec/aztec.js'; import { RollupAbi } from '@aztec/l1-artifacts'; import { TestContract } from '@aztec/noir-contracts/types'; import { EthAddress } from '@aztec/pxe'; -import { AztecRPC, TxStatus } from '@aztec/types'; +import { PXE, TxStatus } from '@aztec/types'; import { Account, Chain, HttpTransport, PublicClient, WalletClient, getAddress, getContract, parseEther } from 'viem'; import { setup } from './fixtures/utils.js'; describe('e2e_cheat_codes', () => { - let aztecRpcServer: AztecRPC; + let pxe: PXE; let wallet: Wallet; let cc: CheatCodes; let teardown: () => Promise; @@ -20,7 +20,7 @@ describe('e2e_cheat_codes', () => { beforeAll(async () => { let deployL1ContractsValues; - ({ teardown, aztecRpcServer, wallet, cheatCodes: cc, deployL1ContractsValues } = await setup()); + ({ teardown, pxe, wallet, cheatCodes: cc, deployL1ContractsValues } = await setup()); walletClient = deployL1ContractsValues.walletClient; publicClient = deployL1ContractsValues.publicClient; @@ -134,7 +134,7 @@ describe('e2e_cheat_codes', () => { }); it('can modify L2 block time', async () => { - const tx = TestContract.deploy(aztecRpcServer).send(); + const tx = TestContract.deploy(pxe).send(); await tx.isMined({ interval: 0.1 }); const receipt = await tx.getReceipt(); const contract = await TestContract.at(receipt.contractAddress!, wallet); diff --git a/yarn-project/end-to-end/src/e2e_cli.test.ts b/yarn-project/end-to-end/src/e2e_cli.test.ts index 36795577426..37e4a3c1cda 100644 --- a/yarn-project/end-to-end/src/e2e_cli.test.ts +++ b/yarn-project/end-to-end/src/e2e_cli.test.ts @@ -1,7 +1,7 @@ import { AztecNodeService } from '@aztec/aztec-node'; import { startHttpRpcServer } from '@aztec/aztec-sandbox'; -import { AztecRPC, createDebugLogger } from '@aztec/aztec.js'; -import { AztecRPCServer } from '@aztec/pxe'; +import { PXE, createDebugLogger } from '@aztec/aztec.js'; +import { PXEService } from '@aztec/pxe'; import { cliTestSuite } from './canary/cli.js'; import { setup as e2eSetup } from './fixtures/utils.js'; @@ -12,21 +12,21 @@ const debug = createDebugLogger('aztec:e2e_cli'); let http: ReturnType; let aztecNode: AztecNodeService | undefined; -let aztecRpcServer: AztecRPC; +let pxe: PXE; const testSetup = async () => { const context = await e2eSetup(2); debug(`Environment set up`); - ({ aztecNode, aztecRpcServer } = context); - http = startHttpRpcServer(aztecRpcServer, HTTP_PORT); + ({ aztecNode, pxe } = context); + http = startHttpRpcServer(pxe, HTTP_PORT); debug(`HTTP RPC server started in port ${HTTP_PORT}`); - return aztecRpcServer; + return pxe; }; const testCleanup = async () => { http.close(); await aztecNode?.stop(); - await (aztecRpcServer as AztecRPCServer).stop(); + await (pxe as PXEService).stop(); }; cliTestSuite('E2E CLI Test', testSetup, testCleanup, createDebugLogger('aztec:e2e_cli'), RPC_URL); diff --git a/yarn-project/end-to-end/src/e2e_cross_chain_messaging.test.ts b/yarn-project/end-to-end/src/e2e_cross_chain_messaging.test.ts index ebb44ddd98b..c9eb2d5ae42 100644 --- a/yarn-project/end-to-end/src/e2e_cross_chain_messaging.test.ts +++ b/yarn-project/end-to-end/src/e2e_cross_chain_messaging.test.ts @@ -25,7 +25,7 @@ describe('e2e_cross_chain_messaging', () => { beforeEach(async () => { const { aztecNode, - aztecRpcServer, + pxe, deployL1ContractsValues, accounts, wallets, @@ -36,7 +36,7 @@ describe('e2e_cross_chain_messaging', () => { crossChainTestHarness = await CrossChainTestHarness.new( aztecNode, - aztecRpcServer, + pxe, deployL1ContractsValues, accounts, wallets[0], diff --git a/yarn-project/end-to-end/src/e2e_deploy_contract.test.ts b/yarn-project/end-to-end/src/e2e_deploy_contract.test.ts index 1317cd6fcb6..b1b4196fbe8 100644 --- a/yarn-project/end-to-end/src/e2e_deploy_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_deploy_contract.test.ts @@ -2,19 +2,19 @@ import { AztecAddress, Contract, ContractDeployer, Fr, Wallet, isContractDeploye import { CompleteAddress, getContractDeploymentInfo } from '@aztec/circuits.js'; import { DebugLogger } from '@aztec/foundation/log'; import { TestContractAbi } from '@aztec/noir-contracts/artifacts'; -import { AztecRPC, TxStatus } from '@aztec/types'; +import { PXE, TxStatus } from '@aztec/types'; import { setup } from './fixtures/utils.js'; describe('e2e_deploy_contract', () => { - let aztecRpcServer: AztecRPC; + let pxe: PXE; let accounts: CompleteAddress[]; let logger: DebugLogger; let wallet: Wallet; let teardown: () => Promise; beforeEach(async () => { - ({ teardown, aztecRpcServer, accounts, logger, wallet } = await setup()); + ({ teardown, pxe, accounts, logger, wallet } = await setup()); }, 100_000); afterEach(() => teardown()); @@ -27,7 +27,7 @@ describe('e2e_deploy_contract', () => { const publicKey = accounts[0].publicKey; const salt = Fr.random(); const deploymentData = await getContractDeploymentInfo(TestContractAbi, [], salt, publicKey); - const deployer = new ContractDeployer(TestContractAbi, aztecRpcServer, publicKey); + const deployer = new ContractDeployer(TestContractAbi, pxe, publicKey); const tx = deployer.deploy().send({ contractAddressSalt: salt }); logger(`Tx sent with hash ${await tx.getTxHash()}`); const receipt = await tx.getReceipt(); @@ -50,15 +50,15 @@ describe('e2e_deploy_contract', () => { }), ); const contractAddress = receiptAfterMined.contractAddress!; - expect(await isContractDeployed(aztecRpcServer, contractAddress)).toBe(true); - expect(await isContractDeployed(aztecRpcServer, AztecAddress.random())).toBe(false); + expect(await isContractDeployed(pxe, contractAddress)).toBe(true); + expect(await isContractDeployed(pxe, AztecAddress.random())).toBe(false); }, 30_000); /** * Verify that we can produce multiple rollups. */ it('should deploy one contract after another in consecutive rollups', async () => { - const deployer = new ContractDeployer(TestContractAbi, aztecRpcServer); + const deployer = new ContractDeployer(TestContractAbi, pxe); for (let index = 0; index < 2; index++) { logger(`Deploying contract ${index + 1}...`); @@ -74,7 +74,7 @@ describe('e2e_deploy_contract', () => { * Verify that we can deploy multiple contracts and interact with all of them. */ it('should deploy multiple contracts and interact with them', async () => { - const deployer = new ContractDeployer(TestContractAbi, aztecRpcServer); + const deployer = new ContractDeployer(TestContractAbi, pxe); for (let index = 0; index < 2; index++) { logger(`Deploying contract ${index + 1}...`); @@ -92,7 +92,7 @@ describe('e2e_deploy_contract', () => { */ it('should not deploy a contract with the same salt twice', async () => { const contractAddressSalt = Fr.random(); - const deployer = new ContractDeployer(TestContractAbi, aztecRpcServer); + const deployer = new ContractDeployer(TestContractAbi, pxe); { const tx = deployer.deploy().send({ contractAddressSalt }); diff --git a/yarn-project/end-to-end/src/e2e_escrow_contract.test.ts b/yarn-project/end-to-end/src/e2e_escrow_contract.test.ts index 1a661fe563d..075df4b3ef1 100644 --- a/yarn-project/end-to-end/src/e2e_escrow_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_escrow_contract.test.ts @@ -3,12 +3,12 @@ import { CompleteAddress, Fr, GrumpkinPrivateKey, GrumpkinScalar, getContractDep import { DebugLogger } from '@aztec/foundation/log'; import { EscrowContractAbi } from '@aztec/noir-contracts/artifacts'; import { EscrowContract, TokenContract } from '@aztec/noir-contracts/types'; -import { AztecRPC, PublicKey, TxStatus } from '@aztec/types'; +import { PXE, PublicKey, TxStatus } from '@aztec/types'; import { setup } from './fixtures/utils.js'; describe('e2e_escrow_contract', () => { - let aztecRpcServer: AztecRPC; + let pxe: PXE; let wallet: AccountWallet; let recipientWallet: AccountWallet; let accounts: CompleteAddress[]; @@ -27,7 +27,7 @@ describe('e2e_escrow_contract', () => { // Setup environment ({ teardown, - aztecRpcServer, + pxe, accounts, wallets: [wallet, recipientWallet], logger, @@ -35,13 +35,13 @@ describe('e2e_escrow_contract', () => { owner = accounts[0].address; recipient = accounts[1].address; - // Generate private key for escrow contract, register key in rpc server, and deploy + // Generate private key for escrow contract, register key in pxe service, and deploy // Note that we need to register it first if we want to emit an encrypted note for it in the constructor escrowPrivateKey = GrumpkinScalar.random(); escrowPublicKey = await generatePublicKey(escrowPrivateKey); const salt = Fr.random(); const deployInfo = await getContractDeploymentInfo(EscrowContractAbi, [owner], salt, escrowPublicKey); - await aztecRpcServer.registerAccount(escrowPrivateKey, deployInfo.completeAddress.partialAddress); + await pxe.registerAccount(escrowPrivateKey, deployInfo.completeAddress.partialAddress); escrowContract = await EscrowContract.deployWithPublicKey(wallet, escrowPublicKey, owner) .send({ contractAddressSalt: salt }) diff --git a/yarn-project/end-to-end/src/e2e_multiple_accounts_1_enc_key.test.ts b/yarn-project/end-to-end/src/e2e_multiple_accounts_1_enc_key.test.ts index 688d5c4cd16..23263fa4edf 100644 --- a/yarn-project/end-to-end/src/e2e_multiple_accounts_1_enc_key.test.ts +++ b/yarn-project/end-to-end/src/e2e_multiple_accounts_1_enc_key.test.ts @@ -3,13 +3,13 @@ import { AztecAddress, Wallet, computeMessageSecretHash, generatePublicKey, getS import { Fr, GrumpkinScalar } from '@aztec/circuits.js'; import { DebugLogger } from '@aztec/foundation/log'; import { TokenContract } from '@aztec/noir-contracts/types'; -import { AztecRPC, TxStatus } from '@aztec/types'; +import { PXE, TxStatus } from '@aztec/types'; import { expectsNumOfEncryptedLogsInTheLastBlockToBe, setup } from './fixtures/utils.js'; describe('e2e_multiple_accounts_1_enc_key', () => { let aztecNode: AztecNodeService | undefined; - let aztecRpcServer: AztecRPC; + let pxe: PXE; const wallets: Wallet[] = []; const accounts: AztecAddress[] = []; let logger: DebugLogger; @@ -21,14 +21,14 @@ describe('e2e_multiple_accounts_1_enc_key', () => { const numAccounts = 3; beforeEach(async () => { - ({ teardown, aztecNode, aztecRpcServer, logger } = await setup(0)); + ({ teardown, aztecNode, pxe, logger } = await setup(0)); const encryptionPrivateKey = GrumpkinScalar.random(); for (let i = 0; i < numAccounts; i++) { logger(`Deploying account contract ${i}/3...`); const signingPrivateKey = GrumpkinScalar.random(); - const account = getSchnorrAccount(aztecRpcServer, encryptionPrivateKey, signingPrivateKey); + const account = getSchnorrAccount(pxe, encryptionPrivateKey, signingPrivateKey); const wallet = await account.waitDeploy({ interval: 0.1 }); const { address } = await account.getCompleteAddress(); wallets.push(wallet); @@ -38,7 +38,7 @@ describe('e2e_multiple_accounts_1_enc_key', () => { // Verify that all accounts use the same encryption key const encryptionPublicKey = await generatePublicKey(encryptionPrivateKey); - for (const account of await aztecRpcServer.getRegisteredAccounts()) { + for (const account of await pxe.getRegisteredAccounts()) { expect(account.publicKey).toEqual(encryptionPublicKey); } @@ -97,7 +97,7 @@ describe('e2e_multiple_accounts_1_enc_key', () => { }; /** - * Tests the ability of the Aztec RPC server to handle multiple accounts under the same encryption key. + * Tests the ability of the Private Execution Environment (PXE) to handle multiple accounts under the same encryption key. */ it('spends notes from multiple account under the same encryption key', async () => { const transferAmount1 = 654n; // account 0 -> account 1 diff --git a/yarn-project/end-to-end/src/e2e_nested_contract.test.ts b/yarn-project/end-to-end/src/e2e_nested_contract.test.ts index 0319f94fec5..aefb5152e1c 100644 --- a/yarn-project/end-to-end/src/e2e_nested_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_nested_contract.test.ts @@ -3,18 +3,18 @@ import { toBigIntBE } from '@aztec/foundation/bigint-buffer'; import { DebugLogger } from '@aztec/foundation/log'; import { toBigInt } from '@aztec/foundation/serialize'; import { ChildContract, ImportTestContract, ParentContract, TestContract } from '@aztec/noir-contracts/types'; -import { AztecRPC, L2BlockL2Logs } from '@aztec/types'; +import { L2BlockL2Logs, PXE } from '@aztec/types'; import { setup } from './fixtures/utils.js'; describe('e2e_nested_contract', () => { - let aztecRpcServer: AztecRPC; + let pxe: PXE; let wallet: Wallet; let logger: DebugLogger; let teardown: () => Promise; beforeEach(async () => { - ({ teardown, aztecRpcServer, wallet, logger } = await setup()); + ({ teardown, pxe, wallet, logger } = await setup()); }, 100_000); afterEach(() => teardown()); @@ -29,7 +29,7 @@ describe('e2e_nested_contract', () => { }, 100_000); const getChildStoredValue = (child: { address: AztecAddress }) => - aztecRpcServer.getPublicStorageAt(child.address, new Fr(1)).then(x => toBigInt(x!)); + pxe.getPublicStorageAt(child.address, new Fr(1)).then(x => toBigInt(x!)); it('performs nested calls', async () => { await parentContract.methods diff --git a/yarn-project/end-to-end/src/e2e_non_contract_account.test.ts b/yarn-project/end-to-end/src/e2e_non_contract_account.test.ts index 4afce0ef322..6f4da87a779 100644 --- a/yarn-project/end-to-end/src/e2e_non_contract_account.test.ts +++ b/yarn-project/end-to-end/src/e2e_non_contract_account.test.ts @@ -2,13 +2,13 @@ import { AztecNodeService } from '@aztec/aztec-node'; import { AztecAddress, SignerlessWallet, Wallet } from '@aztec/aztec.js'; import { DebugLogger } from '@aztec/foundation/log'; import { PokeableTokenContract } from '@aztec/noir-contracts/types'; -import { AztecRPC, CompleteAddress, TxStatus } from '@aztec/types'; +import { CompleteAddress, PXE, TxStatus } from '@aztec/types'; import { expectsNumOfEncryptedLogsInTheLastBlockToBe, setup } from './fixtures/utils.js'; describe('e2e_non_contract_account', () => { let aztecNode: AztecNodeService | undefined; - let aztecRpcServer: AztecRPC; + let pxe: PXE; let wallet: Wallet; let sender: AztecAddress; let recipient: AztecAddress; @@ -23,13 +23,13 @@ describe('e2e_non_contract_account', () => { beforeEach(async () => { let accounts: CompleteAddress[]; - ({ teardown, aztecNode, aztecRpcServer, accounts, wallet, logger } = await setup(2)); + ({ teardown, aztecNode, pxe, accounts, wallet, logger } = await setup(2)); sender = accounts[0].address; recipient = accounts[1].address; - pokerWallet = new SignerlessWallet(aztecRpcServer); + pokerWallet = new SignerlessWallet(pxe); logger(`Deploying L2 contract...`); - const tx = PokeableTokenContract.deploy(aztecRpcServer, initialBalance, sender, recipient).send(); + const tx = PokeableTokenContract.deploy(pxe, initialBalance, sender, recipient).send(); await tx.isMined({ interval: 0.1 }); const receipt = await tx.getReceipt(); expect(receipt.status).toEqual(TxStatus.MINED); diff --git a/yarn-project/end-to-end/src/e2e_ordering.test.ts b/yarn-project/end-to-end/src/e2e_ordering.test.ts index 046cb25da5d..7a9dc9490ea 100644 --- a/yarn-project/end-to-end/src/e2e_ordering.test.ts +++ b/yarn-project/end-to-end/src/e2e_ordering.test.ts @@ -4,19 +4,19 @@ import { Fr, FunctionSelector } from '@aztec/circuits.js'; import { toBigIntBE } from '@aztec/foundation/bigint-buffer'; import { toBigInt } from '@aztec/foundation/serialize'; import { ChildContract, ParentContract } from '@aztec/noir-contracts/types'; -import { AztecRPC, L2BlockL2Logs, TxStatus } from '@aztec/types'; +import { L2BlockL2Logs, PXE, TxStatus } from '@aztec/types'; import { setup } from './fixtures/utils.js'; // See https://github.com/AztecProtocol/aztec-packages/issues/1601 describe('e2e_ordering', () => { - let aztecRpcServer: AztecRPC; + let pxe: PXE; let wallet: Wallet; let teardown: () => Promise; const expectLogsFromLastBlockToBe = async (logMessages: bigint[]) => { - const l2BlockNum = await aztecRpcServer.getBlockNumber(); - const unencryptedLogs = await aztecRpcServer.getUnencryptedLogs(l2BlockNum, 1); + const l2BlockNum = await pxe.getBlockNumber(); + const unencryptedLogs = await pxe.getUnencryptedLogs(l2BlockNum, 1); const unrolledLogs = L2BlockL2Logs.unrollLogs(unencryptedLogs); const bigintLogs = unrolledLogs.map((log: Buffer) => toBigIntBE(log)); @@ -24,7 +24,7 @@ describe('e2e_ordering', () => { }; beforeEach(async () => { - ({ teardown, aztecRpcServer, wallet } = await setup()); + ({ teardown, pxe, wallet } = await setup()); }, 100_000); afterEach(() => teardown()); @@ -72,7 +72,7 @@ describe('e2e_ordering', () => { await expectLogsFromLastBlockToBe(expectedOrder); // The final value of the child is the last one set - const value = await aztecRpcServer.getPublicStorageAt(child.address, new Fr(1)).then(x => toBigInt(x!)); + const value = await pxe.getPublicStorageAt(child.address, new Fr(1)).then(x => toBigInt(x!)); expect(value).toEqual(expectedOrder[1]); // final state should match last value set }, ); @@ -96,7 +96,7 @@ describe('e2e_ordering', () => { const receipt = await tx.wait(); expect(receipt.status).toBe(TxStatus.MINED); - const value = await aztecRpcServer.getPublicStorageAt(child.address, new Fr(1)).then(x => toBigInt(x!)); + const value = await pxe.getPublicStorageAt(child.address, new Fr(1)).then(x => toBigInt(x!)); expect(value).toEqual(expectedOrder[1]); // final state should match last value set }, ); diff --git a/yarn-project/end-to-end/src/e2e_p2p_network.test.ts b/yarn-project/end-to-end/src/e2e_p2p_network.test.ts index 53a285646b7..1ad20b9f413 100644 --- a/yarn-project/end-to-end/src/e2e_p2p_network.test.ts +++ b/yarn-project/end-to-end/src/e2e_p2p_network.test.ts @@ -5,7 +5,7 @@ import { Grumpkin } from '@aztec/circuits.js/barretenberg'; import { DebugLogger } from '@aztec/foundation/log'; import { TestContractAbi } from '@aztec/noir-contracts/artifacts'; import { BootstrapNode, P2PConfig, createLibP2PPeerId } from '@aztec/p2p'; -import { AztecRPCServer, ConstantKeyPair, createAztecRPCServer, getConfigEnvVars as getRpcConfig } from '@aztec/pxe'; +import { ConstantKeyPair, PXEService, createPXEService, getPXEServiceConfig as getRpcConfig } from '@aztec/pxe'; import { TxStatus } from '@aztec/types'; import { setup } from './fixtures/utils.js'; @@ -17,7 +17,7 @@ const BOOT_NODE_TCP_PORT = 40400; interface NodeContext { node: AztecNodeService; - rpcServer: AztecRPCServer; + pxeService: PXEService; txs: SentTx[]; account: AztecAddress; } @@ -45,7 +45,7 @@ describe('e2e_p2p_network', () => { const contexts: NodeContext[] = []; for (let i = 0; i < NUM_NODES; i++) { const node = await createNode(i + 1 + BOOT_NODE_TCP_PORT, bootstrapNodeAddress); - const context = await createAztecRpcServerAndSubmitTransactions(node, NUM_TXS_PER_NODE); + const context = await createPXEServiceAndSubmitTransactions(node, NUM_TXS_PER_NODE); contexts.push(context); } @@ -58,15 +58,15 @@ describe('e2e_p2p_network', () => { expect(isMined).toBe(true); expect(receiptAfterMined.status).toBe(TxStatus.MINED); const contractAddress = receiptAfterMined.contractAddress!; - expect(await isContractDeployed(context.rpcServer, contractAddress)).toBeTruthy(); - expect(await isContractDeployed(context.rpcServer, AztecAddress.random())).toBeFalsy(); + expect(await isContractDeployed(context.pxeService, contractAddress)).toBeTruthy(); + expect(await isContractDeployed(context.pxeService, AztecAddress.random())).toBeFalsy(); } } // shutdown all nodes. for (const context of contexts) { await context.node.stop(); - await context.rpcServer.stop(); + await context.pxeService.stop(); } await bootstrapNode.stop(); }, 80_000); @@ -112,18 +112,13 @@ describe('e2e_p2p_network', () => { return await AztecNodeService.createAndSync(newConfig); }; - // submits a set of transactions to the provided aztec rpc server - const submitTxsTo = async ( - aztecRpcServer: AztecRPCServer, - account: AztecAddress, - numTxs: number, - publicKey: PublicKey, - ) => { + // submits a set of transactions to the provided Private Execution Environment (PXE) + const submitTxsTo = async (pxe: PXEService, account: AztecAddress, numTxs: number, publicKey: PublicKey) => { const txs: SentTx[] = []; for (let i = 0; i < numTxs; i++) { const salt = Fr.random(); const origin = (await getContractDeploymentInfo(TestContractAbi, [], salt, publicKey)).completeAddress.address; - const deployer = new ContractDeployer(TestContractAbi, aztecRpcServer, publicKey); + const deployer = new ContractDeployer(TestContractAbi, pxe, publicKey); const tx = deployer.deploy().send({ contractAddressSalt: salt }); logger(`Tx sent with hash ${await tx.getTxHash()}`); const receipt = await tx.getReceipt(); @@ -139,26 +134,26 @@ describe('e2e_p2p_network', () => { return txs; }; - // creates an instance of the aztec rpc server and submit a given number of transactions to it. - const createAztecRpcServerAndSubmitTransactions = async ( + // creates an instance of the PXE and submit a given number of transactions to it. + const createPXEServiceAndSubmitTransactions = async ( node: AztecNodeService, numTxs: number, ): Promise => { const rpcConfig = getRpcConfig(); - const aztecRpcServer = await createAztecRPCServer(node, rpcConfig, {}, true); + const pxeService = await createPXEService(node, rpcConfig, {}, true); const keyPair = ConstantKeyPair.random(await Grumpkin.new()); const completeAddress = await CompleteAddress.fromPrivateKeyAndPartialAddress( await keyPair.getPrivateKey(), Fr.random(), ); - await aztecRpcServer.registerAccount(await keyPair.getPrivateKey(), completeAddress.partialAddress); + await pxeService.registerAccount(await keyPair.getPrivateKey(), completeAddress.partialAddress); - const txs = await submitTxsTo(aztecRpcServer, completeAddress.address, numTxs, completeAddress.publicKey); + const txs = await submitTxsTo(pxeService, completeAddress.address, numTxs, completeAddress.publicKey); return { txs, account: completeAddress.address, - rpcServer: aztecRpcServer, + pxeService, node, }; }; diff --git a/yarn-project/end-to-end/src/e2e_public_cross_chain_messaging.test.ts b/yarn-project/end-to-end/src/e2e_public_cross_chain_messaging.test.ts index 95f0273f9ce..88980573b2c 100644 --- a/yarn-project/end-to-end/src/e2e_public_cross_chain_messaging.test.ts +++ b/yarn-project/end-to-end/src/e2e_public_cross_chain_messaging.test.ts @@ -25,7 +25,7 @@ describe('e2e_public_cross_chain_messaging', () => { beforeEach(async () => { const { aztecNode: aztecNode_, - aztecRpcServer: aztecRpcServer_, + pxe, deployL1ContractsValues, accounts, wallets, @@ -35,7 +35,7 @@ describe('e2e_public_cross_chain_messaging', () => { } = await setup(2); crossChainTestHarness = await CrossChainTestHarness.new( aztecNode_, - aztecRpcServer_, + pxe, deployL1ContractsValues, accounts, wallets[0], diff --git a/yarn-project/end-to-end/src/e2e_public_to_private_messaging.test.ts b/yarn-project/end-to-end/src/e2e_public_to_private_messaging.test.ts index 60a55068f1c..3514744c0a7 100644 --- a/yarn-project/end-to-end/src/e2e_public_to_private_messaging.test.ts +++ b/yarn-project/end-to-end/src/e2e_public_to_private_messaging.test.ts @@ -19,8 +19,8 @@ describe('e2e_public_to_private_messaging', () => { beforeEach(async () => { const { - aztecNode: aztecNode_, - aztecRpcServer: aztecRpcServer_, + aztecNode, + pxe, deployL1ContractsValues, accounts, wallet, @@ -29,8 +29,8 @@ describe('e2e_public_to_private_messaging', () => { teardown: teardown_, } = await setup(2); crossChainTestHarness = await CrossChainTestHarness.new( - aztecNode_, - aztecRpcServer_, + aztecNode, + pxe, deployL1ContractsValues, accounts, wallet, diff --git a/yarn-project/end-to-end/src/e2e_public_token_contract.test.ts b/yarn-project/end-to-end/src/e2e_public_token_contract.test.ts index fb2822c1f1e..32b85181195 100644 --- a/yarn-project/end-to-end/src/e2e_public_token_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_public_token_contract.test.ts @@ -1,14 +1,14 @@ import { AztecAddress, Wallet } from '@aztec/aztec.js'; import { DebugLogger } from '@aztec/foundation/log'; import { PublicTokenContract } from '@aztec/noir-contracts/types'; -import { AztecRPC, CompleteAddress, TxStatus } from '@aztec/types'; +import { CompleteAddress, PXE, TxStatus } from '@aztec/types'; import times from 'lodash.times'; import { expectUnencryptedLogsFromLastBlockToBe, setup } from './fixtures/utils.js'; describe('e2e_public_token_contract', () => { - let aztecRpcServer: AztecRPC; + let pxe: PXE; let wallet: Wallet; let logger: DebugLogger; let recipient: AztecAddress; @@ -26,7 +26,7 @@ describe('e2e_public_token_contract', () => { beforeEach(async () => { let accounts: CompleteAddress[]; - ({ teardown, aztecRpcServer, accounts, wallet, logger } = await setup()); + ({ teardown, pxe, accounts, wallet, logger } = await setup()); recipient = accounts[0].address; }, 100_000); @@ -52,7 +52,7 @@ describe('e2e_public_token_contract', () => { const balance = await contract.methods.publicBalanceOf(recipient.toField()).view({ from: recipient }); expect(balance).toBe(mintAmount); - await expectUnencryptedLogsFromLastBlockToBe(aztecRpcServer, ['Coins minted']); + await expectUnencryptedLogsFromLastBlockToBe(pxe, ['Coins minted']); }, 45_000); // Regression for https://github.com/AztecProtocol/aztec-packages/issues/640 @@ -75,6 +75,6 @@ describe('e2e_public_token_contract', () => { const balance = await contract.methods.publicBalanceOf(recipient.toField()).view({ from: recipient }); expect(balance).toBe(mintAmount * 3n); - await expectUnencryptedLogsFromLastBlockToBe(aztecRpcServer, ['Coins minted', 'Coins minted', 'Coins minted']); + await expectUnencryptedLogsFromLastBlockToBe(pxe, ['Coins minted', 'Coins minted', 'Coins minted']); }, 60_000); }); diff --git a/yarn-project/end-to-end/src/e2e_sandbox_example.test.ts b/yarn-project/end-to-end/src/e2e_sandbox_example.test.ts index 84f72c805ca..d08674bb55c 100644 --- a/yarn-project/end-to-end/src/e2e_sandbox_example.test.ts +++ b/yarn-project/end-to-end/src/e2e_sandbox_example.test.ts @@ -1,10 +1,10 @@ // docs:start:imports import { - AztecRPC, Fr, + PXE, computeMessageSecretHash, - createAztecRpcClient, createDebugLogger, + createPXEClient, getSandboxAccountsWallets, getSchnorrAccount, waitForSandbox, @@ -21,12 +21,12 @@ describe('e2e_sandbox_example', () => { ////////////// CREATE THE CLIENT INTERFACE AND CONTACT THE SANDBOX ////////////// const logger = createDebugLogger('token'); - // We create AztecRPC client connected to the sandbox URL - const aztecRpc = createAztecRpcClient(SANDBOX_URL); + // We create PXE client connected to the sandbox URL + const pxe = createPXEClient(SANDBOX_URL); // Wait for sandbox to be ready - await waitForSandbox(aztecRpc); + await waitForSandbox(pxe); - const nodeInfo = await aztecRpc.getNodeInfo(); + const nodeInfo = await pxe.getNodeInfo(); logger('Aztec Sandbox Info ', nodeInfo); // docs:end:setup @@ -41,7 +41,7 @@ describe('e2e_sandbox_example', () => { // docs:start:load_accounts ////////////// LOAD SOME ACCOUNTS FROM THE SANDBOX ////////////// // The sandbox comes with a set of created accounts. Load them - const accounts = await getSandboxAccountsWallets(aztecRpc); + const accounts = await getSandboxAccountsWallets(pxe); const alice = accounts[0].getAddress(); const bob = accounts[1].getAddress(); logger(`Loaded alice's account at ${alice.toShortString()}`); @@ -55,7 +55,7 @@ describe('e2e_sandbox_example', () => { const initialSupply = 1_000_000n; logger(`Deploying token contract minting an initial ${initialSupply} tokens to Alice...`); - const contract = await TokenContract.deploy(aztecRpc).send().deployed(); + const contract = await TokenContract.deploy(pxe).send().deployed(); // Create the contract abstraction and link to Alice's wallet for future signing const tokenContractAlice = await TokenContract.at(contract.address, accounts[0]); @@ -73,8 +73,8 @@ describe('e2e_sandbox_example', () => { await tokenContractAlice.methods.redeem_shield(alice, initialSupply, secret).send().wait(); // docs:end:Deployment - // ensure that token contract is registered in the rpc - expect(await aztecRpc.getContracts()).toEqual(expect.arrayContaining([contract.address])); + // ensure that token contract is registered in PXE + expect(await pxe.getContracts()).toEqual(expect.arrayContaining([contract.address])); // docs:start:Balance @@ -137,21 +137,21 @@ describe('e2e_sandbox_example', () => { it('can create accounts on the sandbox', async () => { const logger = createDebugLogger('token'); - // We create AztecRPC client connected to the sandbox URL - const aztecRpc = createAztecRpcClient(SANDBOX_URL); + // We create PXE client connected to the sandbox URL + const pxe = createPXEClient(SANDBOX_URL); // Wait for sandbox to be ready - await waitForSandbox(aztecRpc); + await waitForSandbox(pxe); // docs:start:create_accounts ////////////// CREATE SOME ACCOUNTS WITH SCHNORR SIGNERS ////////////// // Creates new accounts using an account contract that verifies schnorr signatures // Returns once the deployment transactions have settled - const createSchnorrAccounts = async (numAccounts: number, aztecRpc: AztecRPC) => { + const createSchnorrAccounts = async (numAccounts: number, pxe: PXE) => { const accountManagers = Array(numAccounts) .fill(0) .map(() => getSchnorrAccount( - aztecRpc, + pxe, GrumpkinScalar.random(), // encryption private key GrumpkinScalar.random(), // signing private key ), @@ -166,14 +166,14 @@ describe('e2e_sandbox_example', () => { // Create 2 accounts and wallets to go with each logger(`Creating accounts using schnorr signers...`); - const accounts = await createSchnorrAccounts(2, aztecRpc); + const accounts = await createSchnorrAccounts(2, pxe); ////////////// VERIFY THE ACCOUNTS WERE CREATED SUCCESSFULLY ////////////// const [alice, bob] = (await Promise.all(accounts.map(x => x.getCompleteAddress()))).map(x => x.address); // Verify that the accounts were deployed - const registeredAccounts = (await aztecRpc.getRegisteredAccounts()).map(x => x.address); + const registeredAccounts = (await pxe.getRegisteredAccounts()).map(x => x.address); for (const [account, name] of [ [alice, 'Alice'], [bob, 'Bob'], diff --git a/yarn-project/end-to-end/src/e2e_token_contract.test.ts b/yarn-project/end-to-end/src/e2e_token_contract.test.ts index 53536987de8..578c0a3e291 100644 --- a/yarn-project/end-to-end/src/e2e_token_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_token_contract.test.ts @@ -437,7 +437,7 @@ describe('e2e_token_contract', () => { // We need to compute the message we want to sign and add it to the wallet as approved const messageHash = await transferMessageHash(accounts[1], accounts[0], accounts[1], amount, nonce); - // Both wallets are connected to same node and rpc so we could just insert directly using + // Both wallets are connected to same node and PXE so we could just insert directly using // await wallet.signAndAddAuthWitness(messageHash, ); // But doing it in two actions to show the flow. const witness = await wallets[0].createAuthWitness(messageHash); @@ -491,7 +491,7 @@ describe('e2e_token_contract', () => { // We need to compute the message we want to sign and add it to the wallet as approved const messageHash = await transferMessageHash(accounts[1], accounts[0], accounts[1], amount, nonce); - // Both wallets are connected to same node and rpc so we could just insert directly using + // Both wallets are connected to same node and PXE so we could just insert directly using // await wallet.signAndAddAuthWitness(messageHash, ); // But doing it in two actions to show the flow. const witness = await wallets[0].createAuthWitness(messageHash); @@ -772,7 +772,7 @@ describe('e2e_token_contract', () => { // We need to compute the message we want to sign and add it to the wallet as approved const messageHash = await unshieldMessageHash(accounts[1], accounts[0], accounts[1], amount, nonce); - // Both wallets are connected to same node and rpc so we could just insert directly using + // Both wallets are connected to same node and PXE so we could just insert directly using // await wallet.signAndAddAuthWitness(messageHash, ); // But doing it in two actions to show the flow. const witness = await wallets[0].createAuthWitness(messageHash); @@ -826,7 +826,7 @@ describe('e2e_token_contract', () => { // We need to compute the message we want to sign and add it to the wallet as approved const messageHash = await unshieldMessageHash(accounts[1], accounts[0], accounts[1], amount, nonce); - // Both wallets are connected to same node and rpc so we could just insert directly using + // Both wallets are connected to same node and PXE so we could just insert directly using // await wallet.signAndAddAuthWitness(messageHash, ); // But doing it in two actions to show the flow. const witness = await wallets[0].createAuthWitness(messageHash); @@ -850,7 +850,7 @@ describe('e2e_token_contract', () => { const messageHash = await unshieldMessageHash(accounts[1], accounts[0], accounts[1], amount, nonce); const expectedMessageHash = await unshieldMessageHash(accounts[2], accounts[0], accounts[1], amount, nonce); - // Both wallets are connected to same node and rpc so we could just insert directly using + // Both wallets are connected to same node and PXE so we could just insert directly using // await wallet.signAndAddAuthWitness(messageHash, ); // But doing it in two actions to show the flow. const witness = await wallets[0].createAuthWitness(messageHash); @@ -1005,7 +1005,7 @@ describe('e2e_token_contract', () => { // We need to compute the message we want to sign and add it to the wallet as approved const messageHash = await burnMessageHash(accounts[1], accounts[0], amount, nonce); - // Both wallets are connected to same node and rpc so we could just insert directly using + // Both wallets are connected to same node and PXE so we could just insert directly using // await wallet.signAndAddAuthWitness(messageHash, ); // But doing it in two actions to show the flow. const witness = await wallets[0].createAuthWitness(messageHash); @@ -1051,7 +1051,7 @@ describe('e2e_token_contract', () => { // We need to compute the message we want to sign and add it to the wallet as approved const messageHash = await burnMessageHash(accounts[1], accounts[0], amount, nonce); - // Both wallets are connected to same node and rpc so we could just insert directly using + // Both wallets are connected to same node and PXE so we could just insert directly using // await wallet.signAndAddAuthWitness(messageHash, ); // But doing it in two actions to show the flow. const witness = await wallets[0].createAuthWitness(messageHash); @@ -1105,7 +1105,7 @@ describe('e2e_token_contract', () => { const messageHash = await burnMessageHash(accounts[1], accounts[0], amount, nonce); const expectedMessageHash = await burnMessageHash(accounts[2], accounts[0], amount, nonce); - // Both wallets are connected to same node and rpc so we could just insert directly using + // Both wallets are connected to same node and PXE so we could just insert directly using // await wallet.signAndAddAuthWitness(messageHash, { origin: accounts[0].address }); // But doing it in two actions to show the flow. const witness = await wallets[0].createAuthWitness(messageHash); diff --git a/yarn-project/end-to-end/src/fixtures/cross_chain_test_harness.ts b/yarn-project/end-to-end/src/fixtures/cross_chain_test_harness.ts index de813f13c5f..339fffc0380 100644 --- a/yarn-project/end-to-end/src/fixtures/cross_chain_test_harness.ts +++ b/yarn-project/end-to-end/src/fixtures/cross_chain_test_harness.ts @@ -7,8 +7,8 @@ import { sha256ToField } from '@aztec/foundation/crypto'; import { DebugLogger } from '@aztec/foundation/log'; import { OutboxAbi } from '@aztec/l1-artifacts'; import { TokenBridgeContract, TokenContract } from '@aztec/noir-contracts/types'; -import { AztecRPCServer } from '@aztec/pxe'; -import { AztecRPC, TxStatus } from '@aztec/types'; +import { PXEService } from '@aztec/pxe'; +import { PXE, TxStatus } from '@aztec/types'; import { Chain, HttpTransport, PublicClient, getContract } from 'viem'; @@ -21,7 +21,7 @@ import { deployAndInitializeStandardizedTokenAndBridgeContracts } from './utils. export class CrossChainTestHarness { static async new( aztecNode: AztecNodeService | undefined, - aztecRpcServer: AztecRPC, + pxeService: PXE, deployL1ContractsValues: DeployL1Contracts, accounts: CompleteAddress[], wallet: Wallet, @@ -69,7 +69,7 @@ export class CrossChainTestHarness { return new CrossChainTestHarness( aztecNode, - aztecRpcServer, + pxeService, cheatCodes, accounts, logger, @@ -90,8 +90,8 @@ export class CrossChainTestHarness { constructor( /** AztecNode. */ public aztecNode: AztecNodeService | undefined, - /** AztecRpcServer. */ - public aztecRpcServer: AztecRPC, + /** Private Execution Environment (PXE). */ + public pxeService: PXE, /** CheatCodes. */ public cc: CheatCodes, /** Accounts. */ @@ -271,7 +271,7 @@ export class CrossChainTestHarness { async checkEntryIsNotInOutbox(withdrawAmount: bigint, callerOnL1: EthAddress = EthAddress.ZERO): Promise { this.logger('Ensure that the entry is not in outbox yet'); - const contractData = await this.aztecRpcServer.getContractData(this.l2Bridge.address); + const contractData = await this.pxeService.getContractData(this.l2Bridge.address); // 0xb460af94, selector for "withdraw(uint256,address,address)" const content = sha256ToField( Buffer.concat([ @@ -335,8 +335,8 @@ export class CrossChainTestHarness { async stop() { await this.aztecNode?.stop(); - if (this.aztecRpcServer instanceof AztecRPCServer) { - await this.aztecRpcServer?.stop(); + if (this.pxeService instanceof PXEService) { + await this.pxeService?.stop(); } } } diff --git a/yarn-project/end-to-end/src/fixtures/utils.ts b/yarn-project/end-to-end/src/fixtures/utils.ts index 34725dfc973..3ed19980085 100644 --- a/yarn-project/end-to-end/src/fixtures/utils.ts +++ b/yarn-project/end-to-end/src/fixtures/utils.ts @@ -8,7 +8,7 @@ import { EthCheatCodes, Wallet, createAccounts, - createAztecRpcClient as createJsonRpcClient, + createPXEClient as createJsonRpcClient, getSandboxAccountsWallets, } from '@aztec/aztec.js'; import { CircuitsWasm, GeneratorIndex } from '@aztec/circuits.js'; @@ -41,8 +41,8 @@ import { TokenPortalBytecode, } from '@aztec/l1-artifacts'; import { NonNativeTokenContract, TokenBridgeContract, TokenContract } from '@aztec/noir-contracts/types'; -import { AztecRPCServer, createAztecRPCServer, getConfigEnvVars as getRpcConfigEnvVars } from '@aztec/pxe'; -import { AztecRPC, L2BlockL2Logs, LogType, TxStatus } from '@aztec/types'; +import { PXEService, createPXEService, getPXEServiceConfig } from '@aztec/pxe'; +import { L2BlockL2Logs, LogType, PXE, TxStatus } from '@aztec/types'; import { Account, @@ -63,14 +63,14 @@ import { MNEMONIC, localAnvil } from './fixtures.js'; const { SANDBOX_URL = '' } = process.env; -export const waitForRPCServer = async (rpcServer: AztecRPC, logger: DebugLogger) => { +export const waitForPXE = async (pxe: PXE, logger: DebugLogger) => { await retryUntil(async () => { try { - logger('Attempting to contact RPC Server...'); - await rpcServer.getNodeInfo(); + logger('Attempting to contact PXE...'); + await pxe.getNodeInfo(); return true; } catch (error) { - logger('Failed to contact RPC Server!'); + logger('Failed to contact PXE!'); } return undefined; }, 'RPC Get Node Info'); @@ -126,26 +126,26 @@ export const setupL1Contracts = async ( }; /** - * Sets up Aztec RPC Server. - * @param numberOfAccounts - The number of new accounts to be created once the RPC server is initiated. + * Sets up Private Execution Environment (PXE). + * @param numberOfAccounts - The number of new accounts to be created once the PXE is initiated. * @param aztecNode - The instance of an aztec node, if one is required * @param firstPrivKey - The private key of the first account to be created. * @param logger - The logger to be used. - * @param useLogSuffix - Whether to add a randomly generated suffix to the RPC server debug logs. - * @returns Aztec RPC server, accounts, wallets and logger. + * @param useLogSuffix - Whether to add a randomly generated suffix to the PXE debug logs. + * @returns Private Execution Environment (PXE), accounts, wallets and logger. */ -export async function setupAztecRPCServer( +export async function setupPXEService( numberOfAccounts: number, aztecNode: AztecNodeService, logger = getLogger(), useLogSuffix = false, ): Promise<{ /** - * The Aztec RPC instance. + * The PXE instance. */ - aztecRpcServer: AztecRPC; + pxe: PXE; /** - * The accounts created by the RPC server. + * The accounts created by the PXE. */ accounts: CompleteAddress[]; /** @@ -157,14 +157,14 @@ export async function setupAztecRPCServer( */ logger: DebugLogger; }> { - const rpcConfig = getRpcConfigEnvVars(); - const rpc = await createAztecRPCServer(aztecNode, rpcConfig, {}, useLogSuffix); + const pxeServiceConfig = getPXEServiceConfig(); + const pxe = await createPXEService(aztecNode, pxeServiceConfig, {}, useLogSuffix); - const wallets = await createAccounts(rpc, numberOfAccounts); + const wallets = await createAccounts(pxe, numberOfAccounts); return { - aztecRpcServer: rpc!, - accounts: await rpc!.getRegisteredAccounts(), + pxe, + accounts: await pxe.getRegisteredAccounts(), wallets, logger, }; @@ -181,11 +181,11 @@ async function setupWithSandbox(account: Account, config: AztecNodeConfig, logge // we are setting up against the sandbox, l1 contracts are already deployed logger(`Creating JSON RPC client to remote host ${SANDBOX_URL}`); const jsonClient = createJsonRpcClient(SANDBOX_URL); - await waitForRPCServer(jsonClient, logger); - logger('JSON RPC client connected to RPC Server'); + await waitForPXE(jsonClient, logger); + logger('JSON RPC client connected to PXE'); logger(`Retrieving contract addresses from ${SANDBOX_URL}`); const l1Contracts = (await jsonClient.getNodeInfo()).l1ContractAddresses; - logger('RPC server created, constructing wallets from initial sandbox accounts...'); + logger('PXE created, constructing wallets from initial sandbox accounts...'); const wallets = await getSandboxAccountsWallets(jsonClient); const walletClient = createWalletClient({ @@ -206,7 +206,7 @@ async function setupWithSandbox(account: Account, config: AztecNodeConfig, logge const teardown = () => Promise.resolve(); return { aztecNode: undefined, - aztecRpcServer: jsonClient, + pxe: jsonClient, deployL1ContractsValues, accounts: await jsonClient!.getRegisteredAccounts(), config, @@ -220,7 +220,7 @@ async function setupWithSandbox(account: Account, config: AztecNodeConfig, logge /** * Sets up the environment for the end-to-end tests. - * @param numberOfAccounts - The number of new accounts to be created once the RPC server is initiated. + * @param numberOfAccounts - The number of new accounts to be created once the PXE is initiated. */ export async function setup( numberOfAccounts = 1, @@ -231,15 +231,15 @@ export async function setup( */ aztecNode: AztecNodeService | undefined; /** - * The Aztec RPC server. + * The Private Execution Environment (PXE). */ - aztecRpcServer: AztecRPC; + pxe: PXE; /** * Return values from deployL1Contracts function. */ deployL1ContractsValues: DeployL1Contracts; /** - * The accounts created by the RPC server. + * The accounts created by the PXE. */ accounts: CompleteAddress[]; /** @@ -295,18 +295,18 @@ export async function setup( const aztecNode = await createAztecNode(config, logger); - const { aztecRpcServer, accounts, wallets } = await setupAztecRPCServer(numberOfAccounts, aztecNode!, logger); + const { pxe, accounts, wallets } = await setupPXEService(numberOfAccounts, aztecNode!, logger); - const cheatCodes = await CheatCodes.create(config.rpcUrl, aztecRpcServer!); + const cheatCodes = await CheatCodes.create(config.rpcUrl, pxe!); const teardown = async () => { await aztecNode?.stop(); - if (aztecRpcServer instanceof AztecRPCServer) await aztecRpcServer?.stop(); + if (pxe instanceof PXEService) await pxe?.stop(); }; return { aztecNode, - aztecRpcServer, + pxe, deployL1ContractsValues, accounts, config, @@ -455,7 +455,7 @@ export async function deployAndInitializeStandardizedTokenAndBridgeContracts( /** * Deploy L1 token and portal, initialize portal, deploy a non native l2 token contract and attach is to the portal. - * @param aztecRpcServer - the aztec rpc server instance + * @param wallet - Aztec wallet instance. * @param walletClient - A viem WalletClient. * @param publicClient - A viem PublicClient. * @param rollupRegistryAddress - address of rollup registry to pass to initialize the token portal @@ -532,7 +532,7 @@ export const expectsNumOfEncryptedLogsInTheLastBlockToBe = async ( numEncryptedLogs: number, ) => { if (!aztecNode) { - // An api for retrieving encrypted logs does not exist on the rpc server so we have to use the node + // An api for retrieving encrypted logs does not exist on the PXE Service so we have to use the node // This means we can't perform this check if there is no node return; } @@ -544,15 +544,15 @@ export const expectsNumOfEncryptedLogsInTheLastBlockToBe = async ( /** * Checks that the last block contains the given expected unencrypted log messages. - * @param rpc - The instance of AztecRPC for retrieving the logs. + * @param pxe - The instance of PXE for retrieving the logs. * @param logMessages - The set of expected log messages. */ -export const expectUnencryptedLogsFromLastBlockToBe = async (rpc: AztecRPC, logMessages: string[]) => { +export const expectUnencryptedLogsFromLastBlockToBe = async (pxe: PXE, logMessages: string[]) => { // docs:start:get_logs // Get the latest block number to retrieve logs from - const l2BlockNum = await rpc.getBlockNumber(); + const l2BlockNum = await pxe.getBlockNumber(); // Get the unencrypted logs from the last block - const unencryptedLogs = await rpc.getUnencryptedLogs(l2BlockNum, 1); + const unencryptedLogs = await pxe.getUnencryptedLogs(l2BlockNum, 1); // docs:end:get_logs const unrolledLogs = L2BlockL2Logs.unrollLogs(unencryptedLogs); const asciiLogs = unrolledLogs.map(log => log.toString('ascii')); diff --git a/yarn-project/end-to-end/src/guides/dapp_testing.test.ts b/yarn-project/end-to-end/src/guides/dapp_testing.test.ts index 161454e4afa..0c9aa989a23 100644 --- a/yarn-project/end-to-end/src/guides/dapp_testing.test.ts +++ b/yarn-project/end-to-end/src/guides/dapp_testing.test.ts @@ -1,13 +1,13 @@ import { createSandbox } from '@aztec/aztec-sandbox'; import { AccountWallet, - AztecRPC, CheatCodes, Fr, L2BlockL2Logs, + PXE, computeMessageSecretHash, createAccount, - createAztecRpcClient, + createPXEClient, getSandboxAccountsWallets, waitForSandbox, } from '@aztec/aztec.js'; @@ -19,7 +19,7 @@ const { SANDBOX_URL = 'http://localhost:8080', ETHEREUM_HOST = 'http://localhost describe('guides/dapp/testing', () => { describe('on in-proc sandbox', () => { describe('private token contract', () => { - let rpc: AztecRPC; + let pxe: PXE; let stop: () => Promise; let owner: AccountWallet; let recipient: AccountWallet; @@ -27,10 +27,10 @@ describe('guides/dapp/testing', () => { beforeAll(async () => { // docs:start:in-proc-sandbox - ({ rpcServer: rpc, stop } = await createSandbox()); + ({ pxe, stop } = await createSandbox()); // docs:end:in-proc-sandbox - owner = await createAccount(rpc); - recipient = await createAccount(rpc); + owner = await createAccount(pxe); + recipient = await createAccount(pxe); token = await TokenContract.deploy(owner).send().deployed(); await token.methods._initialize(owner.getAddress()).send().wait(); }, 60_000); @@ -52,21 +52,21 @@ describe('guides/dapp/testing', () => { describe('on local sandbox', () => { beforeAll(async () => { - const rpc = createAztecRpcClient(SANDBOX_URL); - await waitForSandbox(rpc); + const pxe = createPXEClient(SANDBOX_URL); + await waitForSandbox(pxe); }); // docs:start:sandbox-example describe('private token contract', () => { - let rpc: AztecRPC; + let pxe: PXE; let owner: AccountWallet; let recipient: AccountWallet; let token: TokenContract; beforeEach(async () => { - rpc = createAztecRpcClient(SANDBOX_URL); - owner = await createAccount(rpc); - recipient = await createAccount(rpc); + pxe = createPXEClient(SANDBOX_URL); + owner = await createAccount(pxe); + recipient = await createAccount(pxe); token = await TokenContract.deploy(owner).send().deployed(); await token.methods._initialize(owner.getAddress()).send().wait(); }, 30_000); @@ -83,15 +83,15 @@ describe('guides/dapp/testing', () => { // docs:end:sandbox-example describe('private token contract with initial accounts', () => { - let rpc: AztecRPC; + let pxe: PXE; let owner: AccountWallet; let recipient: AccountWallet; let token: TokenContract; beforeEach(async () => { // docs:start:use-existing-wallets - rpc = createAztecRpcClient(SANDBOX_URL); - [owner, recipient] = await getSandboxAccountsWallets(rpc); + pxe = createPXEClient(SANDBOX_URL); + [owner, recipient] = await getSandboxAccountsWallets(pxe); token = await TokenContract.deploy(owner).send().deployed(); await token.methods._initialize(owner.getAddress()).send().wait(); // docs:end:use-existing-wallets @@ -108,16 +108,16 @@ describe('guides/dapp/testing', () => { }); describe('cheats', () => { - let rpc: AztecRPC; + let pxe: PXE; let owner: AccountWallet; let testContract: TestContract; let cheats: CheatCodes; beforeAll(async () => { - rpc = createAztecRpcClient(SANDBOX_URL); - owner = await createAccount(rpc); + pxe = createPXEClient(SANDBOX_URL); + owner = await createAccount(pxe); testContract = await TestContract.deploy(owner).send().deployed(); - cheats = await CheatCodes.create(ETHEREUM_HOST, rpc); + cheats = await CheatCodes.create(ETHEREUM_HOST, pxe); }, 30_000); it('warps time to 1h into the future', async () => { @@ -130,7 +130,7 @@ describe('guides/dapp/testing', () => { }); describe('assertions', () => { - let rpc: AztecRPC; + let pxe: PXE; let owner: AccountWallet; let recipient: AccountWallet; let testContract: TestContract; @@ -139,9 +139,9 @@ describe('guides/dapp/testing', () => { let ownerSlot: Fr; beforeAll(async () => { - rpc = createAztecRpcClient(SANDBOX_URL); - owner = await createAccount(rpc); - recipient = await createAccount(rpc); + pxe = createPXEClient(SANDBOX_URL); + owner = await createAccount(pxe); + recipient = await createAccount(pxe); testContract = await TestContract.deploy(owner).send().deployed(); token = await TokenContract.deploy(owner).send().deployed(); await token.methods._initialize(owner.getAddress()).send().wait(); @@ -151,7 +151,7 @@ describe('guides/dapp/testing', () => { await token.methods.redeem_shield(owner.getAddress(), 100n, secret).send().wait(); // docs:start:calc-slot - cheats = await CheatCodes.create(ETHEREUM_HOST, rpc); + cheats = await CheatCodes.create(ETHEREUM_HOST, pxe); // The balances mapping is defined on storage slot 3 and is indexed by user address ownerSlot = cheats.aztec.computeSlotInMap(3n, owner.getAddress()); // docs:end:calc-slot @@ -159,7 +159,7 @@ describe('guides/dapp/testing', () => { it('checks private storage', async () => { // docs:start:private-storage - const notes = await rpc.getPrivateStorageAt(owner.getAddress(), token.address, ownerSlot); + const notes = await pxe.getPrivateStorageAt(owner.getAddress(), token.address, ownerSlot); const values = notes.map(note => note.items[0]); const balance = values.reduce((sum, current) => sum + current.toBigInt(), 0n); expect(balance).toEqual(100n); @@ -170,7 +170,7 @@ describe('guides/dapp/testing', () => { // docs:start:public-storage await token.methods.mint_public(owner.getAddress(), 100n).send().wait(); const ownerPublicBalanceSlot = cheats.aztec.computeSlotInMap(6n, owner.getAddress()); - const balance = await rpc.getPublicStorageAt(token.address, ownerPublicBalanceSlot); + const balance = await pxe.getPublicStorageAt(token.address, ownerPublicBalanceSlot); expect(toBigIntBE(balance!)).toEqual(100n); // docs:end:public-storage }); @@ -179,7 +179,7 @@ describe('guides/dapp/testing', () => { // docs:start:unencrypted-logs const value = Fr.fromString('ef'); // Only 1 bytes will make its way in there :( so no larger stuff const tx = await testContract.methods.emit_unencrypted(value).send().wait(); - const logs = await rpc.getUnencryptedLogs(tx.blockNumber!, 1); + const logs = await pxe.getUnencryptedLogs(tx.blockNumber!, 1); const log = L2BlockL2Logs.unrollLogs(logs)[0]; expect(Fr.fromBuffer(log)).toEqual(value); // docs:end:unencrypted-logs diff --git a/yarn-project/end-to-end/src/guides/up_quick_start.test.ts b/yarn-project/end-to-end/src/guides/up_quick_start.test.ts index d544381b256..855dbcaf4ff 100644 --- a/yarn-project/end-to-end/src/guides/up_quick_start.test.ts +++ b/yarn-project/end-to-end/src/guides/up_quick_start.test.ts @@ -7,7 +7,7 @@ describe('guides/up_quick_start', () => { it('works', async () => { await waitForSandbox(); execSync( - `DEBUG="aztec:*" AZTEC_RPC_HOST=\${SANDBOX_URL:-http://localhost:8080} PATH=$PATH:../node_modules/.bin ./src/guides/up_quick_start.sh`, + `DEBUG="aztec:*" PXE_HOST=\${SANDBOX_URL:-http://localhost:8080} PATH=$PATH:../node_modules/.bin ./src/guides/up_quick_start.sh`, { shell: '/bin/bash', stdio: 'pipe', diff --git a/yarn-project/end-to-end/src/guides/writing_an_account_contract.test.ts b/yarn-project/end-to-end/src/guides/writing_an_account_contract.test.ts index 8930f604eda..eb58f3f19a6 100644 --- a/yarn-project/end-to-end/src/guides/writing_an_account_contract.test.ts +++ b/yarn-project/end-to-end/src/guides/writing_an_account_contract.test.ts @@ -50,10 +50,10 @@ describe('guides/writing_an_account_contract', () => { afterEach(() => context.teardown()); it('works', async () => { - const { aztecRpcServer: rpc, logger } = context; + const { pxe, logger } = context; // docs:start:account-contract-deploy const encryptionPrivateKey = GrumpkinScalar.random(); - const account = new AccountManager(rpc, encryptionPrivateKey, new SchnorrHardcodedKeyAccountContract()); + const account = new AccountManager(pxe, encryptionPrivateKey, new SchnorrHardcodedKeyAccountContract()); const wallet = await account.waitDeploy(); const address = wallet.getCompleteAddress().address; // docs:end:account-contract-deploy @@ -79,7 +79,7 @@ describe('guides/writing_an_account_contract', () => { const walletAddress = wallet.getCompleteAddress(); const wrongKey = GrumpkinScalar.random(); const wrongAccountContract = new SchnorrHardcodedKeyAccountContract(wrongKey); - const wrongAccount = new AccountManager(rpc, encryptionPrivateKey, wrongAccountContract, walletAddress); + const wrongAccount = new AccountManager(pxe, encryptionPrivateKey, wrongAccountContract, walletAddress); const wrongWallet = await wrongAccount.getWallet(); const tokenWithWrongWallet = token.withWallet(wrongWallet); diff --git a/yarn-project/end-to-end/src/pxe_sandbox.test.ts b/yarn-project/end-to-end/src/pxe_sandbox.test.ts new file mode 100644 index 00000000000..cfdee86086e --- /dev/null +++ b/yarn-project/end-to-end/src/pxe_sandbox.test.ts @@ -0,0 +1,12 @@ +import { createPXEClient, waitForSandbox } from '@aztec/aztec.js'; +import { pxeTestSuite } from '@aztec/pxe'; + +const { SANDBOX_URL = 'http://localhost:8080' } = process.env; + +const setup = async () => { + const pxe = createPXEClient(SANDBOX_URL); + await waitForSandbox(pxe); + return pxe; +}; + +pxeTestSuite('pxe_sandbox', setup); diff --git a/yarn-project/end-to-end/src/sample-dapp/connect.mjs b/yarn-project/end-to-end/src/sample-dapp/connect.mjs index d66fbc3ba02..0785fb1ca3a 100644 --- a/yarn-project/end-to-end/src/sample-dapp/connect.mjs +++ b/yarn-project/end-to-end/src/sample-dapp/connect.mjs @@ -1,11 +1,11 @@ // docs:start:all -import { createAztecRpcClient } from '@aztec/aztec.js'; +import { createPXEClient } from '@aztec/aztec.js'; const { SANDBOX_URL = 'http://localhost:8080' } = process.env; async function main() { - const client = createAztecRpcClient(SANDBOX_URL); - const { chainId } = await client.getNodeInfo(); + const pxe = createPXEClient(SANDBOX_URL); + const { chainId } = await pxe.getNodeInfo(); console.log(`Connected to chain ${chainId}`); } diff --git a/yarn-project/end-to-end/src/sample-dapp/deploy.mjs b/yarn-project/end-to-end/src/sample-dapp/deploy.mjs index b620819eb33..7d9c655ac19 100644 --- a/yarn-project/end-to-end/src/sample-dapp/deploy.mjs +++ b/yarn-project/end-to-end/src/sample-dapp/deploy.mjs @@ -1,4 +1,4 @@ -import { Contract, ContractDeployer, createAztecRpcClient, getSandboxAccountsWallets } from '@aztec/aztec.js'; +import { Contract, ContractDeployer, createPXEClient, getSandboxAccountsWallets } from '@aztec/aztec.js'; import { TokenContractAbi } from '@aztec/noir-contracts/artifacts'; import { writeFileSync } from 'fs'; @@ -8,10 +8,10 @@ import { fileURLToPath } from 'url'; const { SANDBOX_URL = 'http://localhost:8080' } = process.env; async function main() { - const client = createAztecRpcClient(SANDBOX_URL); - const [owner] = await getSandboxAccountsWallets(client); + const pxe = createPXEClient(SANDBOX_URL); + const [owner] = await getSandboxAccountsWallets(pxe); - const token = await Contract.deploy(client, TokenContractAbi, []).send().deployed(); + const token = await Contract.deploy(pxe, TokenContractAbi, []).send().deployed(); await token.withWallet(owner).methods._initialize(owner.getAddress()).send().wait(); console.log(`Token deployed at ${token.address.toString()}`); diff --git a/yarn-project/end-to-end/src/sample-dapp/index.mjs b/yarn-project/end-to-end/src/sample-dapp/index.mjs index 17b6e9024eb..32d8e256692 100644 --- a/yarn-project/end-to-end/src/sample-dapp/index.mjs +++ b/yarn-project/end-to-end/src/sample-dapp/index.mjs @@ -2,7 +2,7 @@ import { Fr, L2BlockL2Logs, computeMessageSecretHash, - createAztecRpcClient, + createPXEClient, getSandboxAccountsWallets, } from '@aztec/aztec.js'; import { fileURLToPath } from '@aztec/foundation/url'; @@ -11,17 +11,17 @@ import { getToken } from './contracts.mjs'; const { SANDBOX_URL = 'http://localhost:8080' } = process.env; -async function showAccounts(client) { +async function showAccounts(pxe) { // docs:start:showAccounts - const accounts = await client.getRegisteredAccounts(); + const accounts = await pxe.getRegisteredAccounts(); console.log(`User accounts:\n${accounts.map(a => a.address).join('\n')}`); // docs:end:showAccounts } -async function showPrivateBalances(client) { +async function showPrivateBalances(pxe) { // docs:start:showPrivateBalances - const accounts = await client.getRegisteredAccounts(); - const token = await getToken(client); + const accounts = await pxe.getRegisteredAccounts(); + const token = await getToken(pxe); for (const account of accounts) { // highlight-next-line:showPrivateBalances @@ -31,11 +31,11 @@ async function showPrivateBalances(client) { // docs:end:showPrivateBalances } -async function mintPrivateFunds(client) { - const [owner] = await getSandboxAccountsWallets(client); +async function mintPrivateFunds(pxe) { + const [owner] = await getSandboxAccountsWallets(pxe); const token = await getToken(owner); - await showPrivateBalances(client); + await showPrivateBalances(pxe); const mintAmount = 20n; const secret = Fr.random(); @@ -43,29 +43,29 @@ async function mintPrivateFunds(client) { await token.methods.mint_private(mintAmount, secretHash).send().wait(); await token.methods.redeem_shield(owner.getAddress(), mintAmount, secret).send().wait(); - await showPrivateBalances(client); + await showPrivateBalances(pxe); } -async function transferPrivateFunds(client) { +async function transferPrivateFunds(pxe) { // docs:start:transferPrivateFunds - const [owner, recipient] = await getSandboxAccountsWallets(client); + const [owner, recipient] = await getSandboxAccountsWallets(pxe); const token = await getToken(owner); const tx = token.methods.transfer(owner.getAddress(), recipient.getAddress(), 1n, 0).send(); console.log(`Sent transfer transaction ${await tx.getTxHash()}`); - await showPrivateBalances(client); + await showPrivateBalances(pxe); console.log(`Awaiting transaction to be mined`); const receipt = await tx.wait(); console.log(`Transaction has been mined on block ${receipt.blockNumber}`); - await showPrivateBalances(client); + await showPrivateBalances(pxe); // docs:end:transferPrivateFunds } -async function showPublicBalances(client) { +async function showPublicBalances(pxe) { // docs:start:showPublicBalances - const accounts = await client.getRegisteredAccounts(); - const token = await getToken(client); + const accounts = await pxe.getRegisteredAccounts(); + const token = await getToken(pxe); for (const account of accounts) { // highlight-next-line:showPublicBalances @@ -75,41 +75,41 @@ async function showPublicBalances(client) { // docs:end:showPublicBalances } -async function mintPublicFunds(client) { +async function mintPublicFunds(pxe) { // docs:start:mintPublicFunds - const [owner] = await getSandboxAccountsWallets(client); + const [owner] = await getSandboxAccountsWallets(pxe); const token = await getToken(owner); const tx = token.methods.mint_public(owner.getAddress(), 100n).send(); console.log(`Sent mint transaction ${await tx.getTxHash()}`); - await showPublicBalances(client); + await showPublicBalances(pxe); console.log(`Awaiting transaction to be mined`); const receipt = await tx.wait(); console.log(`Transaction has been mined on block ${receipt.blockNumber}`); - await showPublicBalances(client); + await showPublicBalances(pxe); // docs:end:mintPublicFunds // docs:start:showLogs - const blockNumber = await client.getBlockNumber(); - const logs = await client.getUnencryptedLogs(blockNumber, 1); + const blockNumber = await pxe.getBlockNumber(); + const logs = await pxe.getUnencryptedLogs(blockNumber, 1); const textLogs = L2BlockL2Logs.unrollLogs(logs).map(log => log.toString('ascii')); for (const log of textLogs) console.log(`Log emitted: ${log}`); // docs:end:showLogs } async function main() { - const client = createAztecRpcClient(SANDBOX_URL); - const { chainId } = await client.getNodeInfo(); + const pxe = createPXEClient(SANDBOX_URL); + const { chainId } = await pxe.getNodeInfo(); console.log(`Connected to chain ${chainId}`); - await showAccounts(client); + await showAccounts(pxe); - await mintPrivateFunds(client); + await mintPrivateFunds(pxe); - await transferPrivateFunds(client); + await transferPrivateFunds(pxe); - await mintPublicFunds(client); + await mintPublicFunds(pxe); } // Execute main only if run directly diff --git a/yarn-project/end-to-end/src/sample-dapp/index.test.mjs b/yarn-project/end-to-end/src/sample-dapp/index.test.mjs index 1f695549787..0b52196b14d 100644 --- a/yarn-project/end-to-end/src/sample-dapp/index.test.mjs +++ b/yarn-project/end-to-end/src/sample-dapp/index.test.mjs @@ -4,11 +4,11 @@ import { TokenContractAbi } from '@aztec/noir-contracts/artifacts'; describe('token', () => { // docs:start:setup - let rpc, stop, owner, recipient, token; + let pxe, stop, owner, recipient, token; beforeAll(async () => { - ({ rpcServer: rpc, stop } = await createSandbox()); - owner = await createAccount(rpc); - recipient = await createAccount(rpc); + ({ pxe, stop } = await createSandbox()); + owner = await createAccount(pxe); + recipient = await createAccount(pxe); token = await Contract.deploy(owner, TokenContractAbi, []).send().deployed(); await token.methods._initialize(owner.getAddress()).send().wait(); diff --git a/yarn-project/end-to-end/src/uniswap_trade_on_l1_from_l2.test.ts b/yarn-project/end-to-end/src/uniswap_trade_on_l1_from_l2.test.ts index b1d220dceca..d3d30eee095 100644 --- a/yarn-project/end-to-end/src/uniswap_trade_on_l1_from_l2.test.ts +++ b/yarn-project/end-to-end/src/uniswap_trade_on_l1_from_l2.test.ts @@ -5,7 +5,7 @@ import { EthAddress } from '@aztec/foundation/eth-address'; import { DebugLogger } from '@aztec/foundation/log'; import { UniswapPortalAbi, UniswapPortalBytecode } from '@aztec/l1-artifacts'; import { UniswapContract } from '@aztec/noir-contracts/types'; -import { AztecRPC, CompleteAddress, TxStatus } from '@aztec/types'; +import { CompleteAddress, PXE, TxStatus } from '@aztec/types'; import { getContract, parseEther } from 'viem'; @@ -32,7 +32,7 @@ describe.skip('uniswap_trade_on_l1_from_l2', () => { const DAI_ADDRESS: EthAddress = EthAddress.fromString('0x6B175474E89094C44Da98b954EedeAC495271d0F'); let aztecNode: AztecNodeService | undefined; - let aztecRpcServer: AztecRPC; + let pxe: PXE; let wallet: Wallet; let accounts: CompleteAddress[]; let logger: DebugLogger; @@ -53,8 +53,10 @@ describe.skip('uniswap_trade_on_l1_from_l2', () => { beforeEach(async () => { let deployL1ContractsValues: DeployL1Contracts; - ({ teardown, aztecNode, aztecRpcServer, deployL1ContractsValues, accounts, logger, wallet, cheatCodes } = - await setup(2, dumpedState)); + ({ teardown, aztecNode, pxe, deployL1ContractsValues, accounts, logger, wallet, cheatCodes } = await setup( + 2, + dumpedState, + )); const walletClient = deployL1ContractsValues.walletClient; const publicClient = deployL1ContractsValues.publicClient; @@ -69,7 +71,7 @@ describe.skip('uniswap_trade_on_l1_from_l2', () => { logger('Deploying DAI Portal, initializing and deploying l2 contract...'); daiCrossChainHarness = await CrossChainTestHarness.new( aztecNode, - aztecRpcServer, + pxe, deployL1ContractsValues, accounts, wallet, @@ -82,7 +84,7 @@ describe.skip('uniswap_trade_on_l1_from_l2', () => { logger('Deploying WETH Portal, initializing and deploying l2 contract...'); wethCrossChainHarness = await CrossChainTestHarness.new( aztecNode, - aztecRpcServer, + pxe, deployL1ContractsValues, accounts, wallet, @@ -101,7 +103,7 @@ describe.skip('uniswap_trade_on_l1_from_l2', () => { publicClient, }); // deploy l2 uniswap contract and attach to portal - const tx = UniswapContract.deploy(aztecRpcServer).send({ portalContract: uniswapPortalAddress }); + const tx = UniswapContract.deploy(pxe).send({ portalContract: uniswapPortalAddress }); await tx.isMined({ interval: 0.1 }); const receipt = await tx.getReceipt(); expect(receipt.status).toEqual(TxStatus.MINED); diff --git a/yarn-project/key-store/README.md b/yarn-project/key-store/README.md index 25d284f1f3a..e8dff2a84be 100644 --- a/yarn-project/key-store/README.md +++ b/yarn-project/key-store/README.md @@ -1,3 +1,3 @@ # Key Store -A key store is an input component for the [AztecRPCServer](../pxe/) to manage keys securely. It provides a secure environment and interfaces for users to manage their keys. When the AztecRPCServer requests keys and signatures from the key store, a well-designed key store should prompt users to authorize the requested action before sending any sensitive information to the AztecRPCServer. This helps to ensure that sensitive data, such as private keys, is not accessible to unauthorized parties. Additionally, the key store should provide robust protection mechanisms such as encryption, multi-factor authentication, and backup/restore functionalities to prevent data loss or theft. +A key store is an input component for the [PXEService](../pxe/) to manage keys securely. It provides a secure environment and interfaces for users to manage their keys. When the PXEService requests keys and signatures from the key store, a well-designed key store should prompt users to authorize the requested action before sending any sensitive information to the PXEService. This helps to ensure that sensitive data, such as private keys, is not accessible to unauthorized parties. Additionally, the key store should provide robust protection mechanisms such as encryption, multi-factor authentication, and backup/restore functionalities to prevent data loss or theft. diff --git a/yarn-project/noir-compiler/src/__snapshots__/index.test.ts.snap b/yarn-project/noir-compiler/src/__snapshots__/index.test.ts.snap index d3c5c08ec31..b6fdf8207ce 100644 --- a/yarn-project/noir-compiler/src/__snapshots__/index.test.ts.snap +++ b/yarn-project/noir-compiler/src/__snapshots__/index.test.ts.snap @@ -267,7 +267,7 @@ exports[`noir-compiler using nargo binary generates typescript interface 1`] = ` /* eslint-disable */ import { AztecAddress, CompleteAddress, ContractBase, ContractFunctionInteraction, ContractMethod, DeployMethod, FieldLike, Wallet } from '@aztec/aztec.js'; import { Fr, Point } from '@aztec/foundation/fields'; -import { AztecRPC, PublicKey } from '@aztec/types'; +import { PXE, PublicKey } from '@aztec/types'; import { ContractAbi } from '@aztec/foundation/abi'; import TestContractContractAbiJson from '../target/test.json' assert { type: 'json' }; export const TestContractContractAbi = TestContractContractAbiJson as ContractAbi; @@ -311,14 +311,14 @@ export class TestContractContract extends ContractBase { /** * Creates a tx to deploy a new instance of this contract. */ - public static deploy(rpc: AztecRPC, pub_param: FieldLike) { + public static deploy(rpc: PXE, pub_param: FieldLike) { return new DeployMethod(Point.ZERO, rpc, TestContractContractAbi, Array.from(arguments).slice(1)); } /** * Creates a tx to deploy a new instance of this contract using the specified public key to derive the address. */ - public static deployWithPublicKey(rpc: AztecRPC, publicKey: PublicKey, pub_param: FieldLike) { + public static deployWithPublicKey(rpc: PXE, publicKey: PublicKey, pub_param: FieldLike) { return new DeployMethod(publicKey, rpc, TestContractContractAbi, Array.from(arguments).slice(2)); } diff --git a/yarn-project/noir-compiler/src/contract-interface-gen/typescript.ts b/yarn-project/noir-compiler/src/contract-interface-gen/typescript.ts index a2fc7a94c2d..31ddb4ad10b 100644 --- a/yarn-project/noir-compiler/src/contract-interface-gen/typescript.ts +++ b/yarn-project/noir-compiler/src/contract-interface-gen/typescript.ts @@ -69,15 +69,15 @@ function generateDeploy(input: ContractAbi) { /** * Creates a tx to deploy a new instance of this contract. */ - public static deploy(rpc: AztecRPC, ${args}) { - return new DeployMethod<${input.name}Contract>(Point.ZERO, rpc, ${abiName}, Array.from(arguments).slice(1)); + public static deploy(pxe: PXE, ${args}) { + return new DeployMethod<${input.name}Contract>(Point.ZERO, pxe, ${abiName}, Array.from(arguments).slice(1)); } /** * Creates a tx to deploy a new instance of this contract using the specified public key to derive the address. */ - public static deployWithPublicKey(rpc: AztecRPC, publicKey: PublicKey, ${args}) { - return new DeployMethod<${input.name}Contract>(publicKey, rpc, ${abiName}, Array.from(arguments).slice(2)); + public static deployWithPublicKey(pxe: PXE, publicKey: PublicKey, ${args}) { + return new DeployMethod<${input.name}Contract>(publicKey, pxe, ${abiName}, Array.from(arguments).slice(2)); } `; } @@ -180,7 +180,7 @@ export function generateTypescriptContractInterface(input: ContractAbi, abiImpor /* eslint-disable */ import { AztecAddress, CompleteAddress, ContractBase, ContractFunctionInteraction, ContractMethod, DeployMethod, FieldLike, AztecAddressLike, EthAddressLike, Wallet } from '@aztec/aztec.js'; import { Fr, Point } from '@aztec/foundation/fields'; -import { AztecRPC, PublicKey } from '@aztec/types'; +import { PXE, PublicKey } from '@aztec/types'; import { ContractAbi } from '@aztec/foundation/abi'; ${abiStatement} diff --git a/yarn-project/pxe/README.md b/yarn-project/pxe/README.md index 9f50fa1cf0f..ba56822b3db 100644 --- a/yarn-project/pxe/README.md +++ b/yarn-project/pxe/README.md @@ -1,10 +1,10 @@ -# AztecRPCServer & AztecRPCClient +# PXE Service & PXE -`AztecRPCServer` is a server-side software that provides a set of apis for interacting with the Aztec network. It acts as a bridge between the network and client applications by exposing methods to manage accounts, deploy contracts, create transactions, and retrieve public and account-specific information. It provides a secure environment for the execution of sensitive operations, ensuring private information and decrypted data are not accessible to unauthorized applications. The AztecRPCServer is a critical component of the Aztec network, and its security and reliability are essential to the overall trustworthiness of user's data. +`PXE Service` (pronounced "pixie service") is a server-side software that provides a set of apis for interacting with the Aztec network. It acts as a bridge between the network and client applications by exposing methods to manage accounts, deploy contracts, create transactions, and retrieve public and account-specific information. It provides a secure environment for the execution of sensitive operations, ensuring private information and decrypted data are not accessible to unauthorized applications. The PXE Service is a critical component of the Aztec network, and its security and reliability are essential to the overall trustworthiness of user's data. -`AztecRPCClient` is the interface the AztecRPCServer and every client-side instance implement. Various implementations of the client-side can exist, including those for different platforms such as mobile apps and web browsers. It is a relay between the dApps and the actual AztecRPCServer. +`PXE` is the interface the PXE Service and every client-side instance implement. Various implementations of the client-side can exist, including those for different platforms such as mobile apps and web browsers. It is a relay between the dApps and the actual PXE Service. -### Main Components in an AztecRPCServer +### Main Components in an PXE Service - [Acir Simulator](../acir-simulator/) - [Key Store](../key-store/) diff --git a/yarn-project/pxe/src/aztec_rpc_http/index.ts b/yarn-project/pxe/src/aztec_rpc_http/index.ts deleted file mode 100644 index 939d0ac64c8..00000000000 --- a/yarn-project/pxe/src/aztec_rpc_http/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './aztec_rpc_http_server.js'; diff --git a/yarn-project/pxe/src/aztec_rpc_server/index.ts b/yarn-project/pxe/src/aztec_rpc_server/index.ts deleted file mode 100644 index 1cc9adbe3cb..00000000000 --- a/yarn-project/pxe/src/aztec_rpc_server/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './aztec_rpc_server.js'; -export * from './create_aztec_rpc_server.js'; -export { aztecRpcTestSuite } from './test/aztec_rpc_test_suite.js'; diff --git a/yarn-project/pxe/src/bin/index.ts b/yarn-project/pxe/src/bin/index.ts new file mode 100644 index 00000000000..2cfb5794c51 --- /dev/null +++ b/yarn-project/pxe/src/bin/index.ts @@ -0,0 +1,39 @@ +#!/usr/bin/env -S node --no-warnings +import { createDebugLogger } from '@aztec/foundation/log'; +import { createAztecNodeRpcClient } from '@aztec/types'; + +import { getPXEServiceConfig } from '../config/index.js'; +import { startPXEHttpServer } from '../pxe_http/index.js'; +import { createPXEService } from '../pxe_service/index.js'; + +const { SERVER_PORT = 8080, AZTEC_NODE_RPC_URL = '' } = process.env; + +const logger = createDebugLogger('aztec:pxe_service'); + +/** + * Create and start a new PXE HTTP Server + */ +async function main() { + logger.info(`Setting up PXE...`); + + const pxeConfig = getPXEServiceConfig(); + const nodeRpcClient = createAztecNodeRpcClient(AZTEC_NODE_RPC_URL); + const pxeService = await createPXEService(nodeRpcClient, pxeConfig); + + const shutdown = async () => { + logger.info('Shutting down...'); + await pxeService.stop(); + process.exit(0); + }; + + process.once('SIGINT', shutdown); + process.once('SIGTERM', shutdown); + + startPXEHttpServer(pxeService, SERVER_PORT); + logger.info(`PXE listening on port ${SERVER_PORT}`); +} + +main().catch(err => { + logger.error(err); + process.exit(1); +}); diff --git a/yarn-project/pxe/src/config/index.ts b/yarn-project/pxe/src/config/index.ts index 11a63369e05..81dab01b2ab 100644 --- a/yarn-project/pxe/src/config/index.ts +++ b/yarn-project/pxe/src/config/index.ts @@ -3,9 +3,9 @@ import { dirname, resolve } from 'path'; import { fileURLToPath } from 'url'; /** - * Configuration settings for the RPC Server. + * Configuration settings for the PXE Service. */ -export interface RpcServerConfig { +export interface PXEServiceConfig { /** * The interval to wait between polling for new blocks. */ @@ -13,13 +13,13 @@ export interface RpcServerConfig { } /** - * Creates an instance of SequencerClientConfig out of environment variables using sensible defaults for integration testing if not set. + * Creates an instance of PXEServiceConfig out of environment variables using sensible defaults for integration testing if not set. */ -export function getConfigEnvVars(): RpcServerConfig { - const { RPC_SERVER_BLOCK_POLLING_INTERVAL_MS } = process.env; +export function getPXEServiceConfig(): PXEServiceConfig { + const { PXE_SERVICE_BLOCK_POLLING_INTERVAL_MS } = process.env; return { - l2BlockPollingIntervalMS: RPC_SERVER_BLOCK_POLLING_INTERVAL_MS ? +RPC_SERVER_BLOCK_POLLING_INTERVAL_MS : 1000, + l2BlockPollingIntervalMS: PXE_SERVICE_BLOCK_POLLING_INTERVAL_MS ? +PXE_SERVICE_BLOCK_POLLING_INTERVAL_MS : 1000, }; } diff --git a/yarn-project/pxe/src/index.ts b/yarn-project/pxe/src/index.ts index 1356fae3a22..3aa2f478b0b 100644 --- a/yarn-project/pxe/src/index.ts +++ b/yarn-project/pxe/src/index.ts @@ -1,5 +1,5 @@ -export * from './aztec_rpc_server/index.js'; -export * from './aztec_rpc_http/index.js'; +export * from './pxe_service/index.js'; +export * from './pxe_http/index.js'; export * from './config/index.js'; export { Tx, TxHash } from '@aztec/types'; diff --git a/yarn-project/pxe/src/pxe_http/index.ts b/yarn-project/pxe/src/pxe_http/index.ts new file mode 100644 index 00000000000..9de03e58d4d --- /dev/null +++ b/yarn-project/pxe/src/pxe_http/index.ts @@ -0,0 +1 @@ +export * from './pxe_http_server.js'; diff --git a/yarn-project/pxe/src/aztec_rpc_http/aztec_rpc_http_server.ts b/yarn-project/pxe/src/pxe_http/pxe_http_server.ts similarity index 65% rename from yarn-project/pxe/src/aztec_rpc_http/aztec_rpc_http_server.ts rename to yarn-project/pxe/src/pxe_http/pxe_http_server.ts index 3dc5b84e44c..a6dc6cada6e 100644 --- a/yarn-project/pxe/src/aztec_rpc_http/aztec_rpc_http_server.ts +++ b/yarn-project/pxe/src/pxe_http/pxe_http_server.ts @@ -3,7 +3,6 @@ import { Fr, GrumpkinScalar, Point } from '@aztec/foundation/fields'; import { JsonRpcServer } from '@aztec/foundation/json-rpc/server'; import { AuthWitness, - AztecRPC, CompleteAddress, ContractData, ExtendedContractData, @@ -11,6 +10,7 @@ import { L2BlockL2Logs, L2Tx, NotePreimage, + PXE, Tx, TxExecutionRequest, TxHash, @@ -25,12 +25,12 @@ import { EthAddress } from '../index.js'; export const localAnvil = foundry; /** - * Wraps an instance of the Aztec RPC Server implementation to a JSON RPC HTTP interface. + * Wraps an instance of Private Execution Environment (PXE) implementation to a JSON RPC HTTP interface. * @returns A new instance of the HTTP server. */ -export function getHttpRpcServer(aztecRpcServer: AztecRPC): JsonRpcServer { - const generatedRpcServer = new JsonRpcServer( - aztecRpcServer, +export function createPXERpcServer(pxeService: PXE): JsonRpcServer { + return new JsonRpcServer( + pxeService, { CompleteAddress, AztecAddress, @@ -51,17 +51,16 @@ export function getHttpRpcServer(aztecRpcServer: AztecRPC): JsonRpcServer { false, ['start', 'stop'], ); - return generatedRpcServer; } /** - * Creates an http server that forwards calls to the rpc server and starts it on the given port. - * @param aztecRpcServer - RPC server that answers queries to the created HTTP server. + * Creates an http server that forwards calls to the PXE and starts it on the given port. + * @param pxeService - PXE that answers queries to the created HTTP server. * @param port - Port to listen in. * @returns A running http server. */ -export function startHttpRpcServer(aztecRpcServer: AztecRPC, port: string | number): http.Server { - const rpcServer = getHttpRpcServer(aztecRpcServer); +export function startPXEHttpServer(pxeService: PXE, port: string | number): http.Server { + const rpcServer = createPXERpcServer(pxeService); const app = rpcServer.getApp(); const httpServer = http.createServer(app.callback()); diff --git a/yarn-project/pxe/src/aztec_rpc_server/create_aztec_rpc_server.ts b/yarn-project/pxe/src/pxe_service/create_pxe_service.ts similarity index 57% rename from yarn-project/pxe/src/aztec_rpc_server/create_aztec_rpc_server.ts rename to yarn-project/pxe/src/pxe_service/create_pxe_service.ts index 4a4f5a7eb73..4fc15e58f6f 100644 --- a/yarn-project/pxe/src/aztec_rpc_server/create_aztec_rpc_server.ts +++ b/yarn-project/pxe/src/pxe_service/create_pxe_service.ts @@ -2,38 +2,38 @@ import { Grumpkin } from '@aztec/circuits.js/barretenberg'; import { TestKeyStore } from '@aztec/key-store'; import { AztecNode, KeyStore } from '@aztec/types'; -import { RpcServerConfig } from '../config/index.js'; +import { PXEServiceConfig } from '../config/index.js'; import { Database, MemoryDB } from '../database/index.js'; -import { AztecRPCServer } from './aztec_rpc_server.js'; +import { PXEService } from './pxe_service.js'; /** - * Optional information for creating an AztecRPCServer. + * Optional information for creating an PXEService. */ -interface CreateAztecRPCServerOptions { +interface CreatePXEServiceOptions { /** * A secure storage for cryptographic keys. */ keyStore?: KeyStore; /** - * Storage for the RPC server. + * Storage for the PXE. */ db?: Database; } /** - * Create and start an AztecRPCServer instance with the given AztecNode. + * Create and start an PXEService instance with the given AztecNode. * If no keyStore or database is provided, it will use TestKeyStore and MemoryDB as default values. - * Returns a Promise that resolves to the started AztecRPCServer instance. + * Returns a Promise that resolves to the started PXEService instance. * * @param aztecNode - The AztecNode instance to be used by the server. - * @param config - The Rpc Server Config to use - * @param options - (Optional) Optional information for creating an AztecRPCServer. - * @returns A Promise that resolves to the started AztecRPCServer instance. + * @param config - The PXE Service Config to use + * @param options - (Optional) Optional information for creating an PXEService. + * @returns A Promise that resolves to the started PXEService instance. */ -export async function createAztecRPCServer( +export async function createPXEService( aztecNode: AztecNode, - config: RpcServerConfig, - { keyStore, db }: CreateAztecRPCServerOptions = {}, + config: PXEServiceConfig, + { keyStore, db }: CreatePXEServiceOptions = {}, useLogSuffix: string | boolean | undefined = undefined, ) { const logSuffix = @@ -46,7 +46,7 @@ export async function createAztecRPCServer( keyStore = keyStore || new TestKeyStore(await Grumpkin.new()); db = db || new MemoryDB(logSuffix); - const server = new AztecRPCServer(keyStore, aztecNode, db, config, logSuffix); + const server = new PXEService(keyStore, aztecNode, db, config, logSuffix); await server.start(); return server; } diff --git a/yarn-project/pxe/src/pxe_service/index.ts b/yarn-project/pxe/src/pxe_service/index.ts new file mode 100644 index 00000000000..a43b331f3ad --- /dev/null +++ b/yarn-project/pxe/src/pxe_service/index.ts @@ -0,0 +1,3 @@ +export * from './pxe_service.js'; +export * from './create_pxe_service.js'; +export { pxeTestSuite } from './test/pxe_test_suite.js'; diff --git a/yarn-project/pxe/src/aztec_rpc_server/aztec_rpc_server.ts b/yarn-project/pxe/src/pxe_service/pxe_service.ts similarity index 96% rename from yarn-project/pxe/src/aztec_rpc_server/aztec_rpc_server.ts rename to yarn-project/pxe/src/pxe_service/pxe_service.ts index a4eee145a1d..9a808b2b395 100644 --- a/yarn-project/pxe/src/aztec_rpc_server/aztec_rpc_server.ts +++ b/yarn-project/pxe/src/pxe_service/pxe_service.ts @@ -27,7 +27,6 @@ import NoirVersion from '@aztec/noir-compiler/noir-version'; import { AuthWitness, AztecNode, - AztecRPC, ContractDao, ContractData, DeployedContract, @@ -41,6 +40,7 @@ import { LogType, NodeInfo, NotePreimage, + PXE, PublicKey, SimulationError, Tx, @@ -54,7 +54,7 @@ import { toContractDao, } from '@aztec/types'; -import { RpcServerConfig, getPackageInfo } from '../config/index.js'; +import { PXEServiceConfig, getPackageInfo } from '../config/index.js'; import { ContractDataOracle } from '../contract_data_oracle/index.js'; import { Database } from '../database/index.js'; import { KernelOracle } from '../kernel_oracle/index.js'; @@ -63,9 +63,9 @@ import { getAcirSimulator } from '../simulator/index.js'; import { Synchronizer } from '../synchronizer/index.js'; /** - * A remote Aztec RPC Client implementation. + * A Private Execution Environment (PXE) implementation. */ -export class AztecRPCServer implements AztecRPC { +export class PXEService implements PXE { private synchronizer: Synchronizer; private contractDataOracle: ContractDataOracle; private simulator: AcirSimulator; @@ -76,10 +76,10 @@ export class AztecRPCServer implements AztecRPC { private keyStore: KeyStore, private node: AztecNode, private db: Database, - private config: RpcServerConfig, + private config: PXEServiceConfig, logSuffix?: string, ) { - this.log = createDebugLogger(logSuffix ? `aztec:rpc_server_${logSuffix}` : `aztec:rpc_server`); + this.log = createDebugLogger(logSuffix ? `aztec:pxe_service_${logSuffix}` : `aztec:pxe_service`); this.synchronizer = new Synchronizer(node, db, logSuffix); this.contractDataOracle = new ContractDataOracle(db, node); this.simulator = getAcirSimulator(db, node, node, node, keyStore, this.contractDataOracle); @@ -88,18 +88,18 @@ export class AztecRPCServer implements AztecRPC { } /** - * Starts the Aztec RPC server by beginning the synchronisation process between the Aztec node and the database. + * Starts the PXE Service by beginning the synchronisation process between the Aztec node and the database. * * @returns A promise that resolves when the server has started successfully. */ public async start() { await this.synchronizer.start(INITIAL_L2_BLOCK_NUM, 1, this.config.l2BlockPollingIntervalMS); const info = await this.getNodeInfo(); - this.log.info(`Started RPC server connected to chain ${info.chainId} version ${info.protocolVersion}`); + this.log.info(`Started PXE connected to chain ${info.chainId} version ${info.protocolVersion}`); } /** - * Stops the Aztec RPC server, halting processing of new transactions and shutting down the synchronizer. + * Stops the PXE Service, halting processing of new transactions and shutting down the synchronizer. * This function ensures that all ongoing tasks are completed before stopping the server. * It is useful for gracefully shutting down the server during maintenance or restarts. * @@ -193,7 +193,7 @@ export class AztecRPCServer implements AztecRPC { } const notes = await this.db.getNoteSpendingInfo(contract, storageSlot); const ownerCompleteAddress = await this.db.getCompleteAddress(owner); - if (!ownerCompleteAddress) throw new Error(`Owner ${owner} not registered in RPC server`); + if (!ownerCompleteAddress) throw new Error(`Owner ${owner} not registered in PXE`); const { publicKey: ownerPublicKey } = ownerCompleteAddress; const ownerNotes = notes.filter(n => n.publicKey.equals(ownerPublicKey)); return ownerNotes.map(n => n.notePreimage); @@ -366,7 +366,7 @@ export class AztecRPCServer implements AztecRPC { async #getFunctionCall(functionName: string, args: any[], to: AztecAddress): Promise { const contract = await this.db.getContract(to); if (!contract) { - throw new Error(`Unknown contract ${to}: add it to Aztec RPC server by calling server.addContracts(...)`); + throw new Error(`Unknown contract ${to}: add it to PXE Service by calling server.addContracts(...)`); } const functionDao = contract.functions.find(f => f.name === functionName); @@ -480,7 +480,7 @@ export class AztecRPCServer implements AztecRPC { try { await this.node.simulatePublicCalls(tx); } catch (err) { - // Try to fill in the noir call stack since the RPC server may have access to the debug metadata + // Try to fill in the noir call stack since the PXE may have access to the debug metadata if (err instanceof SimulationError) { const callStack = err.getCallStack(); const originalFailingFunction = callStack[callStack.length - 1]; diff --git a/yarn-project/pxe/src/aztec_rpc_server/test/aztec_rpc_server.test.ts b/yarn-project/pxe/src/pxe_service/test/pxe_service.test.ts similarity index 74% rename from yarn-project/pxe/src/aztec_rpc_server/test/aztec_rpc_server.test.ts rename to yarn-project/pxe/src/pxe_service/test/pxe_service.test.ts index 09aabfd08ed..a6fde8a0f36 100644 --- a/yarn-project/pxe/src/aztec_rpc_server/test/aztec_rpc_server.test.ts +++ b/yarn-project/pxe/src/pxe_service/test/pxe_service.test.ts @@ -2,20 +2,20 @@ import { Grumpkin } from '@aztec/circuits.js/barretenberg'; import { L1ContractAddresses } from '@aztec/ethereum'; import { EthAddress } from '@aztec/foundation/eth-address'; import { TestKeyStore } from '@aztec/key-store'; -import { AztecNode, AztecRPC, L2Tx, mockTx } from '@aztec/types'; +import { AztecNode, L2Tx, PXE, mockTx } from '@aztec/types'; import { MockProxy, mock } from 'jest-mock-extended'; import { MemoryDB } from '../../database/memory_db.js'; -import { RpcServerConfig } from '../../index.js'; -import { AztecRPCServer } from '../aztec_rpc_server.js'; -import { aztecRpcTestSuite } from './aztec_rpc_test_suite.js'; +import { PXEServiceConfig } from '../../index.js'; +import { PXEService } from '../pxe_service.js'; +import { pxeTestSuite } from './pxe_test_suite.js'; -async function createAztecRpcServer(): Promise { +async function createPXEService(): Promise { const keyStore = new TestKeyStore(await Grumpkin.new()); const node = mock(); const db = new MemoryDB(); - const config: RpcServerConfig = { + const config: PXEServiceConfig = { l2BlockPollingIntervalMS: 100, }; @@ -33,16 +33,16 @@ async function createAztecRpcServer(): Promise { }; node.getL1ContractAddresses.mockResolvedValue(mockedContracts); - return new AztecRPCServer(keyStore, node, db, config); + return new PXEService(keyStore, node, db, config); } -aztecRpcTestSuite('AztecRPCServer', createAztecRpcServer); +pxeTestSuite('PXEService', createPXEService); -describe('AztecRPCServer', () => { +describe('PXEService', () => { let keyStore: TestKeyStore; let node: MockProxy; let db: MemoryDB; - let config: RpcServerConfig; + let config: PXEServiceConfig; beforeEach(async () => { keyStore = new TestKeyStore(await Grumpkin.new()); @@ -59,7 +59,7 @@ describe('AztecRPCServer', () => { node.getTx.mockResolvedValue(settledTx); - const rpc = new AztecRPCServer(keyStore, node, db, config); + const rpc = new PXEService(keyStore, node, db, config); await expect(rpc.sendTx(duplicateTx)).rejects.toThrowError(/A settled tx with equal hash/); }); }); diff --git a/yarn-project/pxe/src/aztec_rpc_server/test/aztec_rpc_test_suite.ts b/yarn-project/pxe/src/pxe_service/test/pxe_test_suite.ts similarity index 75% rename from yarn-project/pxe/src/aztec_rpc_server/test/aztec_rpc_test_suite.ts rename to yarn-project/pxe/src/pxe_service/test/pxe_test_suite.ts index ce612295dfd..cbb772b36fa 100644 --- a/yarn-project/pxe/src/aztec_rpc_server/test/aztec_rpc_test_suite.ts +++ b/yarn-project/pxe/src/pxe_service/test/pxe_test_suite.ts @@ -1,20 +1,14 @@ import { AztecAddress, CompleteAddress, Fr, FunctionData, Point, TxContext } from '@aztec/circuits.js'; import { Grumpkin } from '@aztec/circuits.js/barretenberg'; import { ConstantKeyPair } from '@aztec/key-store'; -import { - AztecRPC, - DeployedContract, - INITIAL_L2_BLOCK_NUM, - TxExecutionRequest, - randomDeployedContract, -} from '@aztec/types'; - -export const aztecRpcTestSuite = (testName: string, aztecRpcSetup: () => Promise) => { +import { DeployedContract, INITIAL_L2_BLOCK_NUM, PXE, TxExecutionRequest, randomDeployedContract } from '@aztec/types'; + +export const pxeTestSuite = (testName: string, pxeSetup: () => Promise) => { describe(testName, () => { - let rpc: AztecRPC; + let pxe: PXE; beforeAll(async () => { - rpc = await aztecRpcSetup(); + pxe = await pxeSetup(); }, 120_000); it('registers an account and returns it as an account only and not as a recipient', async () => { @@ -24,17 +18,17 @@ export const aztecRpcTestSuite = (testName: string, aztecRpcSetup: () => Promise Fr.random(), ); - await rpc.registerAccount(await keyPair.getPrivateKey(), completeAddress.partialAddress); + await pxe.registerAccount(await keyPair.getPrivateKey(), completeAddress.partialAddress); // Check that the account is correctly registered using the getAccounts and getRecipients methods - const accounts = await rpc.getRegisteredAccounts(); - const recipients = await rpc.getRecipients(); + const accounts = await pxe.getRegisteredAccounts(); + const recipients = await pxe.getRecipients(); expect(accounts).toContainEqual(completeAddress); expect(recipients).not.toContainEqual(completeAddress); // Check that the account is correctly registered using the getAccount and getRecipient methods - const account = await rpc.getRegisteredAccount(completeAddress.address); - const recipient = await rpc.getRecipient(completeAddress.address); + const account = await pxe.getRegisteredAccount(completeAddress.address); + const recipient = await pxe.getRecipient(completeAddress.address); expect(account).toEqual(completeAddress); expect(recipient).toBeUndefined(); }); @@ -42,17 +36,17 @@ export const aztecRpcTestSuite = (testName: string, aztecRpcSetup: () => Promise it('registers a recipient and returns it as a recipient only and not as an account', async () => { const completeAddress = await CompleteAddress.random(); - await rpc.registerRecipient(completeAddress); + await pxe.registerRecipient(completeAddress); // Check that the recipient is correctly registered using the getAccounts and getRecipients methods - const accounts = await rpc.getRegisteredAccounts(); - const recipients = await rpc.getRecipients(); + const accounts = await pxe.getRegisteredAccounts(); + const recipients = await pxe.getRecipients(); expect(accounts).not.toContainEqual(completeAddress); expect(recipients).toContainEqual(completeAddress); // Check that the recipient is correctly registered using the getAccount and getRecipient methods - const account = await rpc.getRegisteredAccount(completeAddress.address); - const recipient = await rpc.getRecipient(completeAddress.address); + const account = await pxe.getRegisteredAccount(completeAddress.address); + const recipient = await pxe.getRecipient(completeAddress.address); expect(account).toBeUndefined(); expect(recipient).toEqual(completeAddress); }); @@ -64,16 +58,16 @@ export const aztecRpcTestSuite = (testName: string, aztecRpcSetup: () => Promise Fr.random(), ); - await rpc.registerAccount(await keyPair.getPrivateKey(), completeAddress.partialAddress); - await rpc.registerAccount(await keyPair.getPrivateKey(), completeAddress.partialAddress); + await pxe.registerAccount(await keyPair.getPrivateKey(), completeAddress.partialAddress); + await pxe.registerAccount(await keyPair.getPrivateKey(), completeAddress.partialAddress); }); it('cannot register a recipient with the same aztec address but different pub key or partial address', async () => { const recipient1 = await CompleteAddress.random(); const recipient2 = new CompleteAddress(recipient1.address, Point.random(), Fr.random()); - await rpc.registerRecipient(recipient1); - await expect(() => rpc.registerRecipient(recipient2)).rejects.toThrow( + await pxe.registerRecipient(recipient1); + await expect(() => pxe.registerRecipient(recipient2)).rejects.toThrow( `Complete address with aztec address ${recipient1.address}`, ); }); @@ -81,16 +75,16 @@ export const aztecRpcTestSuite = (testName: string, aztecRpcSetup: () => Promise it('does not throw when registering the same recipient twice (just ignores the second attempt)', async () => { const completeAddress = await CompleteAddress.random(); - await rpc.registerRecipient(completeAddress); - await rpc.registerRecipient(completeAddress); + await pxe.registerRecipient(completeAddress); + await pxe.registerRecipient(completeAddress); }); it('successfully adds a contract', async () => { const contracts: DeployedContract[] = [await randomDeployedContract(), await randomDeployedContract()]; - await rpc.addContracts(contracts); + await pxe.addContracts(contracts); const expectedContractAddresses = contracts.map(contract => contract.completeAddress.address); - const contractAddresses = await rpc.getContracts(); + const contractAddresses = await pxe.getContracts(); // check if all the contracts were returned expect(contractAddresses).toEqual(expect.arrayContaining(expectedContractAddresses)); @@ -108,7 +102,7 @@ export const aztecRpcTestSuite = (testName: string, aztecRpcSetup: () => Promise authWitnesses: [], }); - await expect(async () => await rpc.simulateTx(txExecutionRequest, false)).rejects.toThrow( + await expect(async () => await pxe.simulateTx(txExecutionRequest, false)).rejects.toThrow( 'Public entrypoints are not allowed', ); }); @@ -118,7 +112,7 @@ export const aztecRpcTestSuite = (testName: string, aztecRpcSetup: () => Promise it('throws when getting public storage for non-existent contract', async () => { const contract = AztecAddress.random(); - await expect(async () => await rpc.getPublicStorageAt(contract, new Fr(0n))).rejects.toThrow( + await expect(async () => await pxe.getPublicStorageAt(contract, new Fr(0n))).rejects.toThrow( `Contract ${contract.toString()} is not deployed`, ); }); @@ -127,12 +121,12 @@ export const aztecRpcTestSuite = (testName: string, aztecRpcSetup: () => Promise // functions only call AztecNode and these methods are frequently used by the e2e tests. it('successfully gets a block number', async () => { - const blockNum = await rpc.getBlockNumber(); + const blockNum = await pxe.getBlockNumber(); expect(blockNum).toBeGreaterThanOrEqual(INITIAL_L2_BLOCK_NUM); }); it('successfully gets node info', async () => { - const nodeInfo = await rpc.getNodeInfo(); + const nodeInfo = await pxe.getNodeInfo(); expect(typeof nodeInfo.protocolVersion).toEqual('number'); expect(typeof nodeInfo.chainId).toEqual('number'); expect(nodeInfo.l1ContractAddresses.rollupAddress.toString()).toMatch(/0x[a-fA-F0-9]+/); diff --git a/yarn-project/pxe/src/simulator_oracle/index.ts b/yarn-project/pxe/src/simulator_oracle/index.ts index 68309243747..0fb1ee0ce38 100644 --- a/yarn-project/pxe/src/simulator_oracle/index.ts +++ b/yarn-project/pxe/src/simulator_oracle/index.ts @@ -34,7 +34,7 @@ export class SimulatorOracle implements DBOracle { const completeAddress = await this.db.getCompleteAddress(address); if (!completeAddress) throw new Error( - `Unknown complete address for address ${address.toString()}. Add the information to Aztec RPC server by calling server.registerRecipient(...) or server.registerAccount(...)`, + `Unknown complete address for address ${address.toString()}. Add the information to PXE Service by calling server.registerRecipient(...) or server.registerAccount(...)`, ); return completeAddress; } diff --git a/yarn-project/pxe/src/synchronizer/synchronizer.ts b/yarn-project/pxe/src/synchronizer/synchronizer.ts index e8e69c7b004..8a6796de435 100644 --- a/yarn-project/pxe/src/synchronizer/synchronizer.ts +++ b/yarn-project/pxe/src/synchronizer/synchronizer.ts @@ -25,9 +25,7 @@ export class Synchronizer { private noteProcessorsToCatchUp: NoteProcessor[] = []; constructor(private node: AztecNode, private db: Database, logSuffix = '') { - this.log = createDebugLogger( - logSuffix ? `aztec:aztec_rpc_synchronizer_${logSuffix}` : 'aztec:aztec_rpc_synchronizer', - ); + this.log = createDebugLogger(logSuffix ? `aztec:pxe_synchronizer_${logSuffix}` : 'aztec:pxe_synchronizer'); } /** diff --git a/yarn-project/types/src/interfaces/index.ts b/yarn-project/types/src/interfaces/index.ts index d53098ad94c..cde71ea5604 100644 --- a/yarn-project/types/src/interfaces/index.ts +++ b/yarn-project/types/src/interfaces/index.ts @@ -3,7 +3,7 @@ export * from './hasher.js'; export * from './data_commitment_provider.js'; export * from './l1_l2_message_provider.js'; export * from './aztec-node.js'; -export * from './aztec_rpc.js'; +export * from './pxe.js'; export * from './deployed-contract.js'; export * from './node-info.js'; export * from './sync-status.js'; diff --git a/yarn-project/types/src/interfaces/aztec_rpc.ts b/yarn-project/types/src/interfaces/pxe.ts similarity index 91% rename from yarn-project/types/src/interfaces/aztec_rpc.ts rename to yarn-project/types/src/interfaces/pxe.ts index 94217c10a83..938b1ca0fcc 100644 --- a/yarn-project/types/src/interfaces/aztec_rpc.ts +++ b/yarn-project/types/src/interfaces/pxe.ts @@ -18,14 +18,14 @@ import { DeployedContract } from './deployed-contract.js'; import { NodeInfo } from './node-info.js'; import { SyncStatus } from './sync-status.js'; -// docs:start:rpc-interface +// docs:start:pxe-interface /** - * The Aztec RPC Server runs locally for each user, providing functionality for all the operations + * Private Execution Environment (PXE) runs locally for each user, providing functionality for all the operations * needed to interact with the Aztec network, including account management, private data management, * transaction local simulation, and access to an Aztec node. This interface, as part of a Wallet, * is exposed to dapps for interacting with the network on behalf of the user. */ -export interface AztecRPC { +export interface PXE { /** * Insert an auth witness for a given message hash. Auth witnesses are used to authorise actions on * behalf of a user. For instance, a token transfer initiated by a different address may request @@ -41,8 +41,8 @@ export interface AztecRPC { addAuthWitness(authWitness: AuthWitness): Promise; /** - * Registers a user account in the Aztec RPC server given its master encryption private key. - * Once a new account is registered, the RPC server will trial-decrypt all published notes on + * Registers a user account in PXE given its master encryption private key. + * Once a new account is registered, the PXE Service will trial-decrypt all published notes on * the chain and store those that correspond to the registered account. * * @param privKey - Private key of the corresponding user master public key. @@ -52,13 +52,13 @@ export interface AztecRPC { registerAccount(privKey: GrumpkinPrivateKey, partialAddress: PartialAddress): Promise; /** - * Registers a recipient in the Aztec RPC server. This is required when sending encrypted notes to + * Registers a recipient in PXE. This is required when sending encrypted notes to * a user who hasn't deployed their account contract yet. Since their account is not deployed, their - * encryption public key has not been broadcasted, so we need to manually register it on the RPC server + * encryption public key has not been broadcasted, so we need to manually register it on the PXE Service * in order to be able to encrypt data for this recipient. * * @param recipient - The complete address of the recipient - * @remarks Called recipient because we can only send notes to this account and not receive them via this RPC server. + * @remarks Called recipient because we can only send notes to this account and not receive them via this PXE Service. * This is because we don't have the associated private key and for this reason we can't decrypt * the recipient's notes. We can send notes to this account because we can encrypt them with the recipient's * public key. @@ -66,8 +66,8 @@ export interface AztecRPC { registerRecipient(recipient: CompleteAddress): Promise; /** - * Retrieves the user accounts registered on this rpc server. - * @returns An array of the accounts registered on this RPC server. + * Retrieves the user accounts registered on this PXE Service. + * @returns An array of the accounts registered on this PXE Service. */ getRegisteredAccounts(): Promise; @@ -81,8 +81,8 @@ export interface AztecRPC { getRegisteredAccount(address: AztecAddress): Promise; /** - * Retrieves the recipients added to this rpc server. - * @returns An array of recipients registered on this RPC server. + * Retrieves the recipients added to this PXE Service. + * @returns An array of recipients registered on this PXE Service. */ getRecipients(): Promise; @@ -96,18 +96,18 @@ export interface AztecRPC { getRecipient(address: AztecAddress): Promise; /** - * Adds deployed contracts to the RPC server. Deployed contract information is used to access the + * Adds deployed contracts to the PXE Service. Deployed contract information is used to access the * contract code when simulating local transactions. This is automatically called by aztec.js when * deploying a contract. Dapps that wish to interact with contracts already deployed should register - * these contracts in their users' RPC server through this method. + * these contracts in their users' PXE Service through this method. * * @param contracts - An array of DeployedContract objects containing contract ABI, address, and portal contract. */ addContracts(contracts: DeployedContract[]): Promise; /** - * Retrieves the addresses of contracts added to this rpc server. - * @returns An array of contracts addresses registered on this RPC server. + * Retrieves the addresses of contracts added to this PXE Service. + * @returns An array of contracts addresses registered on this PXE Service. */ getContracts(): Promise; @@ -149,7 +149,7 @@ export interface AztecRPC { /** * Retrieves the private storage data at a specified contract address and storage slot. Returns only data - * encrypted for the specified owner that has been already decrypted by the RPC server. Note that there + * encrypted for the specified owner that has been already decrypted by the PXE Service. Note that there * may be multiple notes for a user in a single slot. * * @param owner - The address for whom the private data is encrypted. @@ -278,4 +278,4 @@ export interface AztecRPC { */ getSyncStatus(): Promise; } -// docs:end:rpc-interface +// docs:end:pxe-interface diff --git a/yarn-project/types/src/tx_execution_request.ts b/yarn-project/types/src/tx_execution_request.ts index f9abc90104b..e3e5e830dcd 100644 --- a/yarn-project/types/src/tx_execution_request.ts +++ b/yarn-project/types/src/tx_execution_request.ts @@ -33,7 +33,7 @@ export class TxExecutionRequest { public packedArguments: PackedArguments[], /** * Transient authorization witnesses for authorizing the execution of one or more actions during this tx. - * These witnesses are not expected to be stored in the local witnesses database of the RPC server. + * These witnesses are not expected to be stored in the local witnesses database of the PXE. */ public authWitnesses: AuthWitness[], ) {}