From 241cfa2ddcfbc786a308f3e012e766cee406d257 Mon Sep 17 00:00:00 2001 From: Santiago Palladino Date: Thu, 3 Oct 2024 15:42:48 -0300 Subject: [PATCH] chore: Do not start prover node in e2e tests if not needed --- .../end-to-end/src/e2e_fees/fees_test.ts | 5 +-- .../src/e2e_prover/e2e_prover_test.ts | 4 +- .../src/fixtures/snapshot_manager.ts | 41 +++++++++++-------- yarn-project/end-to-end/src/fixtures/utils.ts | 2 + .../e2e_prover_coordination.test.ts | 12 +++--- .../e2e_public_testnet_transfer.test.ts | 23 ++--------- 6 files changed, 36 insertions(+), 51 deletions(-) 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 1157a4f3c7b..e92c065158b 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 @@ -28,7 +28,6 @@ import { TokenContract, } from '@aztec/noir-contracts.js'; import { getCanonicalFeeJuice } from '@aztec/protocol-contracts/fee-juice'; -import { type ProverNode } from '@aztec/prover-node'; import { getContract } from 'viem'; @@ -55,7 +54,6 @@ export class FeesTest { public logger: DebugLogger; public pxe!: PXE; public aztecNode!: AztecNode; - public proverNode!: ProverNode; public aliceWallet!: AccountWallet; public aliceAddress!: AztecAddress; @@ -175,10 +173,9 @@ export class FeesTest { await this.snapshotManager.snapshot( 'initial_accounts', addAccounts(3, this.logger), - async ({ accountKeys }, { pxe, aztecNode, aztecNodeConfig, proverNode }) => { + async ({ accountKeys }, { pxe, aztecNode, aztecNodeConfig }) => { this.pxe = pxe; this.aztecNode = aztecNode; - this.proverNode = proverNode; const accountManagers = accountKeys.map(ak => getSchnorrAccount(pxe, ak[0], ak[1], 1)); await Promise.all(accountManagers.map(a => a.register())); this.wallets = await Promise.all(accountManagers.map(a => a.getWallet())); diff --git a/yarn-project/end-to-end/src/e2e_prover/e2e_prover_test.ts b/yarn-project/end-to-end/src/e2e_prover/e2e_prover_test.ts index ca6b956d067..5b5831f686f 100644 --- a/yarn-project/end-to-end/src/e2e_prover/e2e_prover_test.ts +++ b/yarn-project/end-to-end/src/e2e_prover/e2e_prover_test.ts @@ -95,7 +95,7 @@ export class FullProverTest { this.snapshotManager = createSnapshotManager( `full_prover_integration/${testName}`, dataPath, - {}, + { startProverNode: true }, { assumeProvenThrough: undefined, useRealProofCommitmentEscrow: true }, ); } @@ -155,10 +155,10 @@ export class FullProverTest { async setup() { this.context = await this.snapshotManager.setup(); + this.simulatedProverNode = this.context.proverNode!; ({ pxe: this.pxe, aztecNode: this.aztecNode, - proverNode: this.simulatedProverNode, deployL1ContractsValues: this.l1Contracts, cheatCodes: this.cheatCodes, } = this.context); 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 019872443b9..9ef2fadf1b6 100644 --- a/yarn-project/end-to-end/src/fixtures/snapshot_manager.ts +++ b/yarn-project/end-to-end/src/fixtures/snapshot_manager.ts @@ -56,7 +56,7 @@ export type SubsystemsContext = { aztecNodeConfig: AztecNodeConfig; pxe: PXEService; deployL1ContractsValues: DeployL1Contracts; - proverNode: ProverNode; + proverNode?: ProverNode; watcher: AnvilTestWatcher; cheatCodes: CheatCodes; }; @@ -251,7 +251,7 @@ async function teardown(context: SubsystemsContext | undefined) { if (!context) { return; } - await context.proverNode.stop(); + await context.proverNode?.stop(); await context.aztecNode.stop(); await context.pxe.stop(); await context.acvmConfig?.cleanup(); @@ -259,7 +259,7 @@ async function teardown(context: SubsystemsContext | undefined) { await context.watcher.stop(); } -export async function createAndSyncProverNode( +async function createAndSyncProverNode( proverNodePrivateKey: `0x${string}`, aztecNodeConfig: AztecNodeConfig, aztecNode: AztecNode, @@ -281,8 +281,8 @@ export async function createAndSyncProverNode( proverNodePollingIntervalMs: 200, quoteProviderBasisPointFee: 100, quoteProviderBondAmount: 1000n, - proverMinimumStakeAmount: 0n, - proverTargetStakeAmount: 0n, + proverMinimumStakeAmount: 1000n, + proverTargetStakeAmount: 2000n, }; const proverNode = await createProverNode(proverConfig, { aztecNodeTxProvider: aztecNode, @@ -309,7 +309,7 @@ async function setupFromFresh( // Fetch the AztecNode config. // TODO: For some reason this is currently the union of a bunch of subsystems. That needs fixing. - const aztecNodeConfig: AztecNodeConfig = { ...getConfigEnvVars(), ...opts }; + const aztecNodeConfig: AztecNodeConfig & SetupOptions = { ...getConfigEnvVars(), ...opts }; aztecNodeConfig.dataDirectory = statePath; // Start anvil. We go via a wrapper script to ensure if the parent dies, anvil dies. @@ -367,12 +367,15 @@ async function setupFromFresh( logger.verbose('Creating and synching an aztec node...'); const aztecNode = await AztecNodeService.createAndSync(aztecNodeConfig, telemetry); - logger.verbose('Creating and syncing a simulated prover node...'); - const proverNode = await createAndSyncProverNode( - `0x${proverNodePrivateKey!.toString('hex')}`, - aztecNodeConfig, - aztecNode, - ); + let proverNode: ProverNode | undefined = undefined; + if (opts.startProverNode) { + logger.verbose('Creating and syncing a simulated prover node...'); + proverNode = await createAndSyncProverNode( + `0x${proverNodePrivateKey!.toString('hex')}`, + aztecNodeConfig, + aztecNode, + ); + } logger.verbose('Creating pxe...'); const pxeConfig = getPXEServiceConfig(); @@ -416,7 +419,7 @@ async function setupFromState(statePath: string, logger: Logger): Promise; /** Context for an end-to-end test as returned by the `setup` function */ diff --git a/yarn-project/end-to-end/src/prover-coordination/e2e_prover_coordination.test.ts b/yarn-project/end-to-end/src/prover-coordination/e2e_prover_coordination.test.ts index 18390ba385a..0ec884a5fad 100644 --- a/yarn-project/end-to-end/src/prover-coordination/e2e_prover_coordination.test.ts +++ b/yarn-project/end-to-end/src/prover-coordination/e2e_prover_coordination.test.ts @@ -51,10 +51,8 @@ describe('e2e_prover_coordination', () => { snapshotManager = createSnapshotManager( `prover_coordination/e2e_json_coordination`, process.env.E2E_DATA_PATH, - {}, - { - assumeProvenThrough: undefined, - }, + { startProverNode: true }, + { assumeProvenThrough: undefined }, ); await snapshotManager.snapshot('setup', addAccounts(2, logger), async ({ accountKeys }, ctx) => { @@ -80,7 +78,7 @@ describe('e2e_prover_coordination', () => { ctx = await snapshotManager.setup(); - await ctx.proverNode.stop(); + await ctx.proverNode!.stop(); cc = new EthCheatCodes(ctx.aztecNodeConfig.l1RpcUrl); @@ -195,7 +193,7 @@ describe('e2e_prover_coordination', () => { }); // Send in the quote - await ctx.proverNode.sendEpochProofQuote(quoteForEpoch0); + await ctx.proverNode!.sendEpochProofQuote(quoteForEpoch0); // Build a block, this should NOT use the above quote as it is for the current epoch (0) await contract.methods.create_note(recipient, recipient, 10).send().wait(); @@ -272,7 +270,7 @@ describe('e2e_prover_coordination', () => { const allQuotes = [proofQuoteInvalidSlot, proofQuoteInvalidEpoch, ...validQuotes, proofQuoteInsufficientBond]; - await Promise.all(allQuotes.map(x => ctx.proverNode.sendEpochProofQuote(x))); + await Promise.all(allQuotes.map(x => ctx.proverNode!.sendEpochProofQuote(x))); // now build another block and we should see the best valid quote being published await contract.methods.create_note(recipient, recipient, 10).send().wait(); diff --git a/yarn-project/end-to-end/src/public-testnet/e2e_public_testnet_transfer.test.ts b/yarn-project/end-to-end/src/public-testnet/e2e_public_testnet_transfer.test.ts index 08636379f64..22cb491facf 100644 --- a/yarn-project/end-to-end/src/public-testnet/e2e_public_testnet_transfer.test.ts +++ b/yarn-project/end-to-end/src/public-testnet/e2e_public_testnet_transfer.test.ts @@ -1,14 +1,10 @@ import { createAccounts } from '@aztec/accounts/testing'; -import { type AztecNodeConfig } from '@aztec/aztec-node'; -import { type AztecNode, type DebugLogger, Fr, type PXE } from '@aztec/aztec.js'; -import { NULL_KEY } from '@aztec/ethereum'; +import { type DebugLogger, Fr, type PXE } from '@aztec/aztec.js'; import { EasyPrivateTokenContract } from '@aztec/noir-contracts.js'; -import { type ProverNode, type ProverNodeConfig, getProverNodeConfigFromEnv } from '@aztec/prover-node'; import { foundry, sepolia } from 'viem/chains'; -import { createAndSyncProverNode } from '../fixtures/snapshot_manager.js'; -import { getPrivateKeyFromIndex, setup } from '../fixtures/utils.js'; +import { setup } from '../fixtures/utils.js'; // process.env.SEQ_PUBLISHER_PRIVATE_KEY = ''; // process.env.PROVER_PUBLISHER_PRIVATE_KEY = ''; @@ -18,10 +14,6 @@ import { getPrivateKeyFromIndex, setup } from '../fixtures/utils.js'; describe(`deploys and transfers a private only token`, () => { let secretKey1: Fr; let secretKey2: Fr; - let proverConfig: ProverNodeConfig; - let config: AztecNodeConfig; - let aztecNode: AztecNode; - let proverNode: ProverNode; let pxe: PXE; let logger: DebugLogger; @@ -30,25 +22,16 @@ describe(`deploys and transfers a private only token`, () => { beforeEach(async () => { const chainId = !process.env.L1_CHAIN_ID ? foundry.id : +process.env.L1_CHAIN_ID; const chain = chainId == sepolia.id ? sepolia : foundry; // Not the best way of doing this. - ({ logger, pxe, teardown, config, aztecNode } = await setup( + ({ logger, pxe, teardown } = await setup( 0, { skipProtocolContracts: true, stateLoad: undefined }, {}, false, chain, )); - proverConfig = getProverNodeConfigFromEnv(); - const proverNodePrivateKey = getPrivateKeyFromIndex(2); - proverConfig.publisherPrivateKey = - proverConfig.publisherPrivateKey === NULL_KEY - ? `0x${proverNodePrivateKey?.toString('hex')}` - : proverConfig.publisherPrivateKey; - - proverNode = await createAndSyncProverNode(proverConfig.publisherPrivateKey, config, aztecNode); }, 600_000); afterEach(async () => { - await proverNode.stop(); await teardown(); });