From 645614494f9bd371b9f94ff70a55e69e95307f9d Mon Sep 17 00:00:00 2001 From: benesjan <13470840+benesjan@users.noreply.github.com> Date: Mon, 22 Sep 2025 13:56:28 +0000 Subject: [PATCH] refactor: un-exposing PXE from e2e tests e2e tests should interact only with a wallet (and maybe a node) because PXE is becoming only a lib used by a wallet. This PR is a step in that direction. # Followup work 1. Drop PXE JSON RPC server, 2. have Wallet instantiate PXE instead of having it passed in as an arg to a constructor, 3. revisit the PXE methods exposed on the TestWallet. --- yarn-project/accounts/src/testing/index.ts | 7 +- .../aztec/src/cli/aztec_start_action.ts | 4 +- yarn-project/aztec/src/cli/cmds/start_bot.ts | 23 +++--- yarn-project/aztec/src/cli/cmds/start_node.ts | 14 ++-- yarn-project/aztec/src/cli/cmds/start_pxe.ts | 29 ++------ yarn-project/aztec/src/examples/token.ts | 2 +- yarn-project/aztec/src/sandbox/banana_fpc.ts | 10 +-- .../aztec/src/sandbox/sponsored_fpc.ts | 12 +-- .../aztec/src/testing/aztec_cheat_codes.ts | 10 +-- yarn-project/aztec/src/testing/cheat_codes.ts | 11 ++- yarn-project/bot/src/amm_bot.ts | 15 ++-- yarn-project/bot/src/bot.ts | 15 ++-- yarn-project/bot/src/factory.ts | 74 +++++-------------- yarn-project/bot/src/runner.ts | 35 ++++----- .../client_flows/client_flows_benchmark.ts | 12 +-- yarn-project/end-to-end/src/bench/utils.ts | 29 +------- .../src/composed/e2e_persistence.test.ts | 8 +- .../end-to-end/src/composed/e2e_pxe.test.ts | 12 --- .../src/composed/e2e_sandbox_example.test.ts | 14 ++-- .../e2e_token_bridge_tutorial_test.test.ts | 8 +- .../uniswap_trade_on_l1_from_l2.test.ts | 2 - .../end-to-end/src/devnet/e2e_smoke.test.ts | 19 ++--- .../end-to-end/src/e2e_2_pxes.test.ts | 22 +++--- .../src/e2e_account_contracts.test.ts | 11 +-- .../blacklist_token_contract_test.ts | 5 +- .../minting.test.ts | 6 +- .../end-to-end/src/e2e_block_building.test.ts | 15 +--- yarn-project/end-to-end/src/e2e_bot.test.ts | 18 +++-- .../cross_chain_messaging_test.ts | 14 ++-- .../token_bridge_private.test.ts | 31 +++++--- .../src/e2e_crowdfunding_and_claim.test.ts | 15 ++-- .../e2e_deploy_contract/deploy_method.test.ts | 7 +- .../src/e2e_deploy_contract/deploy_test.ts | 9 +-- .../src/e2e_deploy_contract/legacy.test.ts | 14 ++-- .../src/e2e_escrow_contract.test.ts | 9 +-- .../end-to-end/src/e2e_fees/fees_test.ts | 15 ++-- .../nested_contract_test.ts | 6 +- .../src/e2e_offchain_effect.test.ts | 6 +- .../e2e_pending_note_hashes_contract.test.ts | 9 +-- .../src/e2e_sequencer_config.test.ts | 9 ++- .../end-to-end/src/e2e_synching.test.ts | 35 +++------ .../src/fixtures/e2e_prover_test.ts | 19 ++--- .../src/fixtures/snapshot_manager.ts | 9 +-- yarn-project/end-to-end/src/fixtures/utils.ts | 51 ++++++------- .../src/guides/dapp_testing.test.ts | 15 ++-- .../src/shared/cross_chain_test_harness.ts | 5 -- .../src/shared/gas_portal_test_harness.ts | 10 +-- .../end-to-end/src/shared/uniswap_l1_l2.ts | 8 +- .../end-to-end/src/spartan/1tps.test.ts | 28 ++++--- .../end-to-end/src/spartan/4epochs.test.ts | 24 +++--- .../end-to-end/src/spartan/n_tps.test.ts | 18 +++-- .../end-to-end/src/spartan/reorg.test.ts | 20 ++--- .../src/spartan/setup_test_wallets.ts | 25 +++---- .../end-to-end/src/spartan/transfer.test.ts | 17 +++-- .../test-wallet/src/wallet/test_wallet.ts | 31 +++++++- 55 files changed, 384 insertions(+), 517 deletions(-) delete mode 100644 yarn-project/end-to-end/src/composed/e2e_pxe.test.ts diff --git a/yarn-project/accounts/src/testing/index.ts b/yarn-project/accounts/src/testing/index.ts index 387da5c8fe1f..f170063d326f 100644 --- a/yarn-project/accounts/src/testing/index.ts +++ b/yarn-project/accounts/src/testing/index.ts @@ -18,11 +18,11 @@ import { } from './configuration.js'; export { - type InitialAccountData, INITIAL_TEST_ACCOUNT_SALTS, INITIAL_TEST_ENCRYPTION_KEYS, INITIAL_TEST_SECRET_KEYS, INITIAL_TEST_SIGNING_KEYS, + type InitialAccountData, } from './configuration.js'; /** @@ -45,10 +45,11 @@ export function getInitialTestAccountsData(): Promise { /** * Queries a PXE for it's registered accounts. - * @param pxe - PXE instance. + * @param testWalletOrPxe - Test wallet or pxe instance to use to get the registered accounts. * @returns A set of key data for each of the initial accounts. */ -export async function getDeployedTestAccounts(pxe: PXE): Promise { +export async function getDeployedTestAccounts(testWalletOrPxe: { getPxe(): PXE } | PXE): Promise { + const pxe = 'getPxe' in testWalletOrPxe ? testWalletOrPxe.getPxe() : testWalletOrPxe; const registeredAccounts = await pxe.getRegisteredAccounts(); const testAccounts = await getInitialTestAccountsData(); return testAccounts.filter(t => registeredAccounts.some(r => r.address.equals(t.address))); diff --git a/yarn-project/aztec/src/cli/aztec_start_action.ts b/yarn-project/aztec/src/cli/aztec_start_action.ts index f52acf64839b..30cea42205ac 100644 --- a/yarn-project/aztec/src/cli/aztec_start_action.ts +++ b/yarn-project/aztec/src/cli/aztec_start_action.ts @@ -63,8 +63,8 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg const { startBlobSink } = await import('./cmds/start_blob_sink.js'); await startBlobSink(options, signalHandlers, userLog); } else if (options.pxe) { - const { startPXE } = await import('./cmds/start_pxe.js'); - ({ config } = await startPXE(options, signalHandlers, services, userLog)); + const { startPXEServiceGetWallet } = await import('./cmds/start_pxe.js'); + ({ config } = await startPXEServiceGetWallet(options, services, userLog)); } else if (options.archiver) { const { startArchiver } = await import('./cmds/start_archiver.js'); ({ config } = await startArchiver(options, signalHandlers, services)); diff --git a/yarn-project/aztec/src/cli/cmds/start_bot.ts b/yarn-project/aztec/src/cli/cmds/start_bot.ts index 0d7e4b87c6be..292e7b34d967 100644 --- a/yarn-project/aztec/src/cli/cmds/start_bot.ts +++ b/yarn-project/aztec/src/cli/cmds/start_bot.ts @@ -1,13 +1,14 @@ import { type BotConfig, BotRunner, botConfigMappings, getBotRunnerApiHandler } from '@aztec/bot'; import type { NamespacedApiHandlers } from '@aztec/foundation/json-rpc/server'; import type { LogFn } from '@aztec/foundation/log'; -import { type AztecNode, type PXE, createAztecNodeClient } from '@aztec/stdlib/interfaces/client'; +import { type AztecNode, type AztecNodeAdmin, createAztecNodeClient } from '@aztec/stdlib/interfaces/client'; import type { TelemetryClient } from '@aztec/telemetry-client'; import { getConfigEnvVars as getTelemetryClientConfig, initTelemetryClient, makeTracedFetch, } from '@aztec/telemetry-client'; +import { TestWallet } from '@aztec/test-wallet'; import { extractRelevantOptions } from '../util.js'; import { getVersions } from '../versioning.js'; @@ -32,28 +33,28 @@ export async function startBot( throw new Error('The bot requires access to a Node'); } - const node = createAztecNodeClient(config.nodeUrl, getVersions(), fetch); + const aztecNode = createAztecNodeClient(config.nodeUrl, getVersions(), fetch); - // Start a PXE client that is used by the bot if required - let pxe: PXE | undefined; - if (options.pxe) { - const { addPXE } = await import('./start_pxe.js'); - ({ pxe } = await addPXE(options, signalHandlers, services, userLog, { node })); - } + // Start a PXE client and get a wallet that is used by the bot if required + const { startPXEServiceGetWallet } = await import('./start_pxe.js'); + const { wallet } = await startPXEServiceGetWallet(options, services, userLog, { node: aztecNode }); const telemetry = initTelemetryClient(getTelemetryClientConfig()); - await addBot(options, signalHandlers, services, { pxe, telemetry, node }); + await addBot(options, signalHandlers, services, wallet, aztecNode, telemetry, undefined); } export function addBot( options: any, signalHandlers: (() => Promise)[], services: NamespacedApiHandlers, - deps: { pxe?: PXE; node?: AztecNode; telemetry: TelemetryClient }, + wallet: TestWallet, + aztecNode: AztecNode, + telemetry: TelemetryClient, + aztecNodeAdmin?: AztecNodeAdmin, ) { const config = extractRelevantOptions(options, botConfigMappings, 'bot'); - const botRunner = new BotRunner(config, deps); + const botRunner = new BotRunner(config, wallet, aztecNode, telemetry, aztecNodeAdmin); if (!config.noStart) { void botRunner.start(); // Do not block since bot setup takes time } diff --git a/yarn-project/aztec/src/cli/cmds/start_node.ts b/yarn-project/aztec/src/cli/cmds/start_node.ts index 5ecc6f5b78d8..e34036f37820 100644 --- a/yarn-project/aztec/src/cli/cmds/start_node.ts +++ b/yarn-project/aztec/src/cli/cmds/start_node.ts @@ -7,7 +7,7 @@ import { getPublicClient } from '@aztec/ethereum'; import { SecretValue } from '@aztec/foundation/config'; import type { NamespacedApiHandlers } from '@aztec/foundation/json-rpc/server'; import type { LogFn } from '@aztec/foundation/log'; -import { AztecNodeAdminApiSchema, AztecNodeApiSchema, type PXE } from '@aztec/stdlib/interfaces/client'; +import { AztecNodeAdminApiSchema, AztecNodeApiSchema } from '@aztec/stdlib/interfaces/client'; import { P2PApiSchema } from '@aztec/stdlib/interfaces/server'; import { type TelemetryClientConfig, @@ -128,17 +128,13 @@ export async function startNode( // Add node stop function to signal handlers signalHandlers.push(node.stop.bind(node)); - // Add a PXE client that connects to this node if requested - let pxe: PXE | undefined; - if (options.pxe) { - const { addPXE } = await import('./start_pxe.js'); - ({ pxe } = await addPXE(options, signalHandlers, services, userLog, { node })); - } - // Add a txs bot if requested if (options.bot) { const { addBot } = await import('./start_bot.js'); - await addBot(options, signalHandlers, services, { pxe, node, telemetry }); + const { startPXEServiceGetWallet } = await import('./start_pxe.js'); + const { wallet } = await startPXEServiceGetWallet(options, services, userLog, { node }); + + await addBot(options, signalHandlers, services, wallet, node, telemetry, undefined); } if (nodeConfig.autoUpdate !== 'disabled' && nodeConfig.autoUpdateUrl) { diff --git a/yarn-project/aztec/src/cli/cmds/start_pxe.ts b/yarn-project/aztec/src/cli/cmds/start_pxe.ts index 388a773ae427..eb943474e0a8 100644 --- a/yarn-project/aztec/src/cli/cmds/start_pxe.ts +++ b/yarn-project/aztec/src/cli/cmds/start_pxe.ts @@ -1,36 +1,21 @@ import type { NamespacedApiHandlers } from '@aztec/foundation/json-rpc/server'; import type { LogFn } from '@aztec/foundation/log'; -import { - type CliPXEOptions, - type PXEService, - type PXEServiceConfig, - allPxeConfigMappings, - createPXEService, -} from '@aztec/pxe/server'; +import { type CliPXEOptions, type PXEServiceConfig, allPxeConfigMappings, createPXEService } from '@aztec/pxe/server'; import { type AztecNode, PXESchema, createAztecNodeClient } from '@aztec/stdlib/interfaces/client'; import { makeTracedFetch } from '@aztec/telemetry-client'; +import { TestWallet } from '@aztec/test-wallet'; import { extractRelevantOptions } from '../util.js'; import { getVersions } from '../versioning.js'; -export type { PXEServiceConfig, CliPXEOptions }; +export type { CliPXEOptions, PXEServiceConfig }; -export async function startPXE( +export async function startPXEServiceGetWallet( options: any, - signalHandlers: (() => Promise)[], - services: NamespacedApiHandlers, - userLog: LogFn, -): Promise<{ pxe: PXEService; config: PXEServiceConfig & CliPXEOptions }> { - return await addPXE(options, signalHandlers, services, userLog, {}); -} - -export async function addPXE( - options: any, - _signalHandlers: (() => Promise)[], services: NamespacedApiHandlers, userLog: LogFn, deps: { node?: AztecNode } = {}, -): Promise<{ pxe: PXEService; config: PXEServiceConfig & CliPXEOptions }> { +): Promise<{ wallet: TestWallet; config: PXEServiceConfig & CliPXEOptions }> { const pxeConfig = extractRelevantOptions(options, allPxeConfigMappings, 'pxe'); const nodeUrl = pxeConfig.nodeUrl; @@ -42,8 +27,10 @@ export async function addPXE( const node = deps.node ?? createAztecNodeClient(nodeUrl!, getVersions(pxeConfig), makeTracedFetch([1, 2, 3], true)); const pxe = await createPXEService(node, pxeConfig as PXEServiceConfig); + const wallet = new TestWallet(pxe, node); + // Add PXE to services list services.pxe = [pxe, PXESchema]; - return { pxe, config: pxeConfig }; + return { wallet, config: pxeConfig }; } diff --git a/yarn-project/aztec/src/examples/token.ts b/yarn-project/aztec/src/examples/token.ts index 37c899c70ef7..84ed02f6f70f 100644 --- a/yarn-project/aztec/src/examples/token.ts +++ b/yarn-project/aztec/src/examples/token.ts @@ -22,7 +22,7 @@ const TRANSFER_AMOUNT = 33n; async function main() { logger.info('Running token contract test on HTTP interface.'); - const accounts = await getDeployedTestAccounts(pxe); + const accounts = await getDeployedTestAccounts(wallet); const [alice, bob] = await Promise.all( accounts.map(async acc => { const accountManager = await wallet.createSchnorrAccount(acc.secret, acc.salt); diff --git a/yarn-project/aztec/src/sandbox/banana_fpc.ts b/yarn-project/aztec/src/sandbox/banana_fpc.ts index 8e13d40f2e32..7aa579b3f0c1 100644 --- a/yarn-project/aztec/src/sandbox/banana_fpc.ts +++ b/yarn-project/aztec/src/sandbox/banana_fpc.ts @@ -6,7 +6,7 @@ import { FPCContract } from '@aztec/noir-contracts.js/FPC'; import { TokenContract } from '@aztec/noir-contracts.js/Token'; import { AztecAddress } from '@aztec/stdlib/aztec-address'; import { type ContractInstanceWithAddress, getContractInstanceFromInstantiationParams } from '@aztec/stdlib/contract'; -import type { PXE } from '@aztec/stdlib/interfaces/client'; +import type { TestWallet } from '@aztec/test-wallet'; const BANANA_COIN_SALT = new Fr(0); const bananaCoinArgs = { @@ -62,20 +62,20 @@ export async function setupBananaFPC(initialAccounts: InitialAccountData[], wall log(`FPC: ${fpc.address}`); } -export async function getDeployedBananaCoinAddress(pxe: PXE) { +export async function getDeployedBananaCoinAddress(wallet: TestWallet) { const initialAccounts = await getInitialTestAccountsData(); const bananaCoin = await getBananaCoinAddress(initialAccounts); - const contracts = await pxe.getContracts(); + const contracts = await wallet.getContracts(); if (!contracts.find(c => c.equals(bananaCoin))) { throw new Error('BananaCoin not deployed.'); } return bananaCoin; } -export async function getDeployedBananaFPCAddress(pxe: PXE) { +export async function getDeployedBananaFPCAddress(wallet: TestWallet) { const initialAccounts = await getInitialTestAccountsData(); const fpc = await getBananaFPCInstance(initialAccounts); - const contracts = await pxe.getContracts(); + const contracts = await wallet.getContracts(); if (!contracts.find(c => c.equals(fpc.address))) { throw new Error('BananaFPC not deployed.'); } diff --git a/yarn-project/aztec/src/sandbox/sponsored_fpc.ts b/yarn-project/aztec/src/sandbox/sponsored_fpc.ts index 73dc18feca4a..73c293fcb25f 100644 --- a/yarn-project/aztec/src/sandbox/sponsored_fpc.ts +++ b/yarn-project/aztec/src/sandbox/sponsored_fpc.ts @@ -1,11 +1,7 @@ -import { - type ContractInstanceWithAddress, - Fr, - type PXE, - getContractInstanceFromInstantiationParams, -} from '@aztec/aztec.js'; +import { type ContractInstanceWithAddress, Fr, getContractInstanceFromInstantiationParams } from '@aztec/aztec.js'; import { SPONSORED_FPC_SALT } from '@aztec/constants'; import { SponsoredFPCContract } from '@aztec/noir-contracts.js/SponsoredFPC'; +import type { TestWallet } from '@aztec/test-wallet'; async function getSponsoredFPCInstance(): Promise { return await getContractInstanceFromInstantiationParams(SponsoredFPCContract.artifact, { @@ -17,9 +13,9 @@ export async function getSponsoredFPCAddress() { return (await getSponsoredFPCInstance()).address; } -export async function getDeployedSponsoredFPCAddress(pxe: PXE) { +export async function getDeployedSponsoredFPCAddress(wallet: TestWallet) { const fpc = await getSponsoredFPCAddress(); - const contracts = await pxe.getContracts(); + const contracts = await wallet.getContracts(); if (!contracts.find(c => c.equals(fpc))) { throw new Error('SponsoredFPC not deployed.'); } diff --git a/yarn-project/aztec/src/testing/aztec_cheat_codes.ts b/yarn-project/aztec/src/testing/aztec_cheat_codes.ts index 4672805aa8fa..82895a5de2d8 100644 --- a/yarn-project/aztec/src/testing/aztec_cheat_codes.ts +++ b/yarn-project/aztec/src/testing/aztec_cheat_codes.ts @@ -2,8 +2,8 @@ import { Fr } from '@aztec/foundation/fields'; import { createLogger } from '@aztec/foundation/log'; import type { AztecAddress } from '@aztec/stdlib/aztec-address'; import { deriveStorageSlotInMap } from '@aztec/stdlib/hash'; -import type { AztecNode, PXE } from '@aztec/stdlib/interfaces/client'; -import type { Note } from '@aztec/stdlib/note'; +import type { AztecNode } from '@aztec/stdlib/interfaces/client'; +import type { Note, NotesFilter, UniqueNote } from '@aztec/stdlib/note'; /** * A class that provides utility functions for interacting with the aztec chain. @@ -11,9 +11,9 @@ import type { Note } from '@aztec/stdlib/note'; export class AztecCheatCodes { constructor( /** - * The PXE Service to use for interacting with the chain + * The test wallet or pxe to use for getting notes */ - public pxe: PXE, + public testWalletOrPxe: { getNotes(filter: NotesFilter): Promise }, /** * The Aztec Node to use for interacting with the chain */ @@ -71,7 +71,7 @@ export class AztecCheatCodes { * @returns The notes stored at the given slot */ public async loadPrivate(recipient: AztecAddress, contract: AztecAddress, slot: Fr | bigint): Promise { - const extendedNotes = await this.pxe.getNotes({ + const extendedNotes = await this.testWalletOrPxe.getNotes({ recipient, contractAddress: contract, storageSlot: new Fr(slot), diff --git a/yarn-project/aztec/src/testing/cheat_codes.ts b/yarn-project/aztec/src/testing/cheat_codes.ts index fb131aa87fd4..4798ce62efc0 100644 --- a/yarn-project/aztec/src/testing/cheat_codes.ts +++ b/yarn-project/aztec/src/testing/cheat_codes.ts @@ -1,7 +1,8 @@ import { retryUntil } from '@aztec/aztec.js'; import { EthCheatCodes, RollupCheatCodes } from '@aztec/ethereum/test'; import type { SequencerClient } from '@aztec/sequencer-client'; -import type { AztecNode, PXE } from '@aztec/stdlib/interfaces/client'; +import type { AztecNode } from '@aztec/stdlib/interfaces/client'; +import type { NotesFilter, UniqueNote } from '@aztec/stdlib/note'; import { AztecCheatCodes } from './aztec_cheat_codes.js'; @@ -18,9 +19,13 @@ export class CheatCodes { public rollup: RollupCheatCodes, ) {} - static async create(rpcUrls: string[], pxe: PXE, node: AztecNode): Promise { + static async create( + rpcUrls: string[], + testWalletOrPxe: { getNotes(filter: NotesFilter): Promise }, + node: AztecNode, + ): Promise { const ethCheatCodes = new EthCheatCodes(rpcUrls); - const aztecCheatCodes = new AztecCheatCodes(pxe, node); + const aztecCheatCodes = new AztecCheatCodes(testWalletOrPxe, node); const rollupCheatCodes = new RollupCheatCodes( ethCheatCodes, await node.getNodeInfo().then(n => n.l1ContractAddresses), diff --git a/yarn-project/bot/src/amm_bot.ts b/yarn-project/bot/src/amm_bot.ts index d27a61fb5232..8dc005ff18bc 100644 --- a/yarn-project/bot/src/amm_bot.ts +++ b/yarn-project/bot/src/amm_bot.ts @@ -2,7 +2,8 @@ import { AztecAddress, Fr, SentTx, TxReceipt, type Wallet } from '@aztec/aztec.j import { jsonStringify } from '@aztec/foundation/json-rpc'; import type { AMMContract } from '@aztec/noir-contracts.js/AMM'; import type { TokenContract } from '@aztec/noir-contracts.js/Token'; -import type { AztecNode, AztecNodeAdmin, PXE } from '@aztec/stdlib/interfaces/client'; +import type { AztecNode, AztecNodeAdmin } from '@aztec/stdlib/interfaces/client'; +import type { TestWallet } from '@aztec/test-wallet'; import { BaseBot } from './base_bot.js'; import type { BotConfig } from './config.js'; @@ -28,13 +29,17 @@ export class AmmBot extends BaseBot { static async create( config: BotConfig, - dependencies: { pxe?: PXE; node?: AztecNode; nodeAdmin?: AztecNodeAdmin }, + wallet: TestWallet, + aztecNode: AztecNode, + aztecNodeAdmin: AztecNodeAdmin | undefined, ): Promise { - const { node, wallet, defaultAccountAddress, token0, token1, amm } = await new BotFactory( + const { defaultAccountAddress, token0, token1, amm } = await new BotFactory( config, - dependencies, + wallet, + aztecNode, + aztecNodeAdmin, ).setupAmm(); - return new AmmBot(node, wallet, defaultAccountAddress, amm, token0, token1, config); + return new AmmBot(aztecNode, wallet, defaultAccountAddress, amm, token0, token1, config); } protected async createAndSendTx(logCtx: object): Promise { diff --git a/yarn-project/bot/src/bot.ts b/yarn-project/bot/src/bot.ts index 43e355b3e08f..a58344461f5e 100644 --- a/yarn-project/bot/src/bot.ts +++ b/yarn-project/bot/src/bot.ts @@ -2,7 +2,8 @@ import { type AztecAddress, BatchCall, SentTx, type Wallet } from '@aztec/aztec. import { times } from '@aztec/foundation/collection'; import type { PrivateTokenContract } from '@aztec/noir-contracts.js/PrivateToken'; import type { TokenContract } from '@aztec/noir-contracts.js/Token'; -import type { AztecNode, AztecNodeAdmin, PXE } from '@aztec/stdlib/interfaces/client'; +import type { AztecNode, AztecNodeAdmin } from '@aztec/stdlib/interfaces/client'; +import type { TestWallet } from '@aztec/test-wallet'; import { BaseBot } from './base_bot.js'; import type { BotConfig } from './config.js'; @@ -25,13 +26,17 @@ export class Bot extends BaseBot { static async create( config: BotConfig, - dependencies: { pxe?: PXE; node?: AztecNode; nodeAdmin?: AztecNodeAdmin }, + wallet: TestWallet, + aztecNode: AztecNode, + aztecNodeAdmin?: AztecNodeAdmin, ): Promise { - const { node, wallet, defaultAccountAddress, token, recipient } = await new BotFactory( + const { defaultAccountAddress, token, recipient } = await new BotFactory( config, - dependencies, + wallet, + aztecNode, + aztecNodeAdmin, ).setup(); - return new Bot(node, wallet, defaultAccountAddress, token, recipient, config); + return new Bot(aztecNode, wallet, defaultAccountAddress, token, recipient, config); } public updateConfig(config: Partial) { diff --git a/yarn-project/bot/src/factory.ts b/yarn-project/bot/src/factory.ts index b3270337fba1..8fe6a7e5f532 100644 --- a/yarn-project/bot/src/factory.ts +++ b/yarn-project/bot/src/factory.ts @@ -9,10 +9,7 @@ import { type DeployOptions, FeeJuicePaymentMethodWithClaim, L1FeeJuicePortalManager, - type PXE, - createAztecNodeClient, createLogger, - createPXEClient, waitForL1ToL2MessageReady, } from '@aztec/aztec.js'; import { createEthereumChain, createExtendedL1Client } from '@aztec/ethereum'; @@ -23,58 +20,23 @@ import { PrivateTokenContract } from '@aztec/noir-contracts.js/PrivateToken'; import { TokenContract } from '@aztec/noir-contracts.js/Token'; import type { AztecNode, AztecNodeAdmin } from '@aztec/stdlib/interfaces/client'; import { deriveSigningKey } from '@aztec/stdlib/keys'; -import { makeTracedFetch } from '@aztec/telemetry-client'; import { TestWallet } from '@aztec/test-wallet'; -import { type BotConfig, SupportedTokenContracts, getVersions } from './config.js'; +import { type BotConfig, SupportedTokenContracts } from './config.js'; import { getBalances, getPrivateBalance, isStandardTokenContract } from './utils.js'; const MINT_BALANCE = 1e12; const MIN_BALANCE = 1e3; export class BotFactory { - private pxe: PXE; - private wallet: TestWallet; - private node: AztecNode; - private nodeAdmin?: AztecNodeAdmin; private log = createLogger('bot'); constructor( private readonly config: BotConfig, - dependencies: { pxe?: PXE; nodeAdmin?: AztecNodeAdmin; node?: AztecNode }, - ) { - if (config.flushSetupTransactions && !dependencies.nodeAdmin) { - throw new Error( - `Either a node admin client or node admin url must be provided if transaction flushing is requested`, - ); - } - if (config.senderPrivateKey && config.senderPrivateKey.getValue() && !dependencies.node) { - throw new Error( - `Either a node client or node url must be provided for bridging L1 fee juice to deploy an account with private key`, - ); - } - if (!dependencies.pxe && !config.pxeUrl) { - throw new Error(`Either a PXE client or a PXE URL must be provided`); - } - - this.nodeAdmin = dependencies.nodeAdmin; - - if (dependencies.pxe) { - this.log.info(`Using local PXE`); - this.pxe = dependencies.pxe; - } else { - this.log.info(`Using remote PXE at ${config.pxeUrl!}`); - this.pxe = createPXEClient(config.pxeUrl!, getVersions(), makeTracedFetch([1, 2, 3], false)); - } - - if (dependencies.node) { - this.node = dependencies.node; - } else { - this.node = createAztecNodeClient(config.nodeUrl!, getVersions(), makeTracedFetch([1, 2, 3], false)); - } - - this.wallet = new TestWallet(this.pxe, this.node); - } + private readonly wallet: TestWallet, + private readonly aztecNode: AztecNode, + private readonly aztecNodeAdmin?: AztecNodeAdmin, + ) {} /** * Initializes a new bot by setting up the sender account, registering the recipient, @@ -85,7 +47,7 @@ export class BotFactory { const defaultAccountAddress = await this.setupAccount(); const token = await this.setupToken(defaultAccountAddress); await this.mintTokens(token, defaultAccountAddress); - return { wallet: this.wallet, defaultAccountAddress, token, node: this.node, recipient }; + return { wallet: this.wallet, defaultAccountAddress, token, node: this.aztecNode, recipient }; } public async setupAmm() { @@ -109,7 +71,7 @@ export class BotFactory { await this.fundAmm(defaultAccountAddress, defaultAccountAddress, amm, token0, token1, liquidityToken); this.log.info(`AMM initialized and funded`); - return { wallet: this.wallet, defaultAccountAddress, amm, token0, token1, node: this.node }; + return { wallet: this.wallet, defaultAccountAddress, amm, token0, token1, node: this.aztecNode }; } /** @@ -136,7 +98,7 @@ export class BotFactory { contract: new SchnorrAccountContract(signingKey!), }; const accountManager = await this.wallet.createAccount(accountData); - const isInit = (await this.pxe.getContractMetadata(accountManager.getAddress())).isContractInitialized; + const isInit = (await this.wallet.getContractMetadata(accountManager.getAddress())).isContractInitialized; if (isInit) { this.log.info(`Account at ${accountManager.getAddress().toString()} already initialized`); const timer = new Timer(); @@ -176,7 +138,7 @@ export class BotFactory { * Registers the recipient for txs in the pxe. */ private async registerRecipient() { - const recipient = await this.pxe.registerAccount(this.config.recipientEncryptionSecret.getValue(), Fr.ONE); + const recipient = await this.wallet.registerAccount(this.config.recipientEncryptionSecret.getValue(), Fr.ONE); return recipient.address; } @@ -204,7 +166,7 @@ export class BotFactory { } const address = (await deploy.getInstance(deployOpts)).address; - if ((await this.pxe.getContractMetadata(address)).isContractPublished) { + if ((await this.wallet.getContractMetadata(address)).isContractPublished) { this.log.info(`Token at ${address.toString()} already deployed`); return deploy.register(); } else { @@ -337,7 +299,7 @@ export class BotFactory { deployOpts: DeployOptions, ): Promise { const address = (await deploy.getInstance(deployOpts)).address; - if ((await this.pxe.getContractMetadata(address)).isContractPublished) { + if ((await this.wallet.getContractMetadata(address)).isContractPublished) { this.log.info(`Contract ${name} at ${address.toString()} already deployed`); return deploy.register(); } else { @@ -400,16 +362,16 @@ export class BotFactory { ); } - const { l1ChainId } = await this.node.getNodeInfo(); + const { l1ChainId } = await this.aztecNode.getNodeInfo(); const chain = createEthereumChain(l1RpcUrls, l1ChainId); const extendedClient = createExtendedL1Client(chain.rpcUrls, mnemonicOrPrivateKey, chain.chainInfo); - const portal = await L1FeeJuicePortalManager.new(this.node, extendedClient, this.log); + const portal = await L1FeeJuicePortalManager.new(this.aztecNode, extendedClient, this.log); const mintAmount = await portal.getTokenManager().getMintAmount(); const claim = await portal.bridgeTokensPublic(recipient, mintAmount, true /* mint */); await this.withNoMinTxsPerBlock(() => - waitForL1ToL2MessageReady(this.node, Fr.fromHexString(claim.messageHash), { + waitForL1ToL2MessageReady(this.aztecNode, Fr.fromHexString(claim.messageHash), { timeoutSeconds: this.config.l1ToL2MessageTimeoutSeconds, forPublicConsumption: false, }), @@ -421,18 +383,18 @@ export class BotFactory { } private async withNoMinTxsPerBlock(fn: () => Promise): Promise { - if (!this.nodeAdmin || !this.config.flushSetupTransactions) { + if (!this.aztecNodeAdmin || !this.config.flushSetupTransactions) { this.log.verbose(`No node admin client or flushing not requested (not setting minTxsPerBlock to 0)`); return fn(); } - const { minTxsPerBlock } = await this.nodeAdmin.getConfig(); + const { minTxsPerBlock } = await this.aztecNodeAdmin.getConfig(); this.log.warn(`Setting sequencer minTxsPerBlock to 0 from ${minTxsPerBlock} to flush setup transactions`); - await this.nodeAdmin.setConfig({ minTxsPerBlock: 0 }); + await this.aztecNodeAdmin.setConfig({ minTxsPerBlock: 0 }); try { return await fn(); } finally { this.log.warn(`Restoring sequencer minTxsPerBlock to ${minTxsPerBlock}`); - await this.nodeAdmin.setConfig({ minTxsPerBlock }); + await this.aztecNodeAdmin.setConfig({ minTxsPerBlock }); } } } diff --git a/yarn-project/bot/src/runner.ts b/yarn-project/bot/src/runner.ts index c4ff23b04f9f..0810ba9e3b71 100644 --- a/yarn-project/bot/src/runner.ts +++ b/yarn-project/bot/src/runner.ts @@ -1,21 +1,19 @@ -import { type AztecNode, createAztecNodeClient, createLogger } from '@aztec/aztec.js'; +import { type AztecNode, createLogger } from '@aztec/aztec.js'; import { omit } from '@aztec/foundation/collection'; import { RunningPromise } from '@aztec/foundation/running-promise'; -import { type AztecNodeAdmin, type PXE, createAztecNodeAdminClient } from '@aztec/stdlib/interfaces/client'; -import { type TelemetryClient, type Traceable, type Tracer, makeTracedFetch, trackSpan } from '@aztec/telemetry-client'; +import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client'; +import { type TelemetryClient, type Traceable, type Tracer, trackSpan } from '@aztec/telemetry-client'; +import type { TestWallet } from '@aztec/test-wallet'; import { AmmBot } from './amm_bot.js'; import type { BaseBot } from './base_bot.js'; import { Bot } from './bot.js'; -import { type BotConfig, getVersions } from './config.js'; +import type { BotConfig } from './config.js'; import type { BotInfo, BotRunnerApi } from './interface.js'; export class BotRunner implements BotRunnerApi, Traceable { private log = createLogger('bot'); private bot?: Promise; - private pxe?: PXE; - private node: AztecNode; - private nodeAdmin?: AztecNodeAdmin; private runningPromise: RunningPromise; private consecutiveErrors = 0; private healthy = true; @@ -24,18 +22,13 @@ export class BotRunner implements BotRunnerApi, Traceable { public constructor( private config: BotConfig, - dependencies: { pxe?: PXE; node?: AztecNode; nodeAdmin?: AztecNodeAdmin; telemetry: TelemetryClient }, + private readonly wallet: TestWallet, + private readonly aztecNode: AztecNode, + private readonly telemetry: TelemetryClient, + private readonly aztecNodeAdmin?: AztecNodeAdmin, ) { - this.tracer = dependencies.telemetry.getTracer('Bot'); - if (!dependencies.node && !config.nodeUrl) { - throw new Error(`Missing node URL in config or dependencies`); - } - const versions = getVersions(); - const fetch = makeTracedFetch([1, 2, 3], true); - this.node = dependencies.node ?? createAztecNodeClient(config.nodeUrl!, versions, fetch); - this.nodeAdmin = - dependencies.nodeAdmin ?? - (config.nodeAdminUrl ? createAztecNodeAdminClient(config.nodeAdminUrl, versions, fetch) : undefined); + this.tracer = telemetry.getTracer('Bot'); + this.runningPromise = new RunningPromise(() => this.#work(), this.log, config.txIntervalSeconds * 1000); } @@ -150,8 +143,8 @@ export class BotRunner implements BotRunnerApi, Traceable { async #createBot() { try { this.bot = this.config.ammTxs - ? AmmBot.create(this.config, { pxe: this.pxe, node: this.node, nodeAdmin: this.nodeAdmin }) - : Bot.create(this.config, { pxe: this.pxe, node: this.node, nodeAdmin: this.nodeAdmin }); + ? AmmBot.create(this.config, this.wallet, this.aztecNode, this.aztecNodeAdmin) + : Bot.create(this.config, this.wallet, this.aztecNode); await this.bot; } catch (err) { this.log.error(`Error setting up bot: ${err}`); @@ -162,7 +155,7 @@ export class BotRunner implements BotRunnerApi, Traceable { @trackSpan('Bot.work') async #work() { if (this.config.maxPendingTxs > 0) { - const pendingTxCount = await this.node.getPendingTxCount(); + const pendingTxCount = await this.aztecNode.getPendingTxCount(); if (pendingTxCount >= this.config.maxPendingTxs) { this.log.verbose(`Not sending bot tx since node has ${pendingTxCount} pending txs`); return; diff --git a/yarn-project/end-to-end/src/bench/client_flows/client_flows_benchmark.ts b/yarn-project/end-to-end/src/bench/client_flows/client_flows_benchmark.ts index 8c7d6e488f89..61ed6ae40fe1 100644 --- a/yarn-project/end-to-end/src/bench/client_flows/client_flows_benchmark.ts +++ b/yarn-project/end-to-end/src/bench/client_flows/client_flows_benchmark.ts @@ -57,7 +57,6 @@ export class ClientFlowsBenchmark { private snapshotManager: ISnapshotManager; public logger: Logger; - private pxe!: PXE; public aztecNode!: AztecNode; public cheatCodes!: CheatCodes; public context!: SubsystemsContext; @@ -202,12 +201,11 @@ export class ClientFlowsBenchmark { deployAccounts(2, this.logger), async ( { deployedAccounts: [{ address: adminAddress }, { address: sequencerAddress }] }, - { wallet, pxe, aztecNode, aztecNodeConfig }, + { wallet, aztecNode, aztecNodeConfig }, ) => { - this.pxe = pxe; this.adminWallet = wallet; this.aztecNode = aztecNode; - this.cheatCodes = await CheatCodes.create(aztecNodeConfig.l1RpcUrls, pxe, aztecNode); + this.cheatCodes = await CheatCodes.create(aztecNodeConfig.l1RpcUrls, wallet, aztecNode); this.adminAddress = adminAddress; this.sequencerAddress = sequencerAddress; @@ -246,7 +244,6 @@ export class ClientFlowsBenchmark { this.feeJuiceBridgeTestHarness = await FeeJuicePortalTestingHarnessFactory.create({ aztecNode: context.aztecNode, aztecNodeAdmin: context.aztecNode, - pxeService: context.pxe, l1Client: context.deployL1ContractsValues.l1Client, wallet: this.adminWallet, logger: this.logger, @@ -292,7 +289,7 @@ export class ClientFlowsBenchmark { 'fpc_setup', async context => { const feeJuiceContract = this.feeJuiceBridgeTestHarness.feeJuice; - expect((await context.pxe.getContractMetadata(feeJuiceContract.address)).isContractPublished).toBe(true); + expect((await context.wallet.getContractMetadata(feeJuiceContract.address)).isContractPublished).toBe(true); const bananaCoin = this.bananaCoin; const bananaFPC = await FPCContract.deploy(this.adminWallet, bananaCoin.address, this.adminAddress) @@ -315,7 +312,7 @@ export class ClientFlowsBenchmark { await this.snapshotManager.snapshot( 'deploy_sponsored_fpc', async () => { - const sponsoredFPC = await setupSponsoredFPC(this.pxe); + const sponsoredFPC = await setupSponsoredFPC(this.adminWallet); this.logger.info(`SponsoredFPC at ${sponsoredFPC.address}`); return { sponsoredFPCAddress: sponsoredFPC.address }; }, @@ -337,7 +334,6 @@ export class ClientFlowsBenchmark { this.logger.verbose(`Setting up cross chain harness...`); const crossChainTestHarness = await CrossChainTestHarness.new( this.aztecNode, - this.pxe, l1Client, this.adminWallet, owner, diff --git a/yarn-project/end-to-end/src/bench/utils.ts b/yarn-project/end-to-end/src/bench/utils.ts index 44d66e4dca3b..b18df8cdd12f 100644 --- a/yarn-project/end-to-end/src/bench/utils.ts +++ b/yarn-project/end-to-end/src/bench/utils.ts @@ -1,8 +1,7 @@ import type { AztecNodeService } from '@aztec/aztec-node'; -import { type AztecNode, BatchCall, type SentTx, type WaitOpts } from '@aztec/aztec.js'; +import { BatchCall, type SentTx, type WaitOpts } from '@aztec/aztec.js'; import { mean, stdDev, times } from '@aztec/foundation/collection'; import { BenchmarkingContract } from '@aztec/noir-test-contracts.js/Benchmarking'; -import { type PXEService, type PXEServiceConfig, createPXEService } from '@aztec/pxe/server'; import type { MetricsType } from '@aztec/telemetry-client'; import type { BenchmarkDataPoint, BenchmarkMetricsType, BenchmarkTelemetryClient } from '@aztec/telemetry-client/bench'; @@ -150,32 +149,6 @@ export async function waitTxs(txs: SentTx[], context: EndToEndContext, txWaitOpt context.logger.info(`All ${txs.length} txs have been mined`); } -/** - * Creates a new PXE - * @param node - Node to connect the pxe to. - * @param contract - Benchmark contract to add to the pxe. - * @param startingBlock - First l2 block to process. - * @returns The new PXE. - */ -export async function createNewPXE(node: AztecNode, contract: BenchmarkingContract): Promise { - const l1Contracts = await node.getL1ContractAddresses(); - const { l1ChainId, rollupVersion } = await node.getNodeInfo(); - const pxeConfig = { - l2BlockBatchSize: 50, - l2BlockPollingIntervalMS: 100, - dataDirectory: undefined, - dataStoreMapSizeKB: 1024 * 1024, - l1Contracts, - l1ChainId, - rollupVersion, - } as PXEServiceConfig; - // docs:start:PXEcreate - const pxe = await createPXEService(node, pxeConfig); - // docs:end:PXEcreate - await pxe.registerContract(contract); - return pxe; -} - function randomBytesAsBigInts(length: number): bigint[] { return [...Array(length)].map(_ => BigInt(Math.floor(Math.random() * 255))); } diff --git a/yarn-project/end-to-end/src/composed/e2e_persistence.test.ts b/yarn-project/end-to-end/src/composed/e2e_persistence.test.ts index 45e364c5a567..7278dd9b7cd1 100644 --- a/yarn-project/end-to-end/src/composed/e2e_persistence.test.ts +++ b/yarn-project/end-to-end/src/composed/e2e_persistence.test.ts @@ -221,7 +221,7 @@ describe('Aztec persistence', () => { }); it("pxe does not have owner's private notes", async () => { - await context.pxe.registerContract({ + await context.wallet.registerContract({ artifact: TokenBlacklistContract.artifact, instance: contractInstance, }); @@ -232,7 +232,7 @@ describe('Aztec persistence', () => { }); it('has access to public storage', async () => { - await context.pxe.registerContract({ + await context.wallet.registerContract({ artifact: TokenBlacklistContract.artifact, instance: contractInstance, }); @@ -242,7 +242,7 @@ describe('Aztec persistence', () => { }); it('pxe restores notes after registering the owner', async () => { - await context.pxe.registerContract({ + await context.wallet.registerContract({ artifact: TokenBlacklistContract.artifact, instance: contractInstance, }); @@ -272,7 +272,7 @@ describe('Aztec persistence', () => { beforeAll(async () => { const temporaryContext = await setup(0, { deployL1ContractsValues }, {}); - await temporaryContext.pxe.registerContract({ + await temporaryContext.wallet.registerContract({ artifact: TokenBlacklistContract.artifact, instance: contractInstance, }); diff --git a/yarn-project/end-to-end/src/composed/e2e_pxe.test.ts b/yarn-project/end-to-end/src/composed/e2e_pxe.test.ts deleted file mode 100644 index 98db76e755a7..000000000000 --- a/yarn-project/end-to-end/src/composed/e2e_pxe.test.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { waitForPXE } from '@aztec/aztec.js'; -import { pxeTestSuite } from '@aztec/pxe/testing'; - -import { setup } from '../fixtures/utils.js'; - -const setupEnv = async () => { - const { pxe } = await setup(0); - await waitForPXE(pxe); - return pxe; -}; - -pxeTestSuite('e2e_pxe', setupEnv); diff --git a/yarn-project/end-to-end/src/composed/e2e_sandbox_example.test.ts b/yarn-project/end-to-end/src/composed/e2e_sandbox_example.test.ts index 1236bb35ae5f..89cd6388b652 100644 --- a/yarn-project/end-to-end/src/composed/e2e_sandbox_example.test.ts +++ b/yarn-project/end-to-end/src/composed/e2e_sandbox_example.test.ts @@ -58,7 +58,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 [aliceAccount, bobAccount] = await getDeployedTestAccounts(pxe); + const [aliceAccount, bobAccount] = await getDeployedTestAccounts(wallet); await wallet.createSchnorrAccount(aliceAccount.secret, aliceAccount.salt); await wallet.createSchnorrAccount(bobAccount.secret, bobAccount.salt); @@ -77,7 +77,7 @@ describe('e2e_sandbox_example', () => { // docs:end:Deployment // ensure that token contract is registered in PXE - expect(await pxe.getContracts()).toEqual(expect.arrayContaining([tokenContract.address])); + expect(await wallet.getContracts()).toEqual(expect.arrayContaining([tokenContract.address])); // docs:start:Balance @@ -148,8 +148,8 @@ describe('e2e_sandbox_example', () => { ////////////// CREATE SOME ACCOUNTS WITH SCHNORR SIGNERS ////////////// // Use one of the pre-funded accounts to pay for the deployments. - const [fundedAccount] = await getDeployedTestAccounts(pxe); const wallet = new TestWallet(pxe, node); + const [fundedAccount] = await getDeployedTestAccounts(wallet); await wallet.createSchnorrAccount(fundedAccount.secret, fundedAccount.salt); // Creates new accounts using an account contract that verifies schnorr signatures @@ -177,7 +177,7 @@ describe('e2e_sandbox_example', () => { const [alice, bob] = (await Promise.all(accounts.map(a => a.getCompleteAddress()))).map(a => a.address); ////////////// VERIFY THE ACCOUNTS WERE CREATED SUCCESSFULLY ////////////// - const registeredAccounts = (await pxe.getRegisteredAccounts()).map(x => x.address); + const registeredAccounts = (await wallet.getAccounts()).map(x => x.item); for (const [account, name] of [ [alice, 'Alice'], [bob, 'Bob'], @@ -195,14 +195,14 @@ describe('e2e_sandbox_example', () => { expect(registeredAccounts.find(acc => acc.equals(bob))).toBeTruthy(); ////////////// FUND A NEW ACCOUNT WITH BANANA COIN ////////////// - const bananaCoinAddress = await getDeployedBananaCoinAddress(pxe); + const bananaCoinAddress = await getDeployedBananaCoinAddress(wallet); const bananaCoin = await TokenContract.at(bananaCoinAddress, wallet); const mintAmount = 10n ** 20n; await bananaCoin.methods.mint_to_private(alice, mintAmount).send({ from: fundedAccount.address }).wait(); ////////////// USE A NEW ACCOUNT TO SEND A TX AND PAY WITH BANANA COIN ////////////// const amountTransferToBob = 100n; - const bananaFPCAddress = await getDeployedBananaFPCAddress(pxe); + const bananaFPCAddress = await getDeployedBananaFPCAddress(wallet); const paymentMethod = new PrivateFeePaymentMethod(bananaFPCAddress, alice, wallet); const receiptForAlice = await bananaCoin.methods .transfer(bob, amountTransferToBob) @@ -223,7 +223,7 @@ describe('e2e_sandbox_example', () => { ////////////// USE A NEW ACCOUNT TO SEND A TX AND PAY VIA SPONSORED FPC ////////////// const amountTransferToAlice = 48n; - const sponsoredFPC = await getDeployedSponsoredFPCAddress(pxe); + const sponsoredFPC = await getDeployedSponsoredFPCAddress(wallet); const sponsoredPaymentMethod = new SponsoredFeePaymentMethod(sponsoredFPC); // The payment method can also be initialized as follows: // const sponsoredPaymentMethod = await SponsoredFeePaymentMethod.new(pxe); diff --git a/yarn-project/end-to-end/src/composed/e2e_token_bridge_tutorial_test.test.ts b/yarn-project/end-to-end/src/composed/e2e_token_bridge_tutorial_test.test.ts index 5200f422abc9..99e46cef954b 100644 --- a/yarn-project/end-to-end/src/composed/e2e_token_bridge_tutorial_test.test.ts +++ b/yarn-project/end-to-end/src/composed/e2e_token_bridge_tutorial_test.test.ts @@ -43,7 +43,8 @@ const setupSandbox = async () => { const pxe = await createPXEClient(PXE_URL); await waitForPXE(pxe); const node = createAztecNodeClient(AZTEC_NODE_URL); - return { pxe, node }; + const wallet = new TestWallet(pxe, node); + return { node, wallet }; }; async function deployTestERC20(): Promise { @@ -79,9 +80,8 @@ describe('e2e_cross_chain_messaging token_bridge_tutorial_test', () => { it('Deploys tokens & bridges to L1 & L2, mints & publicly bridges tokens', async () => { // docs:start:setup const logger = createLogger('aztec:token-bridge-tutorial'); - const { pxe, node } = await setupSandbox(); - const wallet = new TestWallet(pxe, node); - const [ownerAccount] = await getDeployedTestAccounts(pxe); + const { wallet, node } = await setupSandbox(); + const [ownerAccount] = await getDeployedTestAccounts(wallet); await wallet.createSchnorrAccount(ownerAccount.secret, ownerAccount.salt, ownerAccount.signingKey); const { address: ownerAztecAddress } = ownerAccount; const l1ContractAddresses = (await node.getNodeInfo()).l1ContractAddresses; diff --git a/yarn-project/end-to-end/src/composed/uniswap_trade_on_l1_from_l2.test.ts b/yarn-project/end-to-end/src/composed/uniswap_trade_on_l1_from_l2.test.ts index 21381e22d36b..49fd168d00ab 100644 --- a/yarn-project/end-to-end/src/composed/uniswap_trade_on_l1_from_l2.test.ts +++ b/yarn-project/end-to-end/src/composed/uniswap_trade_on_l1_from_l2.test.ts @@ -14,7 +14,6 @@ const testSetup = async (): Promise => { const { aztecNode, teardown: teardown_, - pxe, deployL1ContractsValues, wallet, accounts: [ownerAddress, sponsorAddress], @@ -28,7 +27,6 @@ const testSetup = async (): Promise => { return { aztecNode, - pxe, logger, l1Client, wallet, diff --git a/yarn-project/end-to-end/src/devnet/e2e_smoke.test.ts b/yarn-project/end-to-end/src/devnet/e2e_smoke.test.ts index b67f49e82650..080f3ca3250f 100644 --- a/yarn-project/end-to-end/src/devnet/e2e_smoke.test.ts +++ b/yarn-project/end-to-end/src/devnet/e2e_smoke.test.ts @@ -3,7 +3,6 @@ import { type EthAddress, FeeJuicePaymentMethodWithClaim, Fr, - type PXE, TxStatus, type WaitOpts, createAztecNodeClient, @@ -28,7 +27,7 @@ import { resolve } from 'node:path'; import { getACVMConfig } from '../fixtures/get_acvm_config.js'; import { getBBConfig } from '../fixtures/get_bb_config.js'; -import { getLogger, setupPXEService } from '../fixtures/utils.js'; +import { getLogger, setupPXEServiceAndGetWallet } from '../fixtures/utils.js'; const { AZTEC_NODE_URL, @@ -54,7 +53,6 @@ export const getLocalhost = () => .catch(() => 'localhost'); describe('End-to-end tests for devnet', () => { - let pxe: PXE; let pxeUrl: string; // needed for the CLI let node: AztecNode; let wallet: TestWallet; @@ -85,15 +83,15 @@ describe('End-to-end tests for devnet', () => { node = createAztecNodeClient(AZTEC_NODE_URL); const bbConfig = await getBBConfig(logger); const acvmConfig = await getACVMConfig(logger); - const svc = await setupPXEService(node, { + const svc = await setupPXEServiceAndGetWallet(node, { ...bbConfig, ...acvmConfig, proverEnabled: ['1', 'true'].includes(PXE_PROVER_ENABLED!), }); - pxe = svc.pxe; + wallet = svc.wallet; const nodeInfo = await node.getNodeInfo(); - const pxeInfo = await pxe.getPXEInfo(); + const pxeInfo = await wallet.getPXEInfo(); expect(nodeInfo.protocolContractAddresses.classRegistry).toEqual(pxeInfo.protocolContractAddresses.classRegistry); expect(nodeInfo.protocolContractAddresses.instanceRegistry).toEqual( @@ -108,7 +106,7 @@ describe('End-to-end tests for devnet', () => { const localhost = await getLocalhost(); pxeUrl = `http://${localhost}:${port}`; // start a server for the CLI to talk to - const jsonRpcServer = createNamespacedSafeJsonRpcServer({ pxe: [pxe, PXESchema] }); + const jsonRpcServer = createNamespacedSafeJsonRpcServer({ pxe: [wallet.getPxe(), PXESchema] }); const server = await startHttpRpcServer(jsonRpcServer, { port }); teardown = async () => { @@ -122,16 +120,15 @@ describe('End-to-end tests for devnet', () => { }; } else if (PXE_URL) { logger.info(`Using PXE_URL: ${PXE_URL}`); - pxe = createPXEClient(PXE_URL); + const pxe = createPXEClient(PXE_URL); node = createAztecNodeClient(PXE_URL); pxeUrl = PXE_URL; teardown = () => {}; + wallet = new TestWallet(pxe, node); } else { throw new Error('AZTEC_NODE_URL or PXE_URL must be set'); } - wallet = new TestWallet(pxe, node); - ({ l1ChainId, l1ContractAddresses: { feeJuiceAddress: feeJuiceL1 }, @@ -292,7 +289,7 @@ describe('End-to-end tests for devnet', () => { } async function advanceChainWithEmptyBlocks(wallet: TestWallet) { - const [fundedAccount] = await getDeployedTestAccounts(pxe); + const [fundedAccount] = await getDeployedTestAccounts(wallet); if (!fundedAccount) { throw new Error('A funded wallet is required to create dummy txs.'); } diff --git a/yarn-project/end-to-end/src/e2e_2_pxes.test.ts b/yarn-project/end-to-end/src/e2e_2_pxes.test.ts index 9b025c4b6eb0..66cf55e48197 100644 --- a/yarn-project/end-to-end/src/e2e_2_pxes.test.ts +++ b/yarn-project/end-to-end/src/e2e_2_pxes.test.ts @@ -1,6 +1,6 @@ // docs:start:import_aztecjs import type { InitialAccountData } from '@aztec/accounts/testing'; -import { type AztecAddress, type AztecNode, Fr, type Logger, type PXE, sleep } from '@aztec/aztec.js'; +import { type AztecAddress, type AztecNode, Fr, type Logger, sleep } from '@aztec/aztec.js'; import { TokenContract } from '@aztec/noir-contracts.js/Token'; // docs:end:import_aztecjs import { ChildContract } from '@aztec/noir-test-contracts.js/Child'; @@ -9,7 +9,7 @@ import { TestWallet } from '@aztec/test-wallet'; import { expect, jest } from '@jest/globals'; import { deployToken, expectTokenBalance, mintTokensToPrivate } from './fixtures/token_utils.js'; -import { setup, setupPXEService } from './fixtures/utils.js'; +import { setup, setupPXEServiceAndGetWallet } from './fixtures/utils.js'; const TIMEOUT = 300_000; @@ -17,7 +17,6 @@ describe('e2e_2_pxes', () => { jest.setTimeout(TIMEOUT); let aztecNode: AztecNode; - let pxeB: PXE; let walletA: TestWallet; let walletB: TestWallet; let accountAAddress: AztecAddress; @@ -39,9 +38,8 @@ describe('e2e_2_pxes', () => { // Account A is already deployed in setup - // Deploy accountB via pxeB. - ({ pxe: pxeB, teardown: teardownB } = await setupPXEService(aztecNode, {}, undefined, true)); - walletB = new TestWallet(pxeB, aztecNode); + // Deploy accountB via walletB. + ({ wallet: walletB, teardown: teardownB } = await setupPXEServiceAndGetWallet(aztecNode, {}, undefined, true)); const accountB = await walletB.createSchnorrAccount(initialFundedAccounts[1].secret, initialFundedAccounts[1].salt); accountBAddress = accountB.getAddress(); await accountB.deploy().wait(); @@ -67,7 +65,7 @@ describe('e2e_2_pxes', () => { const token = await deployToken(walletA, accountAAddress, initialBalance, logger); // Add token to PXE B (PXE A already has it because it was deployed through it) - await pxeB.registerContract(token); + await walletB.registerContract(token); // Check initial balances are as expected await expectTokenBalance(walletA, token, accountAAddress, initialBalance, logger); @@ -114,7 +112,7 @@ describe('e2e_2_pxes', () => { const childCompleteAddress = await deployChildContractViaServerA(); // Add Child to PXE B - await pxeB.registerContract({ + await walletB.registerContract({ artifact: ChildContract.artifact, instance: childCompleteAddress, }); @@ -141,7 +139,7 @@ describe('e2e_2_pxes', () => { const token = await deployToken(walletA, accountAAddress, userABalance, logger); // Add token to PXE B (PXE A already has it because it was deployed through it) - await pxeB.registerContract(token); + await walletB.registerContract(token); // Mint tokens to user B await mintTokensToPrivate(token, accountAAddress, accountBAddress, userBBalance); @@ -173,7 +171,7 @@ describe('e2e_2_pxes', () => { await contractWithWalletA.methods.transfer(accountBAddress, transferAmount1).send({ from: accountAAddress }).wait(); // now add the contract and check balances - await pxeB.registerContract(token); + await walletB.registerContract(token); await expectTokenBalance(walletA, token, accountAAddress, initialBalance - transferAmount1, logger); await expectTokenBalance(walletB, token, accountBAddress, transferAmount1, logger); }); @@ -189,7 +187,7 @@ describe('e2e_2_pxes', () => { await sharedAccountOnA.deploy().wait(); const sharedAccountAddress = sharedAccountOnA.getAddress(); - // Register the shared account on pxeB. + // Register the shared account on walletB. await walletB.createSchnorrAccount(sharedAccount.secret, sharedAccount.salt); // deploy the contract on PXE A @@ -217,7 +215,7 @@ describe('e2e_2_pxes', () => { // PXE-B had previously deferred the notes from A -> Shared, and Shared -> B // PXE-B adds the contract // PXE-B reprocesses the deferred notes, and sees the nullifier for A -> Shared - await pxeB.registerContract(token); + await walletB.registerContract(token); await expectTokenBalance(walletB, token, accountBAddress, transferAmount2, logger); await expectTokenBalance(walletB, token, sharedAccountAddress, transferAmount1 - transferAmount2, logger); }); 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 400e6d799ecd..58d1c9f1b0f7 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 @@ -14,8 +14,6 @@ import { Fr, GrumpkinScalar, type Logger, - type PXE, - type Wallet, getAccountContractAddress, } from '@aztec/aztec.js'; import { randomBytes } from '@aztec/foundation/crypto'; @@ -35,11 +33,10 @@ const itShouldBehaveLikeAnAccountContract = ( getAccountContract: (encryptionKey: GrumpkinScalar) => AccountContract, ) => { describe(`behaves like an account contract`, () => { - let pxe: PXE; let aztecNode: AztecNode; let logger: Logger; let teardown: () => Promise; - let wallet: Wallet; + let wallet: TestWallet; let completeAddress: CompleteAddress; let child: ChildContract; @@ -56,10 +53,10 @@ const itShouldBehaveLikeAnAccountContract = ( address, }; - ({ logger, pxe, teardown, aztecNode } = await setup(0, { initialFundedAccounts: [accountData] })); - wallet = new TestWalletInternals(pxe, aztecNode); + ({ logger, wallet, teardown, aztecNode } = await setup(0, { initialFundedAccounts: [accountData] })); + wallet = new TestWalletInternals(wallet.getPxe(), aztecNode); - const accountManager = await AccountManager.create(wallet, pxe, secret, accountContract, salt); + const accountManager = await AccountManager.create(wallet, wallet.getPxe(), secret, accountContract, salt); completeAddress = await accountManager.getCompleteAddress(); if (await accountManager.hasInitializer()) { // The account is pre-funded and can pay for its own fee. diff --git a/yarn-project/end-to-end/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts b/yarn-project/end-to-end/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts index 469e851e45cd..7183e678baaf 100644 --- a/yarn-project/end-to-end/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +++ b/yarn-project/end-to-end/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts @@ -3,7 +3,6 @@ import { type AztecNode, Fr, type Logger, - type PXE, type TxHash, computeSecretHash, createLogger, @@ -62,7 +61,6 @@ export class BlacklistTokenContractTest { private snapshotManager: ISnapshotManager; logger: Logger; wallet!: TestWallet; - pxe!: PXE; asset!: TokenBlacklistContract; tokenSim!: TokenSimulator; badAccount!: InvalidAccountContract; @@ -99,8 +97,7 @@ export class BlacklistTokenContractTest { await this.snapshotManager.snapshot( '3_accounts', deployAccounts(3, this.logger), - ({ deployedAccounts }, { pxe, cheatCodes, aztecNode, sequencer, wallet }) => { - this.pxe = pxe; + ({ deployedAccounts }, { cheatCodes, aztecNode, sequencer, wallet }) => { this.cheatCodes = cheatCodes; this.aztecNode = aztecNode; this.sequencer = sequencer; diff --git a/yarn-project/end-to-end/src/e2e_blacklist_token_contract/minting.test.ts b/yarn-project/end-to-end/src/e2e_blacklist_token_contract/minting.test.ts index 18637a6b8f98..a102b4766ca4 100644 --- a/yarn-project/end-to-end/src/e2e_blacklist_token_contract/minting.test.ts +++ b/yarn-project/end-to-end/src/e2e_blacklist_token_contract/minting.test.ts @@ -5,7 +5,7 @@ import { BlacklistTokenContractTest } from './blacklist_token_contract_test.js'; describe('e2e_blacklist_token_contract mint', () => { const t = new BlacklistTokenContractTest('mint'); - let { asset, tokenSim, adminAddress, otherAddress, blacklistedAddress, pxe } = t; + let { asset, tokenSim, adminAddress, otherAddress, blacklistedAddress, wallet } = t; beforeAll(async () => { await t.applyBaseSnapshots(); @@ -13,7 +13,7 @@ describe('e2e_blacklist_token_contract mint', () => { await t.applyMintSnapshot(); await t.setup(); // Have to destructure again to ensure we have latest refs. - ({ asset, tokenSim, adminAddress, otherAddress, blacklistedAddress, pxe } = t); + ({ asset, tokenSim, adminAddress, otherAddress, blacklistedAddress, wallet } = t); }, 600_000); afterAll(async () => { @@ -97,7 +97,7 @@ describe('e2e_blacklist_token_contract mint', () => { tokenSim.mintPrivate(adminAddress, amount); // 1 note should have been created containing `amount` of tokens - const visibleNotes = await pxe.getNotes({ txHash: receiptClaim.txHash, contractAddress: asset.address }); + const visibleNotes = await wallet.getNotes({ txHash: receiptClaim.txHash, contractAddress: asset.address }); expect(visibleNotes.length).toBe(1); expect(visibleNotes[0].note.items[0].toBigInt()).toBe(amount); }); 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 f1f832b3ad15..0bd738864ab8 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 @@ -7,7 +7,6 @@ import { ContractFunctionInteraction, Fr, type Logger, - type PXE, TxStatus, type Wallet, retryUntil, @@ -38,7 +37,6 @@ import { setup } from './fixtures/utils.js'; describe('e2e_block_building', () => { jest.setTimeout(20 * 60 * 1000); // 20 minutes - let pxe: PXE; let logger: Logger; let wallet: Wallet; @@ -63,7 +61,6 @@ describe('e2e_block_building', () => { let maybeAztecNodeAdmin: AztecNodeAdmin | undefined; ({ teardown, - pxe, logger, aztecNode, aztecNodeAdmin: maybeAztecNodeAdmin, @@ -178,7 +175,7 @@ describe('e2e_block_building', () => { // Assert all contracts got deployed const isContractDeployed = async (address: AztecAddress) => - !!(await pxe.getContractMetadata(address)).contractInstance; + !!(await wallet.getContractMetadata(address)).contractInstance; const areDeployed = await Promise.all(receipts.map(r => isContractDeployed(r.contract.address))); expect(areDeployed).toEqual(times(TX_COUNT, () => true)); }); @@ -284,7 +281,6 @@ describe('e2e_block_building', () => { beforeAll(async () => { ({ teardown, - pxe, logger, wallet, accounts: [ownerAddress], @@ -411,7 +407,6 @@ describe('e2e_block_building', () => { beforeAll(async () => { ({ teardown, - pxe, logger, wallet, accounts: [ownerAddress], @@ -452,7 +447,7 @@ describe('e2e_block_building', () => { expect(privateLogs.length).toBe(3); // The first two logs are encrypted. - const events = await pxe.getPrivateEvents( + const events = await wallet.getPrivateEvents( testContract.address, TestContract.events.ExampleEvent, rct.blockNumber!, @@ -481,7 +476,7 @@ describe('e2e_block_building', () => { // Regression for https://github.com/AztecProtocol/aztec-packages/issues/7918 it('publishes two empty blocks', async () => { - ({ teardown, pxe, logger, aztecNode } = await setup(0, { + ({ teardown, wallet, logger, aztecNode } = await setup(0, { minTxsPerBlock: 0, skipProtocolContracts: true, })); @@ -496,7 +491,7 @@ describe('e2e_block_building', () => { skipProtocolContracts: true, numberOfInitialFundedAccounts: 1, }); - ({ teardown, pxe, logger, aztecNode, wallet } = context); + ({ teardown, logger, aztecNode, wallet } = context); await sleep(1000); const [accountData] = context.initialFundedAccounts; @@ -508,7 +503,6 @@ describe('e2e_block_building', () => { it('can simulate public txs while building a block', async () => { ({ teardown, - pxe, logger, aztecNode, wallet, @@ -550,7 +544,6 @@ describe('e2e_block_building', () => { }); ({ teardown, - pxe, logger, aztecNode, wallet, diff --git a/yarn-project/end-to-end/src/e2e_bot.test.ts b/yarn-project/end-to-end/src/e2e_bot.test.ts index 5ceb93feffed..30fe6cb6a63a 100644 --- a/yarn-project/end-to-end/src/e2e_bot.test.ts +++ b/yarn-project/end-to-end/src/e2e_bot.test.ts @@ -1,16 +1,17 @@ import { getInitialTestAccountsData } from '@aztec/accounts/testing'; -import { type AztecNode, Fr, type PXE } from '@aztec/aztec.js'; +import { type AztecNode, Fr } from '@aztec/aztec.js'; import type { CheatCodes } from '@aztec/aztec/testing'; import { AmmBot, Bot, type BotConfig, SupportedTokenContracts, getBotDefaultConfig } from '@aztec/bot'; import { AVM_MAX_PROCESSABLE_L2_GAS, MAX_PROCESSABLE_DA_GAS_PER_BLOCK } from '@aztec/constants'; import { SecretValue } from '@aztec/foundation/config'; import { bufferToHex } from '@aztec/foundation/string'; import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client'; +import type { TestWallet } from '@aztec/test-wallet'; import { getPrivateKeyFromIndex, setup } from './fixtures/utils.js'; describe('e2e_bot', () => { - let pxe: PXE; + let wallet: TestWallet; let aztecNode: AztecNode; let teardown: () => Promise; let aztecNodeAdmin: AztecNodeAdmin | undefined; @@ -23,7 +24,7 @@ describe('e2e_bot', () => { const setupResult = await setup(1, { initialFundedAccounts }); ({ teardown, - pxe, + wallet, aztecNode, aztecNodeAdmin, cheatCodes, @@ -41,7 +42,7 @@ describe('e2e_bot', () => { followChain: 'PENDING', ammTxs: false, }; - bot = await Bot.create(config, { node: aztecNode, pxe }); + bot = await Bot.create(config, wallet, aztecNode); }); it('sends token transfers from the bot', async () => { @@ -65,7 +66,7 @@ describe('e2e_bot', () => { it('reuses the same account and token contract', async () => { const { defaultAccountAddress, token, recipient } = bot; - const bot2 = await Bot.create(config, { node: aztecNode, pxe }); + const bot2 = await Bot.create(config, wallet, aztecNode); expect(bot2.defaultAccountAddress.toString()).toEqual(defaultAccountAddress.toString()); expect(bot2.token.address.toString()).toEqual(token.address.toString()); expect(bot2.recipient.toString()).toEqual(recipient.toString()); @@ -74,7 +75,8 @@ describe('e2e_bot', () => { it('sends token from the bot using PrivateToken', async () => { const easyBot = await Bot.create( { ...config, contract: SupportedTokenContracts.PrivateTokenContract }, - { node: aztecNode, pxe }, + wallet, + aztecNode, ); const { recipient: recipientBefore } = await easyBot.getBalances(); @@ -93,7 +95,7 @@ describe('e2e_bot', () => { followChain: 'PENDING', ammTxs: true, }; - bot = await AmmBot.create(config, { node: aztecNode, pxe }); + bot = await AmmBot.create(config, wallet, aztecNode, undefined); }); it('swaps tokens from the bot', async () => { @@ -133,7 +135,7 @@ describe('e2e_bot', () => { // in end-to-end/src/e2e_cross_chain_messaging/l1_to_l2.test.ts for context on this test. it('creates bot after inbox drift', async () => { await cheatCodes.rollup.advanceInboxInProgress(10); - await Bot.create(config, { node: aztecNode, nodeAdmin: aztecNodeAdmin, pxe }); + await Bot.create(config, wallet, aztecNode, aztecNodeAdmin); }, 300_000); }); }); diff --git a/yarn-project/end-to-end/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts b/yarn-project/end-to-end/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts index 67fd4e2592a0..90081dcd966a 100644 --- a/yarn-project/end-to-end/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +++ b/yarn-project/end-to-end/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts @@ -1,5 +1,5 @@ import type { AztecNodeConfig } from '@aztec/aztec-node'; -import { AztecAddress, type AztecNode, EthAddress, type Logger, type PXE, createLogger } from '@aztec/aztec.js'; +import { AztecAddress, type AztecNode, EthAddress, type Logger, createLogger } from '@aztec/aztec.js'; import { CheatCodes } from '@aztec/aztec/testing'; import { type DeployL1ContractsArgs, @@ -33,7 +33,6 @@ export class CrossChainMessagingTest { private snapshotManager: ISnapshotManager; logger: Logger; aztecNode!: AztecNode; - pxe!: PXE; aztecNodeConfig!: AztecNodeConfig; aztecNodeAdmin!: AztecNodeAdmin; ctx!: SubsystemsContext; @@ -70,9 +69,9 @@ export class CrossChainMessagingTest { async setup() { this.ctx = await this.snapshotManager.setup(); this.aztecNode = this.ctx.aztecNode; - this.pxe = this.ctx.pxe; + this.wallet = this.ctx.wallet; this.aztecNodeConfig = this.ctx.aztecNodeConfig; - this.cheatCodes = await CheatCodes.create(this.aztecNodeConfig.l1RpcUrls, this.pxe, this.aztecNode); + this.cheatCodes = await CheatCodes.create(this.aztecNodeConfig.l1RpcUrls, this.wallet, this.aztecNode); this.deployL1ContractsValues = this.ctx.deployL1ContractsValues; this.aztecNodeAdmin = this.ctx.aztecNode; } @@ -88,15 +87,14 @@ export class CrossChainMessagingTest { } async applyBaseSnapshots() { - // Note that we are using the same `pxe`, `aztecNodeConfig` and `aztecNode` across all snapshots. + // Note that we are using the same `wallet`, `aztecNodeConfig` and `aztecNode` across all snapshots. // This is to not have issues with different networks. await this.snapshotManager.snapshot( '3_accounts', deployAccounts(3, this.logger), - ({ deployedAccounts }, { pxe, wallet, aztecNodeConfig, aztecNode }) => { + ({ deployedAccounts }, { wallet, aztecNodeConfig, aztecNode }) => { [this.ownerAddress, this.user1Address, this.user2Address] = deployedAccounts.map(a => a.address); - this.pxe = pxe; this.wallet = wallet; this.aztecNode = aztecNode; this.aztecNodeConfig = aztecNodeConfig; @@ -123,7 +121,6 @@ export class CrossChainMessagingTest { this.logger.verbose(`Setting up cross chain harness...`); this.crossChainTestHarness = await CrossChainTestHarness.new( this.aztecNode, - this.pxe, this.l1Client, this.wallet, this.ownerAddress, @@ -158,7 +155,6 @@ export class CrossChainMessagingTest { this.crossChainTestHarness = new CrossChainTestHarness( this.aztecNode, - this.pxe, this.logger, this.l2Token, this.l2Bridge, diff --git a/yarn-project/end-to-end/src/e2e_cross_chain_messaging/token_bridge_private.test.ts b/yarn-project/end-to-end/src/e2e_cross_chain_messaging/token_bridge_private.test.ts index 1994fa38f2e1..cea1a4fbab3a 100644 --- a/yarn-project/end-to-end/src/e2e_cross_chain_messaging/token_bridge_private.test.ts +++ b/yarn-project/end-to-end/src/e2e_cross_chain_messaging/token_bridge_private.test.ts @@ -1,15 +1,27 @@ -import { Fr } from '@aztec/aztec.js'; +import { AztecAddress, type AztecNode, EthAddress, Fr, type Logger } from '@aztec/aztec.js'; import { CheatCodes } from '@aztec/aztec/testing'; import { RollupContract } from '@aztec/ethereum'; +import type { TokenContract } from '@aztec/noir-contracts.js/Token'; +import type { TokenBridgeContract } from '@aztec/noir-contracts.js/TokenBridge'; import { computeL2ToL1MembershipWitness } from '@aztec/stdlib/messaging'; +import type { TestWallet } from '@aztec/test-wallet'; +import type { CrossChainTestHarness } from '../shared/cross_chain_test_harness.js'; import { CrossChainMessagingTest } from './cross_chain_messaging_test.js'; describe('e2e_cross_chain_messaging token_bridge_private', () => { const t = new CrossChainMessagingTest('token_bridge_private'); - let { crossChainTestHarness, ethAccount, aztecNode, logger, ownerAddress, l2Bridge, l2Token, wallet, user2Address } = - t; + let crossChainTestHarness: CrossChainTestHarness; + let ethAccount: EthAddress; + let aztecNode: AztecNode; + let logger: Logger; + let ownerAddress: AztecAddress; + let l2Bridge: TokenBridgeContract; + let l2Token: TokenContract; + let wallet: TestWallet; + let user2Address: AztecAddress; + let rollup: RollupContract; let cheatCodes: CheatCodes; @@ -17,20 +29,15 @@ describe('e2e_cross_chain_messaging token_bridge_private', () => { await t.applyBaseSnapshots(); await t.setup(); // Have to destructure again to ensure we have latest refs. - ({ crossChainTestHarness, wallet, user2Address } = t); - - ethAccount = crossChainTestHarness.ethAccount; - aztecNode = crossChainTestHarness.aztecNode; - logger = crossChainTestHarness.logger; - ownerAddress = crossChainTestHarness.ownerAddress; - l2Bridge = crossChainTestHarness.l2Bridge; - l2Token = crossChainTestHarness.l2Token; + ({ crossChainTestHarness, ethAccount, aztecNode, logger, ownerAddress, l2Bridge, l2Token, wallet, user2Address } = + t); + rollup = new RollupContract( crossChainTestHarness!.l1Client, crossChainTestHarness!.l1ContractAddresses.rollupAddress, ); - cheatCodes = await CheatCodes.create(t.aztecNodeConfig.l1RpcUrls, t.pxe, t.aztecNode); + cheatCodes = await CheatCodes.create(t.aztecNodeConfig.l1RpcUrls, t.wallet, t.aztecNode); }, 300_000); afterEach(async () => { diff --git a/yarn-project/end-to-end/src/e2e_crowdfunding_and_claim.test.ts b/yarn-project/end-to-end/src/e2e_crowdfunding_and_claim.test.ts index 05768ac9f6ae..bbf8324d1c74 100644 --- a/yarn-project/end-to-end/src/e2e_crowdfunding_and_claim.test.ts +++ b/yarn-project/end-to-end/src/e2e_crowdfunding_and_claim.test.ts @@ -1,4 +1,4 @@ -import { Fr, type Logger, type PXE, type UniqueNote, deriveKeys } from '@aztec/aztec.js'; +import { Fr, type Logger, type UniqueNote, deriveKeys } from '@aztec/aztec.js'; import { CheatCodes } from '@aztec/aztec/testing'; import { ClaimContract } from '@aztec/noir-contracts.js/Claim'; import { CrowdfundingContract } from '@aztec/noir-contracts.js/Crowdfunding'; @@ -45,7 +45,6 @@ describe('e2e_crowdfunding_and_claim', () => { let crowdfundingSecretKey; let crowdfundingPublicKeys; - let pxe: PXE; let cheatCodes: CheatCodes; let deadline: number; // end of crowdfunding period @@ -56,7 +55,6 @@ describe('e2e_crowdfunding_and_claim', () => { cheatCodes, teardown, logger, - pxe, wallet, accounts: [operatorAddress, donor1Address, donor2Address], } = await setup(3)); @@ -97,7 +95,7 @@ describe('e2e_crowdfunding_and_claim', () => { deadline, ); const crowdfundingInstance = await crowdfundingDeployment.getInstance(); - await pxe.registerAccount(crowdfundingSecretKey, await computePartialAddress(crowdfundingInstance)); + await wallet.registerAccount(crowdfundingSecretKey, await computePartialAddress(crowdfundingInstance)); crowdfundingContract = await crowdfundingDeployment.send({ from: operatorAddress }).deployed(); logger.info(`Crowdfunding contract deployed at ${crowdfundingContract.address}`); @@ -153,7 +151,7 @@ describe('e2e_crowdfunding_and_claim', () => { .wait(); // Get the notes emitted by the Crowdfunding contract and check that only 1 was emitted (the UintNote) - const notes = await pxe.getNotes({ + const notes = await wallet.getNotes({ txHash: donateTxReceipt.txHash, contractAddress: crowdfundingContract.address, }); @@ -217,7 +215,10 @@ describe('e2e_crowdfunding_and_claim', () => { .wait(); // Get the notes emitted by the Crowdfunding contract and check that only 1 was emitted (the UintNote) - const notes = await pxe.getNotes({ contractAddress: crowdfundingContract.address, txHash: donateTxReceipt.txHash }); + const notes = await wallet.getNotes({ + contractAddress: crowdfundingContract.address, + txHash: donateTxReceipt.txHash, + }); const filtered = notes.filter(x => x.contractAddress.equals(crowdfundingContract.address)); expect(filtered!.length).toEqual(1); @@ -253,7 +254,7 @@ describe('e2e_crowdfunding_and_claim', () => { .call_create_note(arbitraryValue, operatorAddress, arbitraryStorageSlot, false) .send({ from: operatorAddress }) .wait(); - const notes = await pxe.getNotes({ txHash: receipt.txHash, contractAddress: testContract.address }); + const notes = await wallet.getNotes({ txHash: receipt.txHash, contractAddress: testContract.address }); expect(notes.length).toEqual(1); note = processUniqueNote(notes[0]); } diff --git a/yarn-project/end-to-end/src/e2e_deploy_contract/deploy_method.test.ts b/yarn-project/end-to-end/src/e2e_deploy_contract/deploy_method.test.ts index d179374b0ec3..860b1585f853 100644 --- a/yarn-project/end-to-end/src/e2e_deploy_contract/deploy_method.test.ts +++ b/yarn-project/end-to-end/src/e2e_deploy_contract/deploy_method.test.ts @@ -4,7 +4,6 @@ import { BatchCall, Fr, type Logger, - type PXE, type Wallet, createAztecNodeClient, createPXEClient, @@ -22,14 +21,13 @@ import { DeployTest } from './deploy_test.js'; describe('e2e_deploy_contract deploy method', () => { const t = new DeployTest('deploy method'); - let pxe: PXE; let logger: Logger; let wallet: Wallet; let aztecNode: AztecNode; let defaultAccountAddress: AztecAddress; beforeAll(async () => { - ({ pxe, logger, wallet, aztecNode, defaultAccountAddress } = await t.setup()); + ({ logger, wallet, aztecNode, defaultAccountAddress } = await t.setup()); }); afterAll(() => t.teardown()); @@ -54,7 +52,8 @@ describe('e2e_deploy_contract deploy method', () => { await contract.methods.increment_public_value(owner, 84).send({ from: defaultAccountAddress }).wait(); expect(await contract.methods.get_public_value(owner).simulate({ from: defaultAccountAddress })).toEqual(84n); expect( - (await pxe.getContractClassMetadata(contract.instance.currentContractClassId)).isContractClassPubliclyRegistered, + (await wallet.getContractClassMetadata(contract.instance.currentContractClassId)) + .isContractClassPubliclyRegistered, ).toBeTrue(); }); diff --git a/yarn-project/end-to-end/src/e2e_deploy_contract/deploy_test.ts b/yarn-project/end-to-end/src/e2e_deploy_contract/deploy_test.ts index bab05ae4fdb9..8c29a8e86a5c 100644 --- a/yarn-project/end-to-end/src/e2e_deploy_contract/deploy_test.ts +++ b/yarn-project/end-to-end/src/e2e_deploy_contract/deploy_test.ts @@ -5,7 +5,6 @@ import { type ContractBase, Fr, type Logger, - type PXE, type PublicKeys, type Wallet, createLogger, @@ -13,6 +12,7 @@ import { } from '@aztec/aztec.js'; import type { StatefulTestContract } from '@aztec/noir-test-contracts.js/StatefulTest'; import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client'; +import type { TestWallet } from '@aztec/test-wallet'; import { type ISnapshotManager, createSnapshotManager, deployAccounts } from '../fixtures/snapshot_manager.js'; @@ -21,8 +21,7 @@ const { E2E_DATA_PATH: dataPath } = process.env; export class DeployTest { private snapshotManager: ISnapshotManager; public logger: Logger; - public pxe!: PXE; - public wallet!: Wallet; + public wallet!: TestWallet; public defaultAccountAddress!: AztecAddress; public aztecNode!: AztecNode; public aztecNodeAdmin!: AztecNodeAdmin; @@ -35,7 +34,7 @@ export class DeployTest { async setup() { await this.applyInitialAccountSnapshot(); const context = await this.snapshotManager.setup(); - ({ pxe: this.pxe, aztecNode: this.aztecNode, wallet: this.wallet } = context); + ({ aztecNode: this.aztecNode, wallet: this.wallet } = context); this.aztecNodeAdmin = context.aztecNode; return this; } @@ -75,7 +74,7 @@ export class DeployTest { } async registerRandomAccount(): Promise { - const completeAddress = await this.pxe.registerAccount(Fr.random(), Fr.random()); + const completeAddress = await this.wallet.registerAccount(Fr.random(), Fr.random()); return completeAddress.address; } } diff --git a/yarn-project/end-to-end/src/e2e_deploy_contract/legacy.test.ts b/yarn-project/end-to-end/src/e2e_deploy_contract/legacy.test.ts index 1fa720ef5b58..19d4cfe27e21 100644 --- a/yarn-project/end-to-end/src/e2e_deploy_contract/legacy.test.ts +++ b/yarn-project/end-to-end/src/e2e_deploy_contract/legacy.test.ts @@ -4,28 +4,26 @@ import { type DeployOptions, Fr, type Logger, - type PXE, TxStatus, - type Wallet, getContractInstanceFromInstantiationParams, } from '@aztec/aztec.js'; import { TokenContractArtifact } from '@aztec/noir-contracts.js/Token'; import { StatefulTestContract } from '@aztec/noir-test-contracts.js/StatefulTest'; import { TestContractArtifact } from '@aztec/noir-test-contracts.js/Test'; import { TX_ERROR_EXISTING_NULLIFIER } from '@aztec/stdlib/tx'; +import type { TestWallet } from '@aztec/test-wallet'; import { DeployTest } from './deploy_test.js'; describe('e2e_deploy_contract legacy', () => { const t = new DeployTest('legacy'); - let pxe: PXE; let logger: Logger; - let wallet: Wallet; + let wallet: TestWallet; let defaultAccountAddress: AztecAddress; beforeAll(async () => { - ({ pxe, logger, wallet, defaultAccountAddress } = await t.setup()); + ({ logger, wallet, defaultAccountAddress } = await t.setup()); }); afterAll(() => t.teardown()); @@ -46,8 +44,8 @@ describe('e2e_deploy_contract legacy', () => { .send({ from: defaultAccountAddress, contractAddressSalt: salt }) .wait({ wallet }); expect(receipt.contract.address).toEqual(deploymentData.address); - expect((await pxe.getContractMetadata(deploymentData.address)).contractInstance).toBeDefined(); - expect((await pxe.getContractMetadata(deploymentData.address)).isContractPublished).toBeTrue(); + expect((await wallet.getContractMetadata(deploymentData.address)).contractInstance).toBeDefined(); + expect((await wallet.getContractMetadata(deploymentData.address)).isContractPublished).toBeTrue(); }); /** @@ -130,7 +128,7 @@ describe('e2e_deploy_contract legacy', () => { expect(badTxReceipt.status).toEqual(TxStatus.APP_LOGIC_REVERTED); - const { isContractClassPubliclyRegistered } = await pxe.getContractClassMetadata( + const { isContractClassPubliclyRegistered } = await wallet.getContractClassMetadata( (await badDeploy.getInstance()).currentContractClassId, ); // But the bad tx did not deploy 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 6cf5acdfb80a..907ec8fb2bec 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 @@ -1,15 +1,15 @@ -import { type AztecAddress, BatchCall, Fr, type Logger, type PXE, type Wallet, deriveKeys } from '@aztec/aztec.js'; +import { type AztecAddress, BatchCall, Fr, type Logger, deriveKeys } from '@aztec/aztec.js'; import { EscrowContract } from '@aztec/noir-contracts.js/Escrow'; import { TokenContract } from '@aztec/noir-contracts.js/Token'; import { computePartialAddress } from '@aztec/stdlib/contract'; import type { PublicKeys } from '@aztec/stdlib/keys'; +import type { TestWallet } from '@aztec/test-wallet'; import { expectTokenBalance, mintTokensToPrivate } from './fixtures/token_utils.js'; import { setup } from './fixtures/utils.js'; describe('e2e_escrow_contract', () => { - let pxe: PXE; - let wallet: Wallet; + let wallet: TestWallet; let logger: Logger; let teardown: () => Promise; @@ -26,7 +26,6 @@ describe('e2e_escrow_contract', () => { // Setup environment ({ teardown, - pxe, wallet, accounts: [owner, recipient], logger, @@ -38,7 +37,7 @@ describe('e2e_escrow_contract', () => { escrowPublicKeys = (await deriveKeys(escrowSecretKey)).publicKeys; const escrowDeployment = EscrowContract.deployWithPublicKeys(escrowPublicKeys, wallet, owner); const escrowInstance = await escrowDeployment.getInstance(); - await pxe.registerAccount(escrowSecretKey, await computePartialAddress(escrowInstance)); + await wallet.registerAccount(escrowSecretKey, await computePartialAddress(escrowInstance)); escrowContract = await escrowDeployment.send({ from: owner }).deployed(); logger.info(`Escrow contract deployed at ${escrowContract.address}`); diff --git a/yarn-project/end-to-end/src/e2e_fees/fees_test.ts b/yarn-project/end-to-end/src/e2e_fees/fees_test.ts index eba199b1c0c3..54ae1b433452 100644 --- a/yarn-project/end-to-end/src/e2e_fees/fees_test.ts +++ b/yarn-project/end-to-end/src/e2e_fees/fees_test.ts @@ -1,5 +1,5 @@ import { SchnorrAccountContract } from '@aztec/accounts/schnorr'; -import { type AztecAddress, type AztecNode, type Logger, type PXE, createLogger, sleep } from '@aztec/aztec.js'; +import { type AztecAddress, type AztecNode, type Logger, createLogger, sleep } from '@aztec/aztec.js'; import { CheatCodes } from '@aztec/aztec/testing'; import { type DeployL1ContractsArgs, RollupContract, createExtendedL1Client } from '@aztec/ethereum'; import { ChainMonitor } from '@aztec/ethereum/test'; @@ -52,7 +52,6 @@ export class FeesTest { private accounts: AztecAddress[] = []; public logger: Logger; - public pxe!: PXE; public aztecNode!: AztecNode; public cheatCodes!: CheatCodes; @@ -183,12 +182,11 @@ export class FeesTest { await this.snapshotManager.snapshot( 'initial_accounts', deployAccounts(this.numberOfAccounts, this.logger), - async ({ deployedAccounts }, { wallet, pxe, aztecNode, aztecNodeConfig }) => { - this.pxe = pxe; + async ({ deployedAccounts }, { wallet, aztecNode, aztecNodeConfig }) => { this.wallet = wallet; this.aztecNode = aztecNode; this.gasSettings = GasSettings.default({ maxFeesPerGas: (await this.aztecNode.getCurrentBaseFees()).mul(2) }); - this.cheatCodes = await CheatCodes.create(aztecNodeConfig.l1RpcUrls, pxe, aztecNode); + this.cheatCodes = await CheatCodes.create(aztecNodeConfig.l1RpcUrls, wallet, aztecNode); this.accounts = deployedAccounts.map(a => a.address); this.accounts.forEach((a, i) => this.logger.verbose(`Account ${i} address: ${a}`)); [this.aliceAddress, this.bobAddress, this.sequencerAddress] = this.accounts.slice(0, 3); @@ -238,7 +236,6 @@ export class FeesTest { this.feeJuiceBridgeTestHarness = await FeeJuicePortalTestingHarnessFactory.create({ aztecNode: context.aztecNode, aztecNodeAdmin: context.aztecNode, - pxeService: context.pxe, l1Client: context.deployL1ContractsValues.l1Client, wallet: this.wallet, logger: this.logger, @@ -281,7 +278,7 @@ export class FeesTest { 'fpc_setup', async context => { const feeJuiceContract = this.feeJuiceBridgeTestHarness.feeJuice; - expect((await context.pxe.getContractMetadata(feeJuiceContract.address)).isContractPublished).toBe(true); + expect((await context.wallet.getContractMetadata(feeJuiceContract.address)).isContractPublished).toBe(true); const bananaCoin = this.bananaCoin; const bananaFPC = await FPCContract.deploy(this.wallet, bananaCoin.address, this.fpcAdmin) @@ -349,9 +346,9 @@ export class FeesTest { 'sponsored_fpc_setup', async context => { const feeJuiceContract = this.feeJuiceBridgeTestHarness.feeJuice; - expect((await context.pxe.getContractMetadata(feeJuiceContract.address)).isContractPublished).toBe(true); + expect((await context.wallet.getContractMetadata(feeJuiceContract.address)).isContractPublished).toBe(true); - const sponsoredFPC = await setupSponsoredFPC(context.pxe); + const sponsoredFPC = await setupSponsoredFPC(this.wallet); this.logger.info(`SponsoredFPC at ${sponsoredFPC.address}`); return { diff --git a/yarn-project/end-to-end/src/e2e_nested_contract/nested_contract_test.ts b/yarn-project/end-to-end/src/e2e_nested_contract/nested_contract_test.ts index c1ea4be11935..8a81fdc1c909 100644 --- a/yarn-project/end-to-end/src/e2e_nested_contract/nested_contract_test.ts +++ b/yarn-project/end-to-end/src/e2e_nested_contract/nested_contract_test.ts @@ -1,4 +1,4 @@ -import { AztecAddress, type AztecNode, type Logger, type PXE, type Wallet, createLogger } from '@aztec/aztec.js'; +import { AztecAddress, type AztecNode, type Logger, type Wallet, createLogger } from '@aztec/aztec.js'; import { ChildContract } from '@aztec/noir-test-contracts.js/Child'; import { ParentContract } from '@aztec/noir-test-contracts.js/Parent'; @@ -17,7 +17,6 @@ export class NestedContractTest { logger: Logger; wallet!: Wallet; defaultAccountAddress!: AztecAddress; - pxe!: PXE; aztecNode!: AztecNode; parentContract!: ParentContract; @@ -40,10 +39,9 @@ export class NestedContractTest { await this.snapshotManager.snapshot( 'accounts', deployAccounts(this.numberOfAccounts, this.logger), - ({ deployedAccounts }, { pxe, wallet, aztecNode }) => { + ({ deployedAccounts }, { wallet, aztecNode }) => { this.wallet = wallet; [{ address: this.defaultAccountAddress }] = deployedAccounts; - this.pxe = pxe; this.aztecNode = aztecNode; return Promise.resolve(); }, diff --git a/yarn-project/end-to-end/src/e2e_offchain_effect.test.ts b/yarn-project/end-to-end/src/e2e_offchain_effect.test.ts index cbe2c9bae83a..ab8c16dcf610 100644 --- a/yarn-project/end-to-end/src/e2e_offchain_effect.test.ts +++ b/yarn-project/end-to-end/src/e2e_offchain_effect.test.ts @@ -1,4 +1,4 @@ -import { AztecAddress, type AztecNode, Fr, type PXE, type Wallet } from '@aztec/aztec.js'; +import { AztecAddress, type AztecNode, Fr, type Wallet } from '@aztec/aztec.js'; import { PRIVATE_LOG_CIPHERTEXT_LEN } from '@aztec/constants'; import { OffchainEffectContract, type TestEvent } from '@aztec/noir-test-contracts.js/OffchainEffect'; import { MessageContext } from '@aztec/stdlib/logs'; @@ -13,7 +13,6 @@ const TIMEOUT = 120_000; describe('e2e_offchain_effect', () => { let contract1: OffchainEffectContract; let contract2: OffchainEffectContract; - let pxe: PXE; let aztecNode: AztecNode; jest.setTimeout(TIMEOUT); @@ -27,7 +26,6 @@ describe('e2e_offchain_effect', () => { teardown, wallet, accounts: [defaultAccountAddress], - pxe, aztecNode, } = await setup(1)); contract1 = await OffchainEffectContract.deploy(wallet).send({ from: defaultAccountAddress }).deployed(); @@ -104,7 +102,7 @@ describe('e2e_offchain_effect', () => { .simulate({ from: defaultAccountAddress }); // Get the event from PXE - const events = await pxe.getPrivateEvents( + const events = await wallet.getPrivateEvents( contract1.address, OffchainEffectContract.events.TestEvent, blockNumber!, diff --git a/yarn-project/end-to-end/src/e2e_pending_note_hashes_contract.test.ts b/yarn-project/end-to-end/src/e2e_pending_note_hashes_contract.test.ts index a2cf58b91344..867e4e29be2e 100644 --- a/yarn-project/end-to-end/src/e2e_pending_note_hashes_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_pending_note_hashes_contract.test.ts @@ -1,4 +1,4 @@ -import { type AztecAddress, type AztecNode, Fr, type Logger, type PXE, type Wallet } from '@aztec/aztec.js'; +import { type AztecAddress, type AztecNode, Fr, type Logger } from '@aztec/aztec.js'; import { MAX_NOTE_HASHES_PER_CALL, MAX_NOTE_HASHES_PER_TX, @@ -6,14 +6,14 @@ import { MAX_NOTE_HASH_READ_REQUESTS_PER_TX, } from '@aztec/constants'; import { PendingNoteHashesContract } from '@aztec/noir-test-contracts.js/PendingNoteHashes'; +import type { TestWallet } from '@aztec/test-wallet'; import { setup } from './fixtures/utils.js'; describe('e2e_pending_note_hashes_contract', () => { let aztecNode: AztecNode; - let wallet: Wallet; + let wallet: TestWallet; let owner: AztecAddress; - let pxe: PXE; let logger: Logger; let teardown: () => Promise; let contract: PendingNoteHashesContract; @@ -24,7 +24,6 @@ describe('e2e_pending_note_hashes_contract', () => { aztecNode, wallet, logger, - pxe, accounts: [owner], } = await setup(1)); }); @@ -302,7 +301,7 @@ describe('e2e_pending_note_hashes_contract', () => { // Then emit another note log with the same counter as the one above, but with value 5 const txReceipt = await deployedContract.methods.test_emit_bad_note_log(owner, sender).send({ from: owner }).wait(); - const notes = await pxe.getNotes({ txHash: txReceipt.txHash, contractAddress: deployedContract.address }); + const notes = await wallet.getNotes({ txHash: txReceipt.txHash, contractAddress: deployedContract.address }); expect(notes.length).toBe(1); }); diff --git a/yarn-project/end-to-end/src/e2e_sequencer_config.test.ts b/yarn-project/end-to-end/src/e2e_sequencer_config.test.ts index 2db37451be19..33a6c48bb0b0 100644 --- a/yarn-project/end-to-end/src/e2e_sequencer_config.test.ts +++ b/yarn-project/end-to-end/src/e2e_sequencer_config.test.ts @@ -1,8 +1,9 @@ import { getInitialTestAccountsData } from '@aztec/accounts/testing'; -import type { AztecNode, PXE, TxReceipt } from '@aztec/aztec.js'; +import type { AztecNode, TxReceipt } from '@aztec/aztec.js'; import { Bot, type BotConfig, getBotDefaultConfig } from '@aztec/bot'; import type { Logger } from '@aztec/foundation/log'; import type { SequencerClient } from '@aztec/sequencer-client'; +import type { TestWallet } from '@aztec/test-wallet'; import { jest } from '@jest/globals'; import 'jest-extended'; @@ -16,7 +17,7 @@ describe('e2e_sequencer_config', () => { let sequencer: SequencerClient | undefined; let config: BotConfig; let bot: Bot; - let pxe: PXE; + let wallet: TestWallet; let aztecNode: AztecNode; let logger: Logger; @@ -29,7 +30,7 @@ describe('e2e_sequencer_config', () => { const manaTarget = 21e10; beforeAll(async () => { const initialFundedAccounts = await getInitialTestAccountsData(); - ({ teardown, sequencer, aztecNode, logger, pxe } = await setup(1, { + ({ teardown, sequencer, aztecNode, logger, wallet } = await setup(1, { maxL2BlockGas: manaTarget * 2, manaTarget: BigInt(manaTarget), initialFundedAccounts, @@ -40,7 +41,7 @@ describe('e2e_sequencer_config', () => { ammTxs: false, txMinedWaitSeconds: 12, }; - bot = await Bot.create(config, { node: aztecNode, pxe }); + bot = await Bot.create(config, wallet, aztecNode, undefined); }); afterAll(() => teardown()); diff --git a/yarn-project/end-to-end/src/e2e_synching.test.ts b/yarn-project/end-to-end/src/e2e_synching.test.ts index 723fd874c28f..7550685b5909 100644 --- a/yarn-project/end-to-end/src/e2e_synching.test.ts +++ b/yarn-project/end-to-end/src/e2e_synching.test.ts @@ -52,7 +52,6 @@ import { RollupAbi } from '@aztec/l1-artifacts'; import { SchnorrHardcodedAccountContract } from '@aztec/noir-contracts.js/SchnorrHardcodedAccount'; import { TokenContract } from '@aztec/noir-contracts.js/Token'; import { SpamContract } from '@aztec/noir-test-contracts.js/Spam'; -import type { PXEService } from '@aztec/pxe/server'; import { SequencerPublisher, SequencerPublisherMetrics } from '@aztec/sequencer-client'; import type { AztecAddress } from '@aztec/stdlib/aztec-address'; import { CommitteeAttestationsAndSigners, L2Block } from '@aztec/stdlib/block'; @@ -66,7 +65,7 @@ import { getContract } from 'viem'; import { DEFAULT_BLOB_SINK_PORT } from './fixtures/fixtures.js'; import { mintTokensToPrivate } from './fixtures/token_utils.js'; -import { type EndToEndContext, getPrivateKeyFromIndex, setup, setupPXEService } from './fixtures/utils.js'; +import { type EndToEndContext, getPrivateKeyFromIndex, setup, setupPXEServiceAndGetWallet } from './fixtures/utils.js'; const SALT = 420; const AZTEC_GENERATE_TEST_DATA = !!process.env.AZTEC_GENERATE_TEST_DATA; @@ -101,7 +100,6 @@ type VariantDefinition = { */ class TestVariant { private logger: Logger = createLogger(`test_variant`); - private pxe!: PXEService; private token!: TokenContract; private spam!: SpamContract; @@ -122,10 +120,6 @@ class TestVariant { this.txComplexity = def.txComplexity; } - setPXE(pxe: PXEService) { - this.pxe = pxe; - } - setWallet(wallet: TestWallet) { this.wallet = wallet; } @@ -160,8 +154,8 @@ class TestVariant { } async setup(accounts: InitialAccountData[] = []) { - if (this.pxe === undefined) { - throw new Error('Undefined PXE'); + if (this.wallet === undefined) { + throw new Error('Undefined wallet'); } this.accounts = accounts.map(acc => acc.address); @@ -189,8 +183,8 @@ class TestVariant { } async createAndSendTxs() { - if (!this.pxe) { - throw new Error('Undefined PXE'); + if (!this.wallet) { + throw new Error('Undefined wallet'); } if (this.txComplexity == TxComplexity.Deployment) { @@ -323,7 +317,6 @@ describe('e2e_synching', () => { // This is to keep the setup more stable, so as long as the setup is less than 100 L1 txs, changing the setup should not break the setup const { teardown, - pxe, sequencer, aztecNode, wallet, @@ -336,7 +329,6 @@ describe('e2e_synching', () => { l2StartTime: START_TIME + 200 * ETHEREUM_SLOT_DURATION, numberOfInitialFundedAccounts: variant.txCount + 1, }); - variant.setPXE(pxe as PXEService); variant.setWallet(wallet); // Deploy a token, such that we could use it @@ -390,7 +382,6 @@ describe('e2e_synching', () => { aztecNode, sequencer, watcher, - pxe, wallet, blobSink, initialFundedAccounts, @@ -477,7 +468,7 @@ describe('e2e_synching', () => { } await alternativeSync( - { deployL1ContractsValues, cheatCodes, config, logger, pxe, initialFundedAccounts, wallet }, + { deployL1ContractsValues, cheatCodes, config, logger, initialFundedAccounts, wallet }, variant, ); @@ -547,10 +538,7 @@ describe('e2e_synching', () => { const aztecNode = await AztecNodeService.createAndSync(opts.config!); const sequencer = aztecNode.getSequencer(); - const { pxe } = await setupPXEService(aztecNode!); - - variant.setPXE(pxe); - const wallet = new TestWallet(pxe, aztecNode); + const { wallet } = await setupPXEServiceAndGetWallet(aztecNode!); variant.setWallet(wallet); const defaultAccountAddress = (await variant.deployAccounts(opts.initialFundedAccounts!.slice(0, 1)))[0]; @@ -692,8 +680,8 @@ describe('e2e_synching', () => { expect(await aztecNode.getBlockNumber()).toBeLessThan(blockBeforePrune); // We need to start the pxe after the re-org for now, because it won't handle it otherwise - const { pxe } = await setupPXEService(aztecNode!); - variant.setPXE(pxe); + const { wallet } = await setupPXEServiceAndGetWallet(aztecNode!); + variant.setWallet(wallet); const blockBefore = await aztecNode.getBlock(await aztecNode.getBlockNumber()); @@ -750,9 +738,8 @@ describe('e2e_synching', () => { const aztecNode = await AztecNodeService.createAndSync(opts.config!); const sequencer = aztecNode.getSequencer(); - const { pxe } = await setupPXEService(aztecNode!); - - variant.setPXE(pxe); + const { wallet: newWallet } = await setupPXEServiceAndGetWallet(aztecNode!); + variant.setWallet(newWallet); const blockBefore = await aztecNode.getBlock(await aztecNode.getBlockNumber()); diff --git a/yarn-project/end-to-end/src/fixtures/e2e_prover_test.ts b/yarn-project/end-to-end/src/fixtures/e2e_prover_test.ts index ddc16f33453e..fe34ef93a642 100644 --- a/yarn-project/end-to-end/src/fixtures/e2e_prover_test.ts +++ b/yarn-project/end-to-end/src/fixtures/e2e_prover_test.ts @@ -1,6 +1,6 @@ import type { InitialAccountData } from '@aztec/accounts/testing'; import { type Archiver, createArchiver } from '@aztec/archiver'; -import { AztecAddress, type AztecNode, EthAddress, type Logger, type PXE, createLogger } from '@aztec/aztec.js'; +import { AztecAddress, type AztecNode, EthAddress, type Logger, createLogger } from '@aztec/aztec.js'; import { CheatCodes } from '@aztec/aztec/testing'; import { BBCircuitVerifier, @@ -16,7 +16,6 @@ import { SecretValue } from '@aztec/foundation/config'; import { FeeAssetHandlerAbi } from '@aztec/l1-artifacts'; import { TokenContract } from '@aztec/noir-contracts.js/Token'; import { type ProverNode, type ProverNodeConfig, createProverNode } from '@aztec/prover-node'; -import type { PXEService } from '@aztec/pxe/server'; import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client'; import { TestWallet } from '@aztec/test-wallet'; import { getGenesisValues } from '@aztec/world-state/testing'; @@ -34,12 +33,12 @@ import { deployAccounts, publicDeployAccounts, } from './snapshot_manager.js'; -import { getPrivateKeyFromIndex, getSponsoredFPCAddress, setupPXEService } from './utils.js'; +import { getPrivateKeyFromIndex, getSponsoredFPCAddress, setupPXEServiceAndGetWallet } from './utils.js'; const { E2E_DATA_PATH: dataPath } = process.env; type ProvenSetup = { - pxe: PXE; + wallet: TestWallet; teardown: () => Promise; }; @@ -63,7 +62,6 @@ export class FullProverTest { tokenSim!: TokenSimulator; aztecNode!: AztecNode; aztecNodeAdmin!: AztecNodeAdmin; - pxe!: PXEService; cheatCodes!: CheatCodes; blobSink!: BlobSinkServer; private provenComponents: ProvenSetup[] = []; @@ -161,7 +159,6 @@ export class FullProverTest { this.simulatedProverNode = this.context.proverNode!; ({ - pxe: this.pxe, aztecNode: this.aztecNode, deployL1ContractsValues: this.l1Contracts, cheatCodes: this.cheatCodes, @@ -211,7 +208,7 @@ export class FullProverTest { this.logger.verbose(`Main setup completed, initializing full prover PXE, Node, and Prover Node`); for (let i = 0; i < 2; i++) { - const result = await setupPXEService( + const { wallet: provenWallet, teardown: provenTeardown } = await setupPXEServiceAndGetWallet( this.aztecNode, { proverEnabled: this.realProofs, @@ -222,9 +219,7 @@ export class FullProverTest { true, ); this.logger.debug(`Contract address ${this.fakeProofsAsset.address}`); - await result.pxe.registerContract(this.fakeProofsAsset); - - const provenWallet = new TestWallet(result.pxe, this.aztecNode); + await provenWallet.registerContract(this.fakeProofsAsset); for (let i = 0; i < 2; i++) { await provenWallet.createSchnorrAccount(this.deployedAccounts[i].secret, this.deployedAccounts[i].salt); @@ -233,8 +228,8 @@ export class FullProverTest { const asset = await TokenContract.at(this.fakeProofsAsset.address, provenWallet); this.provenComponents.push({ - pxe: result.pxe, - teardown: result.teardown, + wallet: provenWallet, + teardown: provenTeardown, }); this.provenAssets.push(asset); } diff --git a/yarn-project/end-to-end/src/fixtures/snapshot_manager.ts b/yarn-project/end-to-end/src/fixtures/snapshot_manager.ts index 04675846f2c1..8dccc95ab8de 100644 --- a/yarn-project/end-to-end/src/fixtures/snapshot_manager.ts +++ b/yarn-project/end-to-end/src/fixtures/snapshot_manager.ts @@ -31,7 +31,7 @@ import { createLogger } from '@aztec/foundation/log'; import { resolver, reviver } from '@aztec/foundation/serialize'; import { TestDateProvider } from '@aztec/foundation/timer'; import type { ProverNode } from '@aztec/prover-node'; -import { type PXEService, createPXEService, getPXEServiceConfig } from '@aztec/pxe/server'; +import { createPXEService, getPXEServiceConfig } from '@aztec/pxe/server'; import type { SequencerClient } from '@aztec/sequencer-client'; import { tryStop } from '@aztec/stdlib/interfaces/server'; import { getConfigEnvVars as getTelemetryConfig, initTelemetryClient } from '@aztec/telemetry-client'; @@ -68,7 +68,6 @@ export type SubsystemsContext = { bbConfig: any; aztecNode: AztecNodeService; aztecNodeConfig: AztecNodeConfig; - pxe: PXEService; wallet: TestWallet; deployL1ContractsValues: DeployL1ContractsReturnType; proverNode?: ProverNode; @@ -449,7 +448,7 @@ async function setupFromFresh( pxeConfig.proverEnabled = !!opts.realProofs; const pxe = await createPXEService(aztecNode, pxeConfig); const wallet = new TestWallet(pxe, aztecNode); - const cheatCodes = await CheatCodes.create(aztecNodeConfig.l1RpcUrls, pxe, aztecNode); + const cheatCodes = await CheatCodes.create(aztecNodeConfig.l1RpcUrls, wallet, aztecNode); if (statePath) { writeFileSync(`${statePath}/aztec_node_config.json`, JSON.stringify(aztecNodeConfig, resolver)); @@ -460,7 +459,6 @@ async function setupFromFresh( aztecNodeConfig, anvil, aztecNode, - pxe, wallet, sequencer: aztecNode.getSequencer()!, acvmConfig, @@ -578,13 +576,12 @@ async function setupFromState(statePath: string, logger: Logger): Promise = {}, logger = getLogger(), useLogSuffix = false, ): Promise<{ /** - * The PXE instance. + * The wallet instance. */ - pxe: PXEService; + wallet: TestWallet; /** * Logger instance named as the current test. */ @@ -195,8 +189,10 @@ export async function setupPXEService( const teardown = configuredDataDirectory ? () => Promise.resolve() : () => tryRmDir(pxeServiceConfig.dataDirectory!); + const wallet = new TestWallet(pxe, aztecNode); + return { - pxe, + wallet, logger, teardown, }; @@ -236,12 +232,12 @@ async function setupWithRemoteEnvironment( rollupVersion, }; const ethCheatCodes = new EthCheatCodes(config.l1RpcUrls); - const cheatCodes = await CheatCodes.create(config.l1RpcUrls, pxeClient!, aztecNode); + const wallet = new TestWallet(pxeClient, aztecNode); + const cheatCodes = await CheatCodes.create(config.l1RpcUrls, wallet, aztecNode); const teardown = () => Promise.resolve(); logger.verbose('Populating wallet from already registered accounts...'); - const initialFundedAccounts = await getDeployedTestAccounts(pxeClient); - const wallet = new TestWallet(pxeClient, aztecNode); + const initialFundedAccounts = await getDeployedTestAccounts(wallet); if (initialFundedAccounts.length < numberOfAccounts) { throw new Error(`Required ${numberOfAccounts} accounts. Found ${initialFundedAccounts.length}.`); @@ -260,7 +256,6 @@ async function setupWithRemoteEnvironment( aztecNodeAdmin: undefined, sequencer: undefined, proverNode: undefined, - pxe: pxeClient, deployL1ContractsValues, config, initialFundedAccounts, @@ -337,8 +332,6 @@ export type EndToEndContext = { proverNode: ProverNode | undefined; /** A client to the sequencer service (undefined if connected to remote environment) */ sequencer: SequencerClient | undefined; - /** The Private eXecution Environment (PXE). */ - pxe: PXE; /** Return values from deployL1Contracts function. */ deployL1ContractsValues: DeployL1ContractsReturnType; /** The Aztec Node configuration. */ @@ -655,9 +648,9 @@ export async function setup( } logger.verbose('Creating a pxe...'); - const { pxe, teardown: pxeTeardown } = await setupPXEService(aztecNode!, pxeOpts, logger); + const { wallet, teardown: pxeTeardown } = await setupPXEServiceAndGetWallet(aztecNode!, pxeOpts, logger); - const cheatCodes = await CheatCodes.create(config.l1RpcUrls, pxe!, aztecNode); + const cheatCodes = await CheatCodes.create(config.l1RpcUrls, wallet, aztecNode); if ( (opts.aztecTargetCommitteeSize && opts.aztecTargetCommitteeSize > 0) || @@ -670,7 +663,6 @@ export async function setup( await cheatCodes.rollup.setupEpoch(); await cheatCodes.rollup.debugRollup(); } - const wallet = new TestWallet(pxe, aztecNode); let accounts: AztecAddress[] = []; // Below we continue with what we described in the long comment on line 571. if (numberOfAccounts === 0) { @@ -736,7 +728,6 @@ export async function setup( mockGossipSubNetwork, prefilledPublicData, proverNode, - pxe, sequencer: sequencerClient, teardown, telemetryClient: telemetry, @@ -866,7 +857,7 @@ export async function expectMappingDelta( } /** - * Computes the address of the "canonical" SponosoredFPCContract. This is not a protocol contract + * Computes the address of the "canonical" SponsoredFPCContract. This is not a protocol contract * but by conventions its address is computed with a salt of 0. * @returns The address of the sponsored FPC contract */ @@ -879,7 +870,7 @@ export function getSponsoredFPCInstance(): Promise } /** - * Computes the address of the "canonical" SponosoredFPCContract. This is not a protocol contract + * Computes the address of the "canonical" SponsoredFPCContract. This is not a protocol contract * but by conventions its address is computed with a salt of 0. * @returns The address of the sponsored FPC contract */ @@ -891,22 +882,22 @@ export async function getSponsoredFPCAddress() { /** * Deploy a sponsored FPC contract to a running instance. */ -export async function setupSponsoredFPC(pxe: PXE) { +export async function setupSponsoredFPC(wallet: Wallet) { const instance = await getContractInstanceFromInstantiationParams(SponsoredFPCContract.artifact, { salt: new Fr(SPONSORED_FPC_SALT), }); - await pxe.registerContract({ instance, artifact: SponsoredFPCContract.artifact }); + await wallet.registerContract({ instance, artifact: SponsoredFPCContract.artifact }); getLogger().info(`SponsoredFPC: ${instance.address}`); return instance; } /** * Registers the SponsoredFPC in this PXE instance - * @param pxe - The pxe client + * @param wallet - The wallet */ -export async function registerSponsoredFPC(pxe: PXE | Wallet): Promise { - await pxe.registerContract({ instance: await getSponsoredFPCInstance(), artifact: SponsoredFPCContract.artifact }); +export async function registerSponsoredFPC(wallet: Wallet): Promise { + await wallet.registerContract({ instance: await getSponsoredFPCInstance(), artifact: SponsoredFPCContract.artifact }); } export async function waitForProvenChain(node: AztecNode, targetBlock?: number, timeoutSec = 60, intervalSec = 1) { 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 374a6bc00eb8..b12680e1fc0d 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 @@ -4,7 +4,6 @@ import { AztecAddress, type AztecNode, Fr, - type PXE, TxStatus, createAztecNodeClient, createPXEClient, @@ -37,7 +36,6 @@ describe('guides/dapp/testing', () => { }); describe('token contract with initial accounts', () => { - let pxe: PXE; let aztecNode: AztecNode; let wallet: TestWallet; let ownerAddress: AztecAddress; @@ -46,10 +44,10 @@ describe('guides/dapp/testing', () => { beforeEach(async () => { // docs:start:use-existing-wallets - pxe = createPXEClient(PXE_URL); + const pxe = createPXEClient(PXE_URL); aztecNode = createAztecNodeClient(AZTEC_NODE_URL); - const [owner, recipient] = await getDeployedTestAccounts(pxe); wallet = new TestWallet(pxe, aztecNode); + const [owner, recipient] = await getDeployedTestAccounts(wallet); await wallet.createSchnorrAccount(owner.secret, owner.salt); await wallet.createSchnorrAccount(recipient.secret, recipient.salt); ownerAddress = owner.address; @@ -75,7 +73,6 @@ describe('guides/dapp/testing', () => { }); describe('assertions', () => { - let pxe: PXE; let aztecNode: AztecNode; let wallet: TestWallet; let ownerAddress: AztecAddress; @@ -86,10 +83,10 @@ describe('guides/dapp/testing', () => { let ownerSlot: Fr; beforeAll(async () => { - pxe = createPXEClient(PXE_URL); + const pxe = createPXEClient(PXE_URL); aztecNode = createAztecNodeClient(AZTEC_NODE_URL); - const [owner, recipient] = await getDeployedTestAccounts(pxe); wallet = new TestWallet(pxe, aztecNode); + const [owner, recipient] = await getDeployedTestAccounts(wallet); await wallet.createSchnorrAccount(owner.secret, owner.salt); await wallet.createSchnorrAccount(recipient.secret, recipient.salt); ownerAddress = owner.address; @@ -104,7 +101,7 @@ describe('guides/dapp/testing', () => { await mintTokensToPrivate(token, ownerAddress, ownerAddress, mintAmount); // docs:start:calc-slot - cheats = await CheatCodes.create(ETHEREUM_HOSTS.split(','), pxe, aztecNode); + cheats = await CheatCodes.create(ETHEREUM_HOSTS.split(','), wallet, aztecNode); // The balances mapping is indexed by user address ownerSlot = await cheats.aztec.computeSlotInMap(TokenContract.storage.balances.slot, ownerAddress); // docs:end:calc-slot @@ -113,7 +110,7 @@ describe('guides/dapp/testing', () => { it('checks private storage', async () => { // docs:start:private-storage await token.methods.sync_private_state().simulate({ from: ownerAddress }); - const notes = await pxe.getNotes({ + const notes = await wallet.getNotes({ recipient: ownerAddress, contractAddress: token.address, storageSlot: ownerSlot, diff --git a/yarn-project/end-to-end/src/shared/cross_chain_test_harness.ts b/yarn-project/end-to-end/src/shared/cross_chain_test_harness.ts index 94898276f584..a6d1727853d8 100644 --- a/yarn-project/end-to-end/src/shared/cross_chain_test_harness.ts +++ b/yarn-project/end-to-end/src/shared/cross_chain_test_harness.ts @@ -11,7 +11,6 @@ import { type L2AmountClaim, type L2AmountClaimWithRecipient, type Logger, - type PXE, type SiblingPath, type TxReceipt, type Wallet, @@ -131,7 +130,6 @@ export type CrossChainContext = { export class CrossChainTestHarness { static async new( aztecNode: AztecNode, - pxeService: PXE, l1Client: ExtendedViemWalletClient, wallet: Wallet, ownerAddress: AztecAddress, @@ -154,7 +152,6 @@ export class CrossChainTestHarness { return new CrossChainTestHarness( aztecNode, - pxeService, logger, token, bridge, @@ -174,8 +171,6 @@ export class CrossChainTestHarness { constructor( /** Aztec node instance. */ public aztecNode: AztecNode, - /** Private eXecution Environment (PXE). */ - public pxeService: PXE, /** Logger. */ public logger: Logger, diff --git a/yarn-project/end-to-end/src/shared/gas_portal_test_harness.ts b/yarn-project/end-to-end/src/shared/gas_portal_test_harness.ts index af2e8140cd01..8c97fd32eb4d 100644 --- a/yarn-project/end-to-end/src/shared/gas_portal_test_harness.ts +++ b/yarn-project/end-to-end/src/shared/gas_portal_test_harness.ts @@ -7,7 +7,6 @@ import { type L1TokenManager, type L2AmountClaim, type Logger, - type PXE, type Wallet, retryUntil, } from '@aztec/aztec.js'; @@ -27,7 +26,6 @@ export interface IGasBridgingTestHarness { export interface FeeJuicePortalTestingHarnessFactoryConfig { aztecNode: AztecNode; aztecNodeAdmin?: AztecNodeAdmin; - pxeService: PXE; l1Client: ExtendedViemWalletClient; wallet: Wallet; logger: Logger; @@ -38,7 +36,7 @@ export class FeeJuicePortalTestingHarnessFactory { private constructor(private config: FeeJuicePortalTestingHarnessFactoryConfig) {} private async createReal() { - const { aztecNode, aztecNodeAdmin, pxeService, l1Client, wallet, logger } = this.config; + const { aztecNode, aztecNodeAdmin, l1Client, wallet, logger } = this.config; const ethAccount = EthAddress.fromString((await l1Client.getAddresses())[0]); const l1ContractAddresses = (await aztecNode.getNodeInfo()).l1ContractAddresses; @@ -55,7 +53,7 @@ export class FeeJuicePortalTestingHarnessFactory { return new GasBridgingTestHarness( aztecNode, aztecNodeAdmin, - pxeService, + wallet, logger, gasL2, ethAccount, @@ -85,8 +83,8 @@ export class GasBridgingTestHarness implements IGasBridgingTestHarness { public aztecNode: AztecNode, /** Aztec node admin interface */ public aztecNodeAdmin: AztecNodeAdmin | undefined, - /** Private eXecution Environment (PXE). */ - public pxeService: PXE, + /** Wallet. */ + public wallet: Wallet, /** Logger. */ public logger: Logger, diff --git a/yarn-project/end-to-end/src/shared/uniswap_l1_l2.ts b/yarn-project/end-to-end/src/shared/uniswap_l1_l2.ts index 16fcf9a4ceb8..345e848855f4 100644 --- a/yarn-project/end-to-end/src/shared/uniswap_l1_l2.ts +++ b/yarn-project/end-to-end/src/shared/uniswap_l1_l2.ts @@ -4,7 +4,6 @@ import { EthAddress, Fr, type Logger, - type PXE, computeAuthWitMessageHash, generateClaimSecret, } from '@aztec/aztec.js'; @@ -43,8 +42,6 @@ const TIMEOUT = 360_000; export type UniswapSetupContext = { /** Aztec Node instance */ aztecNode: AztecNode; - /** The Private eXecution Environment (PXE). */ - pxe: PXE; /** Logger instance named as the current test. */ logger: Logger; /** The L1 wallet client, extended with public actions. */ @@ -75,7 +72,6 @@ export const uniswapL1L2TestSuite = ( const DAI_ADDRESS: EthAddress = EthAddress.fromString('0x6B175474E89094C44Da98b954EedeAC495271d0F'); let aztecNode: AztecNode; - let pxe: PXE; let logger: Logger; let l1Client: ExtendedViemWalletClient; @@ -102,7 +98,7 @@ export const uniswapL1L2TestSuite = ( let cheatCodes: CheatCodes; let version: number; beforeAll(async () => { - ({ aztecNode, pxe, logger, l1Client, wallet, ownerAddress, sponsorAddress, deployL1ContractsValues, cheatCodes } = + ({ aztecNode, logger, l1Client, wallet, ownerAddress, sponsorAddress, deployL1ContractsValues, cheatCodes } = await setup()); if (Number(await l1Client.getBlockNumber()) < expectedForkBlockNumber) { @@ -121,7 +117,6 @@ export const uniswapL1L2TestSuite = ( logger.info('Deploying DAI Portal, initializing and deploying l2 contract...'); daiCrossChainHarness = await CrossChainTestHarness.new( aztecNode, - pxe, deployL1ContractsValues.l1Client, wallet, ownerAddress, @@ -132,7 +127,6 @@ export const uniswapL1L2TestSuite = ( logger.info('Deploying WETH Portal, initializing and deploying l2 contract...'); wethCrossChainHarness = await CrossChainTestHarness.new( aztecNode, - pxe, l1Client, wallet, ownerAddress, diff --git a/yarn-project/end-to-end/src/spartan/1tps.test.ts b/yarn-project/end-to-end/src/spartan/1tps.test.ts index bfd5a1e85736..5f34d0fb9f32 100644 --- a/yarn-project/end-to-end/src/spartan/1tps.test.ts +++ b/yarn-project/end-to-end/src/spartan/1tps.test.ts @@ -1,14 +1,5 @@ // TODO(#11825) finalize (probably once we have nightly tests setup for GKE) & enable in bootstrap.sh -import { - type PXE, - ProvenTx, - SentTx, - SponsoredFeePaymentMethod, - Tx, - createAztecNodeClient, - readFieldCompressedString, - sleep, -} from '@aztec/aztec.js'; +import { ProvenTx, SentTx, SponsoredFeePaymentMethod, Tx, readFieldCompressedString, sleep } from '@aztec/aztec.js'; import { Fr } from '@aztec/foundation/fields'; import { createLogger } from '@aztec/foundation/log'; @@ -16,7 +7,11 @@ import { jest } from '@jest/globals'; import type { ChildProcess } from 'child_process'; import { getSponsoredFPCAddress } from '../fixtures/utils.js'; -import { type TestAccounts, deploySponsoredTestAccounts, startCompatiblePXE } from './setup_test_wallets.js'; +import { + type TestAccounts, + createWalletAndAztecNodeClient, + deploySponsoredTestAccounts, +} from './setup_test_wallets.js'; import { setupEnvironment, startPortForwardForRPC } from './utils.js'; const config = { ...setupEnvironment(process.env), REAL_VERIFIER: true }; // TODO: remove REAL_VERIFIER: true @@ -30,7 +25,6 @@ describe('token transfer test', () => { let testAccounts: TestAccounts; const forwardProcesses: ChildProcess[] = []; - let pxe: PXE; let cleanup: undefined | (() => Promise); afterAll(async () => { @@ -44,11 +38,15 @@ describe('token transfer test', () => { forwardProcesses.push(aztecRpcProcess); const rpcUrl = `http://127.0.0.1:${aztecRpcPort}`; - ({ pxe, cleanup } = await startCompatiblePXE(rpcUrl, config.REAL_VERIFIER, logger)); - const node = createAztecNodeClient(rpcUrl); + const { + wallet, + aztecNode, + cleanup: _cleanup, + } = await createWalletAndAztecNodeClient(rpcUrl, config.REAL_VERIFIER, logger); + cleanup = _cleanup; // Setup wallets - testAccounts = await deploySponsoredTestAccounts(pxe, node, MINT_AMOUNT, logger); + testAccounts = await deploySponsoredTestAccounts(wallet, aztecNode, MINT_AMOUNT, logger); expect(ROUNDS).toBeLessThanOrEqual(MINT_AMOUNT); }); diff --git a/yarn-project/end-to-end/src/spartan/4epochs.test.ts b/yarn-project/end-to-end/src/spartan/4epochs.test.ts index 47b99b7c48b5..ed6001015025 100644 --- a/yarn-project/end-to-end/src/spartan/4epochs.test.ts +++ b/yarn-project/end-to-end/src/spartan/4epochs.test.ts @@ -1,20 +1,19 @@ -import { - type AztecNode, - type PXE, - SponsoredFeePaymentMethod, - createAztecNodeClient, - readFieldCompressedString, -} from '@aztec/aztec.js'; +import { type AztecNode, SponsoredFeePaymentMethod, readFieldCompressedString } from '@aztec/aztec.js'; import { RollupCheatCodes } from '@aztec/aztec/testing'; import { getL1ContractsConfigEnvVars } from '@aztec/ethereum'; import { EthCheatCodesWithState } from '@aztec/ethereum/test'; import { createLogger } from '@aztec/foundation/log'; +import { TestWallet } from '@aztec/test-wallet'; import { jest } from '@jest/globals'; import type { ChildProcess } from 'child_process'; import { getSponsoredFPCAddress } from '../fixtures/utils.js'; -import { type TestAccounts, deploySponsoredTestAccounts, startCompatiblePXE } from './setup_test_wallets.js'; +import { + type TestAccounts, + createWalletAndAztecNodeClient, + deploySponsoredTestAccounts, +} from './setup_test_wallets.js'; import { setupEnvironment, startPortForwardForEthereum, startPortForwardForRPC } from './utils.js'; const config = { ...setupEnvironment(process.env), REAL_VERIFIER: true }; // TODO: remove REAL_VERIFIER: true @@ -34,8 +33,8 @@ describe('token transfer test', () => { let testAccounts: TestAccounts; let ETHEREUM_HOSTS: string[]; const forwardProcesses: ChildProcess[] = []; - let pxe: PXE; - let node: AztecNode; + let wallet: TestWallet; + let aztecNode: AztecNode; let cleanup: undefined | (() => Promise); afterAll(async () => { @@ -53,11 +52,10 @@ describe('token transfer test', () => { const rpcUrl = `http://127.0.0.1:${aztecRpcPort}`; ETHEREUM_HOSTS = [`http://127.0.0.1:${ethereumPort}`]; - ({ pxe, cleanup } = await startCompatiblePXE(rpcUrl, config.REAL_VERIFIER, logger)); - node = createAztecNodeClient(rpcUrl); + ({ wallet, aztecNode, cleanup } = await createWalletAndAztecNodeClient(rpcUrl, config.REAL_VERIFIER, logger)); // Setup wallets - testAccounts = await deploySponsoredTestAccounts(pxe, node, MINT_AMOUNT, logger); + testAccounts = await deploySponsoredTestAccounts(wallet, aztecNode, MINT_AMOUNT, logger); expect(ROUNDS).toBeLessThanOrEqual(MINT_AMOUNT); logger.info(`Tested wallets setup: ${ROUNDS} < ${MINT_AMOUNT}`); diff --git a/yarn-project/end-to-end/src/spartan/n_tps.test.ts b/yarn-project/end-to-end/src/spartan/n_tps.test.ts index f12020c19f75..35c222079ab3 100644 --- a/yarn-project/end-to-end/src/spartan/n_tps.test.ts +++ b/yarn-project/end-to-end/src/spartan/n_tps.test.ts @@ -1,10 +1,15 @@ -import { Fr, type PXE, ProvenTx, Tx, createAztecNodeClient, readFieldCompressedString, sleep } from '@aztec/aztec.js'; +import { type AztecNode, Fr, ProvenTx, Tx, readFieldCompressedString, sleep } from '@aztec/aztec.js'; import { createLogger } from '@aztec/foundation/log'; +import { TestWallet } from '@aztec/test-wallet'; import { jest } from '@jest/globals'; import type { ChildProcess } from 'child_process'; -import { type TestAccounts, deploySponsoredTestAccounts, startCompatiblePXE } from './setup_test_wallets.js'; +import { + type TestAccounts, + createWalletAndAztecNodeClient, + deploySponsoredTestAccounts, +} from './setup_test_wallets.js'; import { setupEnvironment, startPortForwardForRPC } from './utils.js'; const config = { ...setupEnvironment(process.env), REAL_VERIFIER: true }; // TODO: remove REAL_VERIFIER: true @@ -19,7 +24,9 @@ describe('sustained 10 TPS test', () => { const TOTAL_TXS = TEST_DURATION_SECONDS * TARGET_TPS; let testAccounts: TestAccounts; - let pxe: PXE; + let wallet: TestWallet; + let aztecNode: AztecNode; + let cleanup: undefined | (() => Promise); const forwardProcesses: ChildProcess[] = []; @@ -34,12 +41,11 @@ describe('sustained 10 TPS test', () => { forwardProcesses.push(aztecRpcProcess); const rpcUrl = `http://127.0.0.1:${aztecRpcPort}`; - ({ pxe, cleanup } = await startCompatiblePXE(rpcUrl, config.REAL_VERIFIER, logger)); - const node = createAztecNodeClient(rpcUrl); + ({ wallet, aztecNode, cleanup } = await createWalletAndAztecNodeClient(rpcUrl, config.REAL_VERIFIER, logger)); // Setup wallets logger.info('deploying test wallets'); - testAccounts = await deploySponsoredTestAccounts(pxe, node, MINT_AMOUNT, logger); + testAccounts = await deploySponsoredTestAccounts(wallet, aztecNode, MINT_AMOUNT, logger); logger.info(`testAccounts ready`); logger.info( diff --git a/yarn-project/end-to-end/src/spartan/reorg.test.ts b/yarn-project/end-to-end/src/spartan/reorg.test.ts index 8a35581a1ea9..5ab36fb965af 100644 --- a/yarn-project/end-to-end/src/spartan/reorg.test.ts +++ b/yarn-project/end-to-end/src/spartan/reorg.test.ts @@ -1,17 +1,18 @@ // CREATE_CHAOS_MESH should be set to true to run this test -import { type AztecNode, type PXE, createAztecNodeClient, sleep } from '@aztec/aztec.js'; +import { type AztecNode, sleep } from '@aztec/aztec.js'; import { RollupCheatCodes } from '@aztec/aztec/testing'; import { EthCheatCodesWithState } from '@aztec/ethereum/test'; import { createLogger } from '@aztec/foundation/log'; +import { TestWallet } from '@aztec/test-wallet'; import { expect, jest } from '@jest/globals'; import type { ChildProcess } from 'child_process'; import { type TestAccounts, + createWalletAndAztecNodeClient, deploySponsoredTestAccounts, performTransfers, - startCompatiblePXE, } from './setup_test_wallets.js'; import { applyProverFailure, setupEnvironment, startPortForwardForEthereum, startPortForwardForRPC } from './utils.js'; @@ -43,10 +44,9 @@ describe('reorg test', () => { let ETHEREUM_HOSTS: string[]; const forwardProcesses: ChildProcess[] = []; let rpcUrl: string; - + let wallet: TestWallet; let testAccounts: TestAccounts; - let pxe: PXE; - let node: AztecNode; + let aztecNode: AztecNode; let cleanup: undefined | (() => Promise); afterAll(async () => { @@ -63,9 +63,8 @@ describe('reorg test', () => { rpcUrl = `http://127.0.0.1:${aztecRpcPort}`; ETHEREUM_HOSTS = [`http://127.0.0.1:${ethPort}`]; - node = createAztecNodeClient(rpcUrl); - ({ pxe, cleanup } = await startCompatiblePXE(rpcUrl, config.REAL_VERIFIER, debugLogger)); - testAccounts = await deploySponsoredTestAccounts(pxe, node, MINT_AMOUNT, debugLogger); + ({ wallet, aztecNode, cleanup } = await createWalletAndAztecNodeClient(rpcUrl, config.REAL_VERIFIER, debugLogger)); + testAccounts = await deploySponsoredTestAccounts(wallet, aztecNode, MINT_AMOUNT, debugLogger); }); it('survives a reorg', async () => { @@ -107,9 +106,10 @@ describe('reorg test', () => { await sleep(30 * 1000); // Restart the PXE - ({ pxe, cleanup } = await startCompatiblePXE(rpcUrl, config.REAL_VERIFIER, debugLogger)); + ({ wallet, aztecNode, cleanup } = await createWalletAndAztecNodeClient(rpcUrl, config.REAL_VERIFIER, debugLogger)); + await sleep(30 * 1000); - testAccounts = await deploySponsoredTestAccounts(pxe, node, MINT_AMOUNT, debugLogger); + testAccounts = await deploySponsoredTestAccounts(wallet, aztecNode, MINT_AMOUNT, debugLogger); // TODO(#9327): end delete await performTransfers({ diff --git a/yarn-project/end-to-end/src/spartan/setup_test_wallets.ts b/yarn-project/end-to-end/src/spartan/setup_test_wallets.ts index 639d46fc8726..8e509f9c8234 100644 --- a/yarn-project/end-to-end/src/spartan/setup_test_wallets.ts +++ b/yarn-project/end-to-end/src/spartan/setup_test_wallets.ts @@ -6,7 +6,6 @@ import { type FeePaymentMethod, Fr, L1FeeJuicePortalManager, - type PXE, SponsoredFeePaymentMethod, type Wallet, createAztecNodeClient, @@ -25,7 +24,6 @@ import { getBBConfig } from '../fixtures/get_bb_config.js'; import { getSponsoredFPCAddress, registerSponsoredFPC } from '../fixtures/utils.js'; export interface TestAccounts { - pxe: PXE; aztecNode: AztecNode; wallet: TestWallet; accounts: AztecAddress[]; @@ -52,7 +50,7 @@ export async function setupTestAccountsWithTokens( const aztecNode = createAztecNodeClient(nodeUrl); const wallet = new TestWallet(pxe, aztecNode); - const [recipientAccount, ...accounts] = (await getDeployedTestAccounts(pxe)).slice(0, ACCOUNT_COUNT + 1); + const [recipientAccount, ...accounts] = (await getDeployedTestAccounts(wallet)).slice(0, ACCOUNT_COUNT + 1); const tokenAdmin = accounts[0]; const tokenAddress = await deployTokenAndMint( @@ -66,7 +64,6 @@ export async function setupTestAccountsWithTokens( const tokenContract = await TokenContract.at(tokenAddress, wallet); return { - pxe, aztecNode, accounts: accounts.map(acc => acc.address), wallet, @@ -79,13 +76,12 @@ export async function setupTestAccountsWithTokens( } export async function deploySponsoredTestAccounts( - pxe: PXE, + wallet: TestWallet, aztecNode: AztecNode, mintAmount: bigint, logger: Logger, numberOfFundedWallets = 1, ): Promise { - const wallet = new TestWallet(pxe, aztecNode); const [recipient, ...funded] = await generateSchnorrAccounts(numberOfFundedWallets + 1); const recipientAccount = await wallet.createSchnorrAccount(recipient.secret, recipient.salt); const fundedAccounts = await Promise.all(funded.map(a => wallet.createSchnorrAccount(a.secret, a.salt))); @@ -112,7 +108,6 @@ export async function deploySponsoredTestAccounts( const tokenContract = await TokenContract.at(tokenAddress, wallet); return { - pxe, aztecNode, wallet, accounts: fundedAccounts.map(acc => acc.getAddress()), @@ -143,7 +138,7 @@ export async function deployTestAccountsWithTokens( const claims = await Promise.all( fundedAccounts.map(a => - bridgeL1FeeJuice(l1RpcUrls, mnemonicOrPrivateKey, pxe, aztecNode, a.getAddress(), undefined, logger), + bridgeL1FeeJuice(l1RpcUrls, mnemonicOrPrivateKey, aztecNode, a.getAddress(), undefined, logger), ), ); @@ -172,7 +167,6 @@ export async function deployTestAccountsWithTokens( const tokenContract = await TokenContract.at(tokenAddress, wallet); return { - pxe, aztecNode, wallet, accounts: fundedAccounts.map(acc => acc.getAddress()), @@ -187,7 +181,6 @@ export async function deployTestAccountsWithTokens( async function bridgeL1FeeJuice( l1RpcUrls: string[], mnemonicOrPrivateKey: string, - pxe: PXE, aztecNode: AztecNode, recipient: AztecAddress, amount: bigint | undefined, @@ -293,23 +286,25 @@ export async function performTransfers({ } } -export async function startCompatiblePXE( +export async function createWalletAndAztecNodeClient( nodeUrl: string, proverEnabled: boolean, logger: Logger, -): Promise<{ pxe: PXE; cleanup: () => Promise }> { - const node = createAztecNodeClient(nodeUrl); +): Promise<{ wallet: TestWallet; aztecNode: AztecNode; cleanup: () => Promise }> { + const aztecNode = createAztecNodeClient(nodeUrl); const [bbConfig, acvmConfig] = await Promise.all([getBBConfig(logger), getACVMConfig(logger)]); - const pxe = await createPXEService(node, { + const pxe = await createPXEService(aztecNode, { dataDirectory: undefined, dataStoreMapSizeKB: 1024 * 1024, ...bbConfig, ...acvmConfig, proverEnabled, }); + const wallet = new TestWallet(pxe, aztecNode); return { - pxe, + wallet, + aztecNode, async cleanup() { await pxe.stop(); await bbConfig?.cleanup(); diff --git a/yarn-project/end-to-end/src/spartan/transfer.test.ts b/yarn-project/end-to-end/src/spartan/transfer.test.ts index aa212e7e3804..3e102d22cae1 100644 --- a/yarn-project/end-to-end/src/spartan/transfer.test.ts +++ b/yarn-project/end-to-end/src/spartan/transfer.test.ts @@ -1,12 +1,17 @@ -import { type PXE, SponsoredFeePaymentMethod, createAztecNodeClient, readFieldCompressedString } from '@aztec/aztec.js'; +import { type AztecNode, SponsoredFeePaymentMethod, readFieldCompressedString } from '@aztec/aztec.js'; import { createLogger } from '@aztec/foundation/log'; import { TokenContract } from '@aztec/noir-contracts.js/Token'; +import { TestWallet } from '@aztec/test-wallet'; import { jest } from '@jest/globals'; import type { ChildProcess } from 'child_process'; import { getSponsoredFPCAddress } from '../fixtures/utils.js'; -import { type TestAccounts, deploySponsoredTestAccounts, startCompatiblePXE } from './setup_test_wallets.js'; +import { + type TestAccounts, + createWalletAndAztecNodeClient, + deploySponsoredTestAccounts, +} from './setup_test_wallets.js'; import { setupEnvironment, startPortForwardForRPC } from './utils.js'; const config = setupEnvironment(process.env); @@ -21,7 +26,8 @@ describe('token transfer test', () => { let testAccounts: TestAccounts; const forwardProcesses: ChildProcess[] = []; - let pxe: PXE; + let wallet: TestWallet; + let aztecNode: AztecNode; let cleanup: undefined | (() => Promise); afterAll(async () => { @@ -33,10 +39,9 @@ describe('token transfer test', () => { const { process, port } = await startPortForwardForRPC(config.NAMESPACE); forwardProcesses.push(process); const rpcUrl = `http://127.0.0.1:${port}`; - const node = createAztecNodeClient(rpcUrl); - ({ pxe, cleanup } = await startCompatiblePXE(rpcUrl, config.REAL_VERIFIER, logger)); + ({ wallet, aztecNode, cleanup } = await createWalletAndAztecNodeClient(rpcUrl, config.REAL_VERIFIER, logger)); - testAccounts = await deploySponsoredTestAccounts(pxe, node, MINT_AMOUNT, logger); + testAccounts = await deploySponsoredTestAccounts(wallet, aztecNode, MINT_AMOUNT, logger); expect(ROUNDS).toBeLessThanOrEqual(MINT_AMOUNT); }); diff --git a/yarn-project/test-wallet/src/wallet/test_wallet.ts b/yarn-project/test-wallet/src/wallet/test_wallet.ts index 8b79b5229fb3..5adedfc2b4f4 100644 --- a/yarn-project/test-wallet/src/wallet/test_wallet.ts +++ b/yarn-project/test-wallet/src/wallet/test_wallet.ts @@ -7,6 +7,7 @@ import { type ContractArtifact, type ContractFunctionInteractionCallIntent, type IntentInnerHash, + type PXE, SetPublicAuthwitContractInteraction, SignerlessAccount, type SimulateMethodOptions, @@ -18,7 +19,9 @@ import type { ExecutionPayload } from '@aztec/entrypoints/payload'; import { Fq, Fr } from '@aztec/foundation/fields'; import { AuthWitness } from '@aztec/stdlib/auth-witness'; import { AztecAddress } from '@aztec/stdlib/aztec-address'; -import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract'; +import type { CompleteAddress, ContractInstanceWithAddress, PartialAddress } from '@aztec/stdlib/contract'; +import type { PXEInfo } from '@aztec/stdlib/interfaces/client'; +import type { NotesFilter, UniqueNote } from '@aztec/stdlib/note'; import type { TxSimulationResult } from '@aztec/stdlib/tx'; /** @@ -176,4 +179,30 @@ export abstract class BaseTestWallet extends BaseWallet { return this.pxe.simulateTx(txRequest, true /* simulatePublic */, true, true, { contracts: contractOverrides }); } } + + // RECENTLY ADDED TO GET RID OF PXE IN END-TO-END TESTS + registerAccount(secretKey: Fr, partialAddress: PartialAddress): Promise { + return this.pxe.registerAccount(secretKey, partialAddress); + } + + // RECENTLY ADDED TO GET RID OF PXE IN END-TO-END TESTS + getNotes(filter: NotesFilter): Promise { + return this.pxe.getNotes(filter); + } + + // RECENTLY ADDED TO GET RID OF PXE IN END-TO-END TESTS + // Temporary hack to be able to instantiate TestWalletInternals + getPxe(): PXE { + return this.pxe; + } + + // RECENTLY ADDED TO GET RID OF PXE IN END-TO-END TESTS + getPXEInfo(): Promise { + return this.pxe.getPXEInfo(); + } + + // RECENTLY ADDED TO GET RID OF PXE IN END-TO-END TESTS + getContracts(): Promise { + return this.pxe.getContracts(); + } }