diff --git a/yarn-project/canary/tsconfig.json b/yarn-project/canary/tsconfig.json index 837b3f136a5..d02659b19cd 100644 --- a/yarn-project/canary/tsconfig.json +++ b/yarn-project/canary/tsconfig.json @@ -20,10 +20,10 @@ }, "references": [ { - "path": "../circuits.js" + "path": "../aztec.js" }, { - "path": "../aztec.js" + "path": "../circuits.js" }, { "path": "../cli" diff --git a/yarn-project/end-to-end/src/e2e_cli.test.ts b/yarn-project/end-to-end/src/e2e_cli.test.ts index 21709f65a3a..1f24698ce1e 100644 --- a/yarn-project/end-to-end/src/e2e_cli.test.ts +++ b/yarn-project/end-to-end/src/e2e_cli.test.ts @@ -1,7 +1,6 @@ -import { AztecNodeService } from '@aztec/aztec-node'; import { startHttpRpcServer } from '@aztec/aztec-sandbox'; import { PXE, createDebugLogger } from '@aztec/aztec.js'; -import { PXEService, createPXERpcServer } from '@aztec/pxe'; +import { createPXERpcServer } from '@aztec/pxe'; import { cliTestSuite } from './canary/cli.js'; import { setup as e2eSetup } from './fixtures/utils.js'; @@ -11,13 +10,13 @@ const RPC_URL = `http://localhost:${HTTP_PORT}`; const debug = createDebugLogger('aztec:e2e_cli'); let http: ReturnType; -let aztecNode: AztecNodeService | undefined; let pxe: PXE; +let teardown: () => Promise; const testSetup = async () => { const context = await e2eSetup(2); debug(`Environment set up`); - ({ aztecNode, pxe } = context); + ({ pxe, teardown } = context); http = startHttpRpcServer(pxe, createPXERpcServer, HTTP_PORT); debug(`HTTP RPC server started in port ${HTTP_PORT}`); return pxe; @@ -25,8 +24,7 @@ const testSetup = async () => { const testCleanup = async () => { http.close(); - await aztecNode?.stop(); - await (pxe as PXEService).stop(); + await teardown(); }; cliTestSuite('E2E CLI Test', testSetup, testCleanup, createDebugLogger('aztec:e2e_cli'), RPC_URL); diff --git a/yarn-project/end-to-end/src/e2e_multi_transfer.test.ts b/yarn-project/end-to-end/src/e2e_multi_transfer.test.ts index 65c593fbfc0..81aa130aba0 100644 --- a/yarn-project/end-to-end/src/e2e_multi_transfer.test.ts +++ b/yarn-project/end-to-end/src/e2e_multi_transfer.test.ts @@ -1,8 +1,7 @@ -import { AztecNodeService } from '@aztec/aztec-node'; import { AztecAddress, Contract, Wallet } from '@aztec/aztec.js'; import { DebugLogger } from '@aztec/foundation/log'; import { MultiTransferContract, PrivateTokenAirdropContract } from '@aztec/noir-contracts/types'; -import { CompleteAddress } from '@aztec/types'; +import { AztecNode, CompleteAddress } from '@aztec/types'; import { expectsNumOfEncryptedLogsInTheLastBlockToBe, setup } from './fixtures/utils.js'; @@ -14,7 +13,7 @@ import { expectsNumOfEncryptedLogsInTheLastBlockToBe, setup } from './fixtures/u describe('multi-transfer payments', () => { const numberOfAccounts = 12; - let aztecNode: AztecNodeService | undefined; + let aztecNode: AztecNode | undefined; let wallet: Wallet; let logger: DebugLogger; let teardown: () => Promise; diff --git a/yarn-project/end-to-end/src/e2e_multiple_accounts_1_enc_key.test.ts b/yarn-project/end-to-end/src/e2e_multiple_accounts_1_enc_key.test.ts index 651552a7d2a..e463e48ea5a 100644 --- a/yarn-project/end-to-end/src/e2e_multiple_accounts_1_enc_key.test.ts +++ b/yarn-project/end-to-end/src/e2e_multiple_accounts_1_enc_key.test.ts @@ -1,14 +1,13 @@ -import { AztecNodeService } from '@aztec/aztec-node'; import { AztecAddress, Wallet, computeMessageSecretHash, generatePublicKey, getSchnorrAccount } from '@aztec/aztec.js'; import { Fr, GrumpkinScalar } from '@aztec/circuits.js'; import { DebugLogger } from '@aztec/foundation/log'; import { TokenContract } from '@aztec/noir-contracts/types'; -import { PXE, TxStatus } from '@aztec/types'; +import { AztecNode, PXE, TxStatus } from '@aztec/types'; import { expectsNumOfEncryptedLogsInTheLastBlockToBe, setup } from './fixtures/utils.js'; describe('e2e_multiple_accounts_1_enc_key', () => { - let aztecNode: AztecNodeService | undefined; + let aztecNode: AztecNode | undefined; let pxe: PXE; const wallets: Wallet[] = []; const accounts: AztecAddress[] = []; diff --git a/yarn-project/end-to-end/src/e2e_non_contract_account.test.ts b/yarn-project/end-to-end/src/e2e_non_contract_account.test.ts index 6f4da87a779..9a40f277243 100644 --- a/yarn-project/end-to-end/src/e2e_non_contract_account.test.ts +++ b/yarn-project/end-to-end/src/e2e_non_contract_account.test.ts @@ -1,13 +1,12 @@ -import { AztecNodeService } from '@aztec/aztec-node'; import { AztecAddress, SignerlessWallet, Wallet } from '@aztec/aztec.js'; import { DebugLogger } from '@aztec/foundation/log'; import { PokeableTokenContract } from '@aztec/noir-contracts/types'; -import { CompleteAddress, PXE, TxStatus } from '@aztec/types'; +import { AztecNode, CompleteAddress, PXE, TxStatus } from '@aztec/types'; import { expectsNumOfEncryptedLogsInTheLastBlockToBe, setup } from './fixtures/utils.js'; describe('e2e_non_contract_account', () => { - let aztecNode: AztecNodeService | undefined; + let aztecNode: AztecNode | undefined; let pxe: PXE; let wallet: Wallet; let sender: AztecAddress; diff --git a/yarn-project/end-to-end/src/e2e_pending_commitments_contract.test.ts b/yarn-project/end-to-end/src/e2e_pending_commitments_contract.test.ts index 81070e19577..abe745c4688 100644 --- a/yarn-project/end-to-end/src/e2e_pending_commitments_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_pending_commitments_contract.test.ts @@ -1,13 +1,12 @@ -import { AztecNodeService } from '@aztec/aztec-node'; import { AztecAddress, Fr, Wallet } from '@aztec/aztec.js'; import { DebugLogger } from '@aztec/foundation/log'; import { PendingCommitmentsContract } from '@aztec/noir-contracts/types'; -import { CompleteAddress, TxStatus } from '@aztec/types'; +import { AztecNode, CompleteAddress, TxStatus } from '@aztec/types'; import { setup } from './fixtures/utils.js'; describe('e2e_pending_commitments_contract', () => { - let aztecNode: AztecNodeService | undefined; + let aztecNode: AztecNode | undefined; let wallet: Wallet; let logger: DebugLogger; let owner: AztecAddress; diff --git a/yarn-project/end-to-end/src/e2e_private_token_contract.test.ts b/yarn-project/end-to-end/src/e2e_private_token_contract.test.ts index 3d13f15fa02..1cc13f97e78 100644 --- a/yarn-project/end-to-end/src/e2e_private_token_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_private_token_contract.test.ts @@ -1,13 +1,12 @@ -import { AztecNodeService } from '@aztec/aztec-node'; import { AztecAddress, Wallet } from '@aztec/aztec.js'; import { DebugLogger } from '@aztec/foundation/log'; import { PrivateTokenContract } from '@aztec/noir-contracts/types'; -import { CompleteAddress, TxStatus } from '@aztec/types'; +import { AztecNode, CompleteAddress, TxStatus } from '@aztec/types'; import { expectsNumOfEncryptedLogsInTheLastBlockToBe, setup } from './fixtures/utils.js'; describe('e2e_private_token_contract', () => { - let aztecNode: AztecNodeService | undefined; + let aztecNode: AztecNode | undefined; let wallet: Wallet; let logger: DebugLogger; let owner: AztecAddress; diff --git a/yarn-project/end-to-end/src/fixtures/cross_chain_test_harness.ts b/yarn-project/end-to-end/src/fixtures/cross_chain_test_harness.ts index 4eba012fa93..5d2f2c18a81 100644 --- a/yarn-project/end-to-end/src/fixtures/cross_chain_test_harness.ts +++ b/yarn-project/end-to-end/src/fixtures/cross_chain_test_harness.ts @@ -8,7 +8,7 @@ import { DebugLogger } from '@aztec/foundation/log'; import { OutboxAbi } from '@aztec/l1-artifacts'; import { TokenBridgeContract, TokenContract } from '@aztec/noir-contracts/types'; import { PXEService } from '@aztec/pxe'; -import { PXE, TxStatus } from '@aztec/types'; +import { AztecNode, PXE, TxStatus } from '@aztec/types'; import { Chain, HttpTransport, PublicClient, getContract } from 'viem'; @@ -20,7 +20,7 @@ import { deployAndInitializeTokenAndBridgeContracts } from './utils.js'; */ export class CrossChainTestHarness { static async new( - aztecNode: AztecNodeService | undefined, + aztecNode: AztecNode | undefined, pxeService: PXE, deployL1ContractsValues: DeployL1Contracts, accounts: CompleteAddress[], @@ -89,7 +89,7 @@ export class CrossChainTestHarness { } constructor( /** AztecNode. */ - public aztecNode: AztecNodeService | undefined, + public aztecNode: AztecNode | undefined, /** Private eXecution Environment (PXE). */ public pxeService: PXE, /** CheatCodes. */ @@ -338,7 +338,7 @@ export class CrossChainTestHarness { } async stop() { - await this.aztecNode?.stop(); + if (this.aztecNode instanceof AztecNodeService) await this.aztecNode?.stop(); if (this.pxeService instanceof PXEService) { await this.pxeService?.stop(); } diff --git a/yarn-project/end-to-end/src/fixtures/utils.ts b/yarn-project/end-to-end/src/fixtures/utils.ts index 7b8e3c18e07..e371f36489a 100644 --- a/yarn-project/end-to-end/src/fixtures/utils.ts +++ b/yarn-project/end-to-end/src/fixtures/utils.ts @@ -8,7 +8,7 @@ import { EthCheatCodes, Wallet, createAccounts, - createPXEClient as createJsonRpcClient, + createPXEClient, getSandboxAccountsWallets, } from '@aztec/aztec.js'; import { CircuitsWasm, GeneratorIndex } from '@aztec/circuits.js'; @@ -42,7 +42,7 @@ import { } from '@aztec/l1-artifacts'; import { NonNativeTokenContract, TokenBridgeContract, TokenContract } from '@aztec/noir-contracts/types'; import { PXEService, createPXEService, getPXEServiceConfig } from '@aztec/pxe'; -import { L2BlockL2Logs, LogType, PXE, TxStatus } from '@aztec/types'; +import { AztecNode, L2BlockL2Logs, LogType, PXE, TxStatus, createAztecNodeRpcClient } from '@aztec/types'; import { Account, @@ -76,10 +76,7 @@ export const waitForPXE = async (pxe: PXE, logger: DebugLogger) => { }, 'RPC Get Node Info'); }; -const createAztecNode = async ( - nodeConfig: AztecNodeConfig, - logger: DebugLogger, -): Promise => { +const createAztecNode = async (nodeConfig: AztecNodeConfig, logger: DebugLogger): Promise => { if (SANDBOX_URL) { logger(`Not creating Aztec Node as we are running against a sandbox at ${SANDBOX_URL}`); return undefined; @@ -136,7 +133,7 @@ export const setupL1Contracts = async ( */ export async function setupPXEService( numberOfAccounts: number, - aztecNode: AztecNodeService, + aztecNode: AztecNode, logger = getLogger(), useLogSuffix = false, ): Promise<{ @@ -175,18 +172,20 @@ export async function setupPXEService( * @param account - The account for use in create viem wallets. * @param config - The aztec Node Configuration * @param logger - The logger to be used - * @returns Private eXecution Environment (PXE) client, viem wallets, contract addreses etc. + * @returns Private eXecution Environment (PXE) client, viem wallets, contract addresses etc. */ async function setupWithSandbox(account: Account, config: AztecNodeConfig, logger: DebugLogger) { // we are setting up against the sandbox, l1 contracts are already deployed - logger(`Creating JSON RPC client to remote host ${SANDBOX_URL}`); - const jsonClient = createJsonRpcClient(SANDBOX_URL); - await waitForPXE(jsonClient, logger); + logger(`Creating Aztec Node client to remote host ${SANDBOX_URL}`); + const aztecNode = createAztecNodeRpcClient('http://localhost:8079'); + logger(`Creating PXE client to remote host ${SANDBOX_URL}`); + const pxeClient = createPXEClient(SANDBOX_URL); + await waitForPXE(pxeClient, logger); logger('JSON RPC client connected to PXE'); logger(`Retrieving contract addresses from ${SANDBOX_URL}`); - const l1Contracts = (await jsonClient.getNodeInfo()).l1ContractAddresses; + const l1Contracts = (await pxeClient.getNodeInfo()).l1ContractAddresses; logger('PXE created, constructing wallets from initial sandbox accounts...'); - const wallets = await getSandboxAccountsWallets(jsonClient); + const wallets = await getSandboxAccountsWallets(pxeClient); const walletClient = createWalletClient({ account, @@ -202,13 +201,13 @@ async function setupWithSandbox(account: Account, config: AztecNodeConfig, logge walletClient, publicClient, }; - const cheatCodes = await CheatCodes.create(config.rpcUrl, jsonClient!); + const cheatCodes = await CheatCodes.create(config.rpcUrl, pxeClient!); const teardown = () => Promise.resolve(); return { - aztecNode: undefined, - pxe: jsonClient, + aztecNode, + pxe: pxeClient, deployL1ContractsValues, - accounts: await jsonClient!.getRegisteredAccounts(), + accounts: await pxeClient!.getRegisteredAccounts(), config, wallet: wallets[0], wallets, @@ -229,7 +228,7 @@ export async function setup( /** * The Aztec Node service. */ - aztecNode: AztecNodeService | undefined; + aztecNode: AztecNode | undefined; /** * The Private eXecution Environment (PXE). */ @@ -300,7 +299,7 @@ export async function setup( const cheatCodes = await CheatCodes.create(config.rpcUrl, pxe!); const teardown = async () => { - await aztecNode?.stop(); + if (aztecNode instanceof AztecNodeService) await aztecNode?.stop(); if (pxe instanceof PXEService) await pxe?.stop(); }; @@ -528,7 +527,7 @@ export function delay(ms: number): Promise { * @param numEncryptedLogs - The number of expected logs. */ export const expectsNumOfEncryptedLogsInTheLastBlockToBe = async ( - aztecNode: AztecNodeService | undefined, + aztecNode: AztecNode | undefined, numEncryptedLogs: number, ) => { if (!aztecNode) { diff --git a/yarn-project/end-to-end/src/uniswap_trade_on_l1_from_l2.test.ts b/yarn-project/end-to-end/src/uniswap_trade_on_l1_from_l2.test.ts index 4f25b6bbbc9..dbbd6d9779e 100644 --- a/yarn-project/end-to-end/src/uniswap_trade_on_l1_from_l2.test.ts +++ b/yarn-project/end-to-end/src/uniswap_trade_on_l1_from_l2.test.ts @@ -6,7 +6,7 @@ import { EthAddress } from '@aztec/foundation/eth-address'; import { DebugLogger } from '@aztec/foundation/log'; import { UniswapPortalAbi, UniswapPortalBytecode } from '@aztec/l1-artifacts'; import { UniswapContract } from '@aztec/noir-contracts/types'; -import { PXE, TxStatus } from '@aztec/types'; +import { AztecNode, PXE, TxStatus } from '@aztec/types'; import { getContract, parseEther } from 'viem'; @@ -31,7 +31,7 @@ describe('uniswap_trade_on_l1_from_l2', () => { const WETH9_ADDRESS: EthAddress = EthAddress.fromString('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'); const DAI_ADDRESS: EthAddress = EthAddress.fromString('0x6B175474E89094C44Da98b954EedeAC495271d0F'); - let aztecNode: AztecNodeService | undefined; + let aztecNode: AztecNode | undefined; let pxe: PXE; let logger: DebugLogger; let teardown: () => Promise;