From 8583ea8dc3a094747907a6f1e08382a1b75b4233 Mon Sep 17 00:00:00 2001 From: PhilWindle Date: Fri, 23 Aug 2024 17:17:12 +0100 Subject: [PATCH 01/16] New test --- .../src/fixtures/snapshot_manager.ts | 14 ++-- yarn-project/end-to-end/src/fixtures/utils.ts | 25 ++++-- .../e2e_private_token_transfer.test.ts | 84 +++++++++++++++++++ 3 files changed, 110 insertions(+), 13 deletions(-) create mode 100644 yarn-project/end-to-end/src/public_testnet/e2e_private_token_transfer.test.ts 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 c57f8fe542c..452c96a7ab3 100644 --- a/yarn-project/end-to-end/src/fixtures/snapshot_manager.ts +++ b/yarn-project/end-to-end/src/fixtures/snapshot_manager.ts @@ -232,7 +232,7 @@ async function teardown(context: SubsystemsContext | undefined) { export async function createAndSyncProverNode( rollupAddress: EthAddress, - proverNodePrivateKey: Buffer, + proverNodePrivateKey: `0x${string}`, aztecNodeConfig: AztecNodeConfig, aztecNode: AztecNode, ) { @@ -247,6 +247,8 @@ export async function createAndSyncProverNode( { blockUntilSync: true }, ); + console.log(`Prover key: ${proverNodePrivateKey}`); + // Prover node config is for simulated proofs const proverConfig: ProverNodeConfig = { ...aztecNodeConfig, @@ -254,9 +256,9 @@ export async function createAndSyncProverNode( dataDirectory: undefined, proverId: new Fr(42), realProofs: false, - proverAgentConcurrency: 2, - publisherPrivateKey: `0x${proverNodePrivateKey.toString('hex')}`, - proverNodeMaxPendingJobs: 100, + proverAgentConcurrency: 1, + publisherPrivateKey: proverNodePrivateKey, + proverNodeMaxPendingJobs: 1, }; const proverNode = await createProverNode(proverConfig, { aztecNodeTxProvider: aztecNode, @@ -332,7 +334,7 @@ async function setupFromFresh( logger.verbose('Creating and syncing a simulated prover node...'); const proverNode = await createAndSyncProverNode( deployL1ContractsValues.l1ContractAddresses.rollupAddress, - proverNodePrivateKey!, + `0x${proverNodePrivateKey!}`, aztecNodeConfig, aztecNode, ); @@ -416,7 +418,7 @@ async function setupFromState(statePath: string, logger: Logger): Promise { + let secretKey1: Fr; + let secretKey2: Fr; + let proverConfig: ProverNodeConfig; + let config: AztecNodeConfig; + let aztecNode: AztecNode; + let proverNode: ProverNode; + + let pxe: PXE; + let logger: DebugLogger; + let teardown: () => Promise; + + beforeEach(async () => { + ({ logger, pxe, teardown, config, aztecNode } = await setup(0, {skipProtocolContracts: true, stateLoad: undefined})); + proverConfig = getProverNodeConfigFromEnv(); + + //proverNode = await createAndSyncProverNode(config.l1Contracts.rollupAddress, proverConfig.publisherPrivateKey, config, aztecNode); + }); + + afterEach(() => teardown()); + + it('calls a private function', async () => { + const initialBalance = 100000000000n; + const transferValue = 5n; + secretKey1 = Fr.random(); + secretKey2 = Fr.random(); + + logger.info(`Deploying accounts.`) + + const accounts = await createAccounts(pxe, 2, [secretKey1, secretKey2]); + + logger.info(`Accounts deployed, deploying token.`); + + const [deployerWallet, recipientWallet] = accounts; + + const token = await EasyPrivateTokenContract.deploy( + deployerWallet, + initialBalance, + deployerWallet.getAddress(), + deployerWallet.getAddress(), + ).send({ + universalDeploy: true, + skipPublicDeployment: true, + skipClassRegistration: true, + skipInitialization: false, + skipPublicSimulation: true, + }).deployed({ + proven: false, + provenTimeout: 600, + }); + + logger.info(`Performing transfer.`); + + await token.methods.transfer(transferValue, deployerWallet.getAddress(), recipientWallet.getAddress(), deployerWallet.getAddress()).send().wait({proven: false, provenTimeout: 600}); + + logger.info(`Transfer completed`); + + const balanceDeployer = await token.methods.get_balance(deployerWallet.getAddress()).simulate(); + const balanceRecipient = await token.methods.get_balance(recipientWallet.getAddress()).simulate(); + + logger.info(`Deployer balance: ${balanceDeployer}, Recipient balance: ${balanceRecipient}`); + + expect(balanceDeployer).toBe(initialBalance - transferValue); + expect(balanceRecipient).toBe(transferValue); + }); +}); \ No newline at end of file From b05d744d5aad9e6e3ea4a95f4a5ebb0130ad39e5 Mon Sep 17 00:00:00 2001 From: PhilWindle Date: Sat, 24 Aug 2024 21:52:54 +0100 Subject: [PATCH 02/16] Privater token transfer --- .../accounts/src/testing/create_account.ts | 4 ++- .../src/fixtures/snapshot_manager.ts | 2 -- yarn-project/end-to-end/src/fixtures/utils.ts | 12 +++++-- .../e2e_private_token_transfer.test.ts | 34 ++++++++++++------- .../ethereum/src/deploy_l1_contracts.ts | 12 ++++--- 5 files changed, 41 insertions(+), 23 deletions(-) diff --git a/yarn-project/accounts/src/testing/create_account.ts b/yarn-project/accounts/src/testing/create_account.ts index 5f9903165da..0c7e8327a09 100644 --- a/yarn-project/accounts/src/testing/create_account.ts +++ b/yarn-project/accounts/src/testing/create_account.ts @@ -3,6 +3,7 @@ import { type PXE } from '@aztec/circuit-types'; import { Fr, deriveSigningKey } from '@aztec/circuits.js'; import { getSchnorrAccount } from '../schnorr/index.js'; +import { WaitOpts } from '@aztec/aztec.js'; /** * Deploys and registers a new account using random private keys and returns the associated Schnorr account wallet. Useful for testing. @@ -27,6 +28,7 @@ export async function createAccounts( pxe: PXE, numberOfAccounts = 1, secrets: Fr[] = [], + waitOpts: WaitOpts = { interval: 0.1 } ): Promise { const accounts = []; @@ -56,6 +58,6 @@ export async function createAccounts( // Send them and await them to be mined const txs = await Promise.all(accounts.map(account => account.deploy())); - await Promise.all(txs.map(tx => tx.wait({ interval: 0.1 }))); + await Promise.all(txs.map(tx => tx.wait(waitOpts))); return Promise.all(accounts.map(account => account.getWallet())); } 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 452c96a7ab3..a7d8f483d99 100644 --- a/yarn-project/end-to-end/src/fixtures/snapshot_manager.ts +++ b/yarn-project/end-to-end/src/fixtures/snapshot_manager.ts @@ -247,8 +247,6 @@ export async function createAndSyncProverNode( { blockUntilSync: true }, ); - console.log(`Prover key: ${proverNodePrivateKey}`); - // Prover node config is for simulated proofs const proverConfig: ProverNodeConfig = { ...aztecNodeConfig, diff --git a/yarn-project/end-to-end/src/fixtures/utils.ts b/yarn-project/end-to-end/src/fixtures/utils.ts index 7ad2c51ac61..73fe78b8565 100644 --- a/yarn-project/end-to-end/src/fixtures/utils.ts +++ b/yarn-project/end-to-end/src/fixtures/utils.ts @@ -114,6 +114,7 @@ export const setupL1Contracts = async ( account: HDAccount | PrivateKeyAccount, logger: DebugLogger, args: { salt?: number } = {}, + chain: Chain = foundry, ) => { const l1Artifacts: L1ContractArtifactsForDeployment = { registry: { @@ -146,7 +147,7 @@ export const setupL1Contracts = async ( }, }; - const l1Data = await deployL1Contracts(l1RpcUrl, account, foundry, logger, l1Artifacts, { + const l1Data = await deployL1Contracts(l1RpcUrl, account, chain, logger, l1Artifacts, { l2FeeJuiceAddress: FeeJuiceAddress, vkTreeRoot: getVKTreeRoot(), salt: args.salt, @@ -292,6 +293,8 @@ type SetupOptions = { deployL1ContractsValues?: DeployL1Contracts; /** Whether to skip deployment of protocol contracts (auth registry, etc) */ skipProtocolContracts?: boolean; + /** Salt to use in L1 contract deployment */ + salt?: number; } & Partial; /** Context for an end-to-end test as returned by the `setup` function */ @@ -330,6 +333,7 @@ export async function setup( pxeOpts: Partial = {}, enableGas = false, enableValidators = false, + chain: Chain = foundry, ): Promise { const config = { ...getConfigEnvVars(), ...opts }; const logger = getLogger(); @@ -337,6 +341,9 @@ export async function setup( let anvil: Anvil | undefined; if (!config.l1RpcUrl) { + if (chain.id != foundry.id) { + throw new Error(`No ETHEREUM_HOST set but non anvil chain requested`); + } if (PXE_URL) { throw new Error( `PXE_URL provided but no ETHEREUM_HOST set. Refusing to run, please set both variables so tests can deploy L1 contracts to the same Anvil instance`, @@ -364,7 +371,6 @@ export async function setup( let publisherHdAccount = undefined; if (config.publisherPrivateKey && config.publisherPrivateKey != NULL_KEY) { - console.log(`KEY: ${config.publisherPrivateKey}`); publisherHdAccount = privateKeyToAccount(config.publisherPrivateKey); } else if (!MNEMONIC) { throw new Error(`Mnemonic not provided and no publisher private key`); @@ -381,7 +387,7 @@ export async function setup( } const deployL1ContractsValues = - opts.deployL1ContractsValues ?? (await setupL1Contracts(config.l1RpcUrl, publisherHdAccount!, logger)); + opts.deployL1ContractsValues ?? (await setupL1Contracts(config.l1RpcUrl, publisherHdAccount!, logger, { salt: opts.salt }, chain)); config.l1Contracts = deployL1ContractsValues.l1ContractAddresses; diff --git a/yarn-project/end-to-end/src/public_testnet/e2e_private_token_transfer.test.ts b/yarn-project/end-to-end/src/public_testnet/e2e_private_token_transfer.test.ts index 9f96138e5dd..fd1ad819cb4 100644 --- a/yarn-project/end-to-end/src/public_testnet/e2e_private_token_transfer.test.ts +++ b/yarn-project/end-to-end/src/public_testnet/e2e_private_token_transfer.test.ts @@ -1,20 +1,23 @@ import { AztecNode, type DebugLogger, - DeployL1Contracts, Fr, type PXE, } from '@aztec/aztec.js'; -import { setup } from '../fixtures/utils.js'; +import { getPrivateKeyFromIndex, setup } from '../fixtures/utils.js'; import { EasyPrivateTokenContract } from '@aztec/noir-contracts.js'; import { createAccounts } from '@aztec/accounts/testing'; import { getProverNodeConfigFromEnv, ProverNode, ProverNodeConfig } from '@aztec/prover-node'; import { createAndSyncProverNode } from '../fixtures/snapshot_manager.js'; import { AztecNodeConfig } from '@aztec/aztec-node'; +import { NULL_KEY } from '@aztec/ethereum'; +import { foundry, sepolia } from 'viem/chains'; -process.env.SEQ_PUBLISHER_PRIVATE_KEY = '0x7c852118294e51e653712a81e05800f419141751be58f605c371e15141b007a6'; -process.env.PROVER_PUBLISHER_PRIVATE_KEY = '0x47e179ec197488593b187f80a00eb0da91f1b9d0b13f8733639f19c30a34926a'; +// process.env.SEQ_PUBLISHER_PRIVATE_KEY = ''; +// process.env.PROVER_PUBLISHER_PRIVATE_KEY = ''; +// process.env.ETHEREUM_HOST= 'https://sepolia.infura.io/v3/'; +// process.env.L1_CHAIN_ID = '11155111'; describe(`deploys and transfers a private only token`, () => { let secretKey1: Fr; @@ -29,13 +32,20 @@ describe(`deploys and transfers a private only token`, () => { let teardown: () => Promise; beforeEach(async () => { - ({ logger, pxe, teardown, config, aztecNode } = await setup(0, {skipProtocolContracts: true, stateLoad: undefined})); + 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(0, {skipProtocolContracts: true, stateLoad: undefined, salt: 1}, { }, false, false, chain)); proverConfig = getProverNodeConfigFromEnv(); + const proverNodePrivateKey = getPrivateKeyFromIndex(2); + proverConfig.publisherPrivateKey = proverConfig.publisherPrivateKey === NULL_KEY ? `0x${proverNodePrivateKey?.toString('hex')}` : proverConfig.publisherPrivateKey; - //proverNode = await createAndSyncProverNode(config.l1Contracts.rollupAddress, proverConfig.publisherPrivateKey, config, aztecNode); - }); + proverNode = await createAndSyncProverNode(config.l1Contracts.rollupAddress, proverConfig.publisherPrivateKey, config, aztecNode); + }, 600_000); - afterEach(() => teardown()); + afterEach(async () => { + await proverNode.stop(); + teardown(); + }); it('calls a private function', async () => { const initialBalance = 100000000000n; @@ -45,7 +55,7 @@ describe(`deploys and transfers a private only token`, () => { logger.info(`Deploying accounts.`) - const accounts = await createAccounts(pxe, 2, [secretKey1, secretKey2]); + const accounts = await createAccounts(pxe, 2, [secretKey1, secretKey2], { interval: 0.1, proven: true, provenTimeout: 600}); logger.info(`Accounts deployed, deploying token.`); @@ -63,13 +73,13 @@ describe(`deploys and transfers a private only token`, () => { skipInitialization: false, skipPublicSimulation: true, }).deployed({ - proven: false, + proven: true, provenTimeout: 600, }); logger.info(`Performing transfer.`); - await token.methods.transfer(transferValue, deployerWallet.getAddress(), recipientWallet.getAddress(), deployerWallet.getAddress()).send().wait({proven: false, provenTimeout: 600}); + await token.methods.transfer(transferValue, deployerWallet.getAddress(), recipientWallet.getAddress(), deployerWallet.getAddress()).send().wait({proven: true, provenTimeout: 600}); logger.info(`Transfer completed`); @@ -80,5 +90,5 @@ describe(`deploys and transfers a private only token`, () => { expect(balanceDeployer).toBe(initialBalance - transferValue); expect(balanceRecipient).toBe(transferValue); - }); + }, 600_000); }); \ No newline at end of file diff --git a/yarn-project/ethereum/src/deploy_l1_contracts.ts b/yarn-project/ethereum/src/deploy_l1_contracts.ts index 8897a4d1811..95951a6fe7a 100644 --- a/yarn-project/ethereum/src/deploy_l1_contracts.ts +++ b/yarn-project/ethereum/src/deploy_l1_contracts.ts @@ -161,12 +161,14 @@ export const deployL1Contracts = async ( }; return await (await fetch(rpcUrl, content)).json(); }; - const interval = 12; - const res = await rpcCall(rpcUrl, 'anvil_setBlockTimestampInterval', [interval]); - if (res.error) { - throw new Error(`Error setting block interval: ${res.error.message}`); + if (chain.id == foundry.id) { + const interval = 12; + const res = await rpcCall(rpcUrl, 'anvil_setBlockTimestampInterval', [interval]); + if (res.error) { + throw new Error(`Error setting block interval: ${res.error.message}`); + } + logger.info(`Set block interval to ${interval}`); } - logger.info(`Set block interval to ${interval}`); logger.info(`Deploying contracts from ${account.address.toString()}...`); From 6f470890d85a49b42daea21452fcb50885a47bd2 Mon Sep 17 00:00:00 2001 From: PhilWindle Date: Sat, 24 Aug 2024 22:20:48 +0100 Subject: [PATCH 03/16] Fix --- yarn-project/end-to-end/src/fixtures/snapshot_manager.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 a7d8f483d99..2420a97d783 100644 --- a/yarn-project/end-to-end/src/fixtures/snapshot_manager.ts +++ b/yarn-project/end-to-end/src/fixtures/snapshot_manager.ts @@ -332,7 +332,7 @@ async function setupFromFresh( logger.verbose('Creating and syncing a simulated prover node...'); const proverNode = await createAndSyncProverNode( deployL1ContractsValues.l1ContractAddresses.rollupAddress, - `0x${proverNodePrivateKey!}`, + `0x${proverNodePrivateKey!.toString('hex')}`, aztecNodeConfig, aztecNode, ); From 2c7c374201a77cd3112ceea649584f2d93a1dd68 Mon Sep 17 00:00:00 2001 From: PhilWindle Date: Sat, 24 Aug 2024 22:25:50 +0100 Subject: [PATCH 04/16] Rename --- ...token_transfer.test.ts => e2e_public_testnet_transfer.test.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename yarn-project/end-to-end/src/public_testnet/{e2e_private_token_transfer.test.ts => e2e_public_testnet_transfer.test.ts} (100%) diff --git a/yarn-project/end-to-end/src/public_testnet/e2e_private_token_transfer.test.ts b/yarn-project/end-to-end/src/public_testnet/e2e_public_testnet_transfer.test.ts similarity index 100% rename from yarn-project/end-to-end/src/public_testnet/e2e_private_token_transfer.test.ts rename to yarn-project/end-to-end/src/public_testnet/e2e_public_testnet_transfer.test.ts From b05356bd0a1c5d77842e891bc0fc685ad8e096b2 Mon Sep 17 00:00:00 2001 From: PhilWindle Date: Sat, 24 Aug 2024 22:28:28 +0100 Subject: [PATCH 05/16] New test run in github --- .github/workflows/sepolia-test.yml | 77 ++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 .github/workflows/sepolia-test.yml diff --git a/.github/workflows/sepolia-test.yml b/.github/workflows/sepolia-test.yml new file mode 100644 index 00000000000..f679f2efb37 --- /dev/null +++ b/.github/workflows/sepolia-test.yml @@ -0,0 +1,77 @@ +name: Run public testnet test +on: + push: + branches: [pw/new-test-2] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} + GIT_COMMIT: devnet + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + +jobs: + setup: + uses: ./.github/workflows/setup-runner.yml + with: + username: ${{ github.event.pull_request.user.login || github.actor }} + runner_type: builder-x86 + secrets: inherit + if: ${{ github.event.workflow_run.conclusion == 'success' }} + + build: + needs: setup + runs-on: ${{ github.event.pull_request.user.login || github.actor }}-x86 + outputs: + e2e_list: ${{ steps.e2e_list.outputs.list }} + if: ${{ github.event.workflow_run.conclusion == 'success' }} + steps: + - uses: actions/checkout@v4 + with: + ref: "${{ env.GIT_COMMIT }}" + + - uses: ./.github/ci-setup-action + with: + concurrency_key: build-test-artifacts-${{ github.actor }} + + - name: "Build E2E Image" + timeout-minutes: 40 + run: | + earthly-ci ./yarn-project+export-e2e-test-images + + - name: Create list of devnet end-to-end jobs + id: e2e_list + run: echo "list=$(earthly ls ./yarn-project/end-to-end | grep 'public_testnet' | sed 's/+//' | jq -R . | jq -cs .)" >> $GITHUB_OUTPUT + + e2e: + needs: build + runs-on: ubuntu-20.04 + strategy: + fail-fast: false + matrix: + test: ${{ fromJson( needs.build.outputs.e2e_list )}} + if: ${{ github.event.workflow_run.conclusion == 'success' }} + steps: + - uses: actions/checkout@v4 + with: { ref: "${{ env.GIT_COMMIT }}" } + - uses: ./.github/ci-setup-action + - name: Setup and Test + timeout-minutes: 40 + uses: ./.github/ensure-tester-with-images + with: + # big machine since we're doing proving + runner_type: "64core-tester-x86" + builder_type: builder-x86 + # these are copied to the tester and expected by the earthly command below + # if they fail to copy, it will try to build them on the tester and fail + builder_images_to_copy: aztecprotocol/end-to-end:${{ env.GIT_COMMIT }} + # command to produce the images in case they don't exist + builder_command: scripts/earthly-ci ./yarn-project+export-e2e-test-images + run: | + set -eux + cd ./yarn-project/end-to-end/ + export FORCE_COLOR=1 + ../../scripts/earthly-ci -P --no-output +${{ matrix.test }} From 27c5aebbfcc0fc3d4ad063e350050658308779ec Mon Sep 17 00:00:00 2001 From: PhilWindle Date: Sat, 24 Aug 2024 22:44:44 +0100 Subject: [PATCH 06/16] Workflow --- .github/workflows/sepolia-test.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/sepolia-test.yml b/.github/workflows/sepolia-test.yml index f679f2efb37..d7948fe5ad4 100644 --- a/.github/workflows/sepolia-test.yml +++ b/.github/workflows/sepolia-test.yml @@ -1,7 +1,10 @@ name: Run public testnet test on: - push: - branches: [pw/new-test-2] + workflow_run: + workflows: ["CI"] + types: [completed] + branches: + - 'pw/new-test-2' concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -9,7 +12,7 @@ concurrency: env: DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} - GIT_COMMIT: devnet + GIT_COMMIT: ${{ github.sha }} AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} From f8fd3564afe7ac7c2edf6c770e27729f5e3577fe Mon Sep 17 00:00:00 2001 From: PhilWindle Date: Sat, 24 Aug 2024 22:53:26 +0100 Subject: [PATCH 07/16] Fixes --- yarn-project/accounts/src/testing/create_account.ts | 4 ++-- .../public_testnet/e2e_public_testnet_transfer.test.ts | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/yarn-project/accounts/src/testing/create_account.ts b/yarn-project/accounts/src/testing/create_account.ts index 0c7e8327a09..02baa1f108b 100644 --- a/yarn-project/accounts/src/testing/create_account.ts +++ b/yarn-project/accounts/src/testing/create_account.ts @@ -1,9 +1,9 @@ +import { type WaitOpts } from '@aztec/aztec.js'; import { type AccountWalletWithSecretKey } from '@aztec/aztec.js/wallet'; import { type PXE } from '@aztec/circuit-types'; import { Fr, deriveSigningKey } from '@aztec/circuits.js'; import { getSchnorrAccount } from '../schnorr/index.js'; -import { WaitOpts } from '@aztec/aztec.js'; /** * Deploys and registers a new account using random private keys and returns the associated Schnorr account wallet. Useful for testing. @@ -28,7 +28,7 @@ export async function createAccounts( pxe: PXE, numberOfAccounts = 1, secrets: Fr[] = [], - waitOpts: WaitOpts = { interval: 0.1 } + waitOpts: WaitOpts = { interval: 0.1 }, ): Promise { const accounts = []; 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 fd1ad819cb4..9104099beca 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,5 +1,5 @@ import { - AztecNode, + type AztecNode, type DebugLogger, Fr, type PXE, @@ -8,9 +8,9 @@ import { import { getPrivateKeyFromIndex, setup } from '../fixtures/utils.js'; import { EasyPrivateTokenContract } from '@aztec/noir-contracts.js'; import { createAccounts } from '@aztec/accounts/testing'; -import { getProverNodeConfigFromEnv, ProverNode, ProverNodeConfig } from '@aztec/prover-node'; +import { getProverNodeConfigFromEnv, type ProverNode, type ProverNodeConfig } from '@aztec/prover-node'; import { createAndSyncProverNode } from '../fixtures/snapshot_manager.js'; -import { AztecNodeConfig } from '@aztec/aztec-node'; +import { type AztecNodeConfig } from '@aztec/aztec-node'; import { NULL_KEY } from '@aztec/ethereum'; import { foundry, sepolia } from 'viem/chains'; @@ -44,7 +44,7 @@ describe(`deploys and transfers a private only token`, () => { afterEach(async () => { await proverNode.stop(); - teardown(); + await teardown(); }); it('calls a private function', async () => { From 31f2218a6115952e6607fb2a88132df8abd3ab67 Mon Sep 17 00:00:00 2001 From: PhilWindle Date: Sat, 24 Aug 2024 23:03:02 +0100 Subject: [PATCH 08/16] Formatting --- yarn-project/end-to-end/src/fixtures/utils.ts | 5 +- .../e2e_public_testnet_transfer.test.ts | 78 ++++++++++++------- 2 files changed, 52 insertions(+), 31 deletions(-) diff --git a/yarn-project/end-to-end/src/fixtures/utils.ts b/yarn-project/end-to-end/src/fixtures/utils.ts index 73fe78b8565..a065b2037b1 100644 --- a/yarn-project/end-to-end/src/fixtures/utils.ts +++ b/yarn-project/end-to-end/src/fixtures/utils.ts @@ -37,6 +37,7 @@ import { computeContractAddressFromInstance, getContractClassFromArtifact, } from '@aztec/circuits.js'; +import { NULL_KEY } from '@aztec/ethereum'; import { bufferAsFields } from '@aztec/foundation/abi'; import { makeBackoff, retry, retryUntil } from '@aztec/foundation/retry'; import { @@ -85,7 +86,6 @@ import { MNEMONIC } from './fixtures.js'; import { getACVMConfig } from './get_acvm_config.js'; import { getBBConfig } from './get_bb_config.js'; import { isMetricsLoggingRequested, setupMetricsLogger } from './logging.js'; -import { NULL_KEY } from '@aztec/ethereum'; export { deployAndInitializeTokenAndBridgeContracts } from '../shared/cross_chain_test_harness.js'; @@ -387,7 +387,8 @@ export async function setup( } const deployL1ContractsValues = - opts.deployL1ContractsValues ?? (await setupL1Contracts(config.l1RpcUrl, publisherHdAccount!, logger, { salt: opts.salt }, chain)); + opts.deployL1ContractsValues ?? + (await setupL1Contracts(config.l1RpcUrl, publisherHdAccount!, logger, { salt: opts.salt }, chain)); config.l1Contracts = deployL1ContractsValues.l1ContractAddresses; 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 9104099beca..37584569b10 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,19 +1,15 @@ -import { - type AztecNode, - type DebugLogger, - Fr, - type PXE, -} from '@aztec/aztec.js'; - -import { getPrivateKeyFromIndex, setup } from '../fixtures/utils.js'; -import { EasyPrivateTokenContract } from '@aztec/noir-contracts.js'; import { createAccounts } from '@aztec/accounts/testing'; -import { getProverNodeConfigFromEnv, type ProverNode, type ProverNodeConfig } from '@aztec/prover-node'; -import { createAndSyncProverNode } from '../fixtures/snapshot_manager.js'; 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 { 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'; + // process.env.SEQ_PUBLISHER_PRIVATE_KEY = ''; // process.env.PROVER_PUBLISHER_PRIVATE_KEY = ''; // process.env.ETHEREUM_HOST= 'https://sepolia.infura.io/v3/'; @@ -34,12 +30,27 @@ 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(0, {skipProtocolContracts: true, stateLoad: undefined, salt: 1}, { }, false, false, chain)); + ({ logger, pxe, teardown, config, aztecNode } = await setup( + 0, + { skipProtocolContracts: true, stateLoad: undefined, salt: 1 }, + {}, + false, + false, + chain, + )); proverConfig = getProverNodeConfigFromEnv(); const proverNodePrivateKey = getPrivateKeyFromIndex(2); - proverConfig.publisherPrivateKey = proverConfig.publisherPrivateKey === NULL_KEY ? `0x${proverNodePrivateKey?.toString('hex')}` : proverConfig.publisherPrivateKey; - - proverNode = await createAndSyncProverNode(config.l1Contracts.rollupAddress, proverConfig.publisherPrivateKey, config, aztecNode); + proverConfig.publisherPrivateKey = + proverConfig.publisherPrivateKey === NULL_KEY + ? `0x${proverNodePrivateKey?.toString('hex')}` + : proverConfig.publisherPrivateKey; + + proverNode = await createAndSyncProverNode( + config.l1Contracts.rollupAddress, + proverConfig.publisherPrivateKey, + config, + aztecNode, + ); }, 600_000); afterEach(async () => { @@ -53,9 +64,13 @@ describe(`deploys and transfers a private only token`, () => { secretKey1 = Fr.random(); secretKey2 = Fr.random(); - logger.info(`Deploying accounts.`) + logger.info(`Deploying accounts.`); - const accounts = await createAccounts(pxe, 2, [secretKey1, secretKey2], { interval: 0.1, proven: true, provenTimeout: 600}); + const accounts = await createAccounts(pxe, 2, [secretKey1, secretKey2], { + interval: 0.1, + proven: true, + provenTimeout: 600, + }); logger.info(`Accounts deployed, deploying token.`); @@ -66,20 +81,25 @@ describe(`deploys and transfers a private only token`, () => { initialBalance, deployerWallet.getAddress(), deployerWallet.getAddress(), - ).send({ - universalDeploy: true, - skipPublicDeployment: true, - skipClassRegistration: true, - skipInitialization: false, - skipPublicSimulation: true, - }).deployed({ - proven: true, - provenTimeout: 600, - }); + ) + .send({ + universalDeploy: true, + skipPublicDeployment: true, + skipClassRegistration: true, + skipInitialization: false, + skipPublicSimulation: true, + }) + .deployed({ + proven: true, + provenTimeout: 600, + }); logger.info(`Performing transfer.`); - await token.methods.transfer(transferValue, deployerWallet.getAddress(), recipientWallet.getAddress(), deployerWallet.getAddress()).send().wait({proven: true, provenTimeout: 600}); + await token.methods + .transfer(transferValue, deployerWallet.getAddress(), recipientWallet.getAddress(), deployerWallet.getAddress()) + .send() + .wait({ proven: true, provenTimeout: 600 }); logger.info(`Transfer completed`); @@ -91,4 +111,4 @@ describe(`deploys and transfers a private only token`, () => { expect(balanceDeployer).toBe(initialBalance - transferValue); expect(balanceRecipient).toBe(transferValue); }, 600_000); -}); \ No newline at end of file +}); From be262db3a91ab1550ed74c647ad9524bd047f040 Mon Sep 17 00:00:00 2001 From: PhilWindle Date: Sun, 25 Aug 2024 10:05:14 +0100 Subject: [PATCH 09/16] Try schedule --- .github/workflows/sepolia-test.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/sepolia-test.yml b/.github/workflows/sepolia-test.yml index d7948fe5ad4..7f28e6b6e4c 100644 --- a/.github/workflows/sepolia-test.yml +++ b/.github/workflows/sepolia-test.yml @@ -1,10 +1,7 @@ name: Run public testnet test on: - workflow_run: - workflows: ["CI"] - types: [completed] - branches: - - 'pw/new-test-2' + schedule: + - cron: '06 10 * * 1 - 5 concurrency: group: ${{ github.workflow }}-${{ github.ref }} From fadf2e4cb0e742d7973803c2131db65e4e335b7a Mon Sep 17 00:00:00 2001 From: PhilWindle Date: Sun, 25 Aug 2024 10:09:25 +0100 Subject: [PATCH 10/16] Branch --- .github/workflows/sepolia-test.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sepolia-test.yml b/.github/workflows/sepolia-test.yml index 7f28e6b6e4c..12cb9e702ea 100644 --- a/.github/workflows/sepolia-test.yml +++ b/.github/workflows/sepolia-test.yml @@ -1,7 +1,7 @@ name: Run public testnet test on: schedule: - - cron: '06 10 * * 1 - 5 + - cron: '06 10 * * 1-5' concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -31,7 +31,8 @@ jobs: steps: - uses: actions/checkout@v4 with: - ref: "${{ env.GIT_COMMIT }}" + #ref: "${{ env.GIT_COMMIT }}" + ref: pw/new-test-2 - uses: ./.github/ci-setup-action with: From c22f2e13c43969693fe7c96a36368e648ff6000c Mon Sep 17 00:00:00 2001 From: PhilWindle Date: Sun, 25 Aug 2024 10:10:38 +0100 Subject: [PATCH 11/16] Time --- .github/workflows/sepolia-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sepolia-test.yml b/.github/workflows/sepolia-test.yml index 12cb9e702ea..ea909cb420d 100644 --- a/.github/workflows/sepolia-test.yml +++ b/.github/workflows/sepolia-test.yml @@ -1,7 +1,7 @@ name: Run public testnet test on: schedule: - - cron: '06 10 * * 1-5' + - cron: '12 10 * * 0-5' concurrency: group: ${{ github.workflow }}-${{ github.ref }} From fa918e7a82ba10445af2e47c520dede0c2852114 Mon Sep 17 00:00:00 2001 From: PhilWindle Date: Sun, 25 Aug 2024 13:39:20 +0100 Subject: [PATCH 12/16] Add env vars --- .github/workflows/sepolia-test.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/sepolia-test.yml b/.github/workflows/sepolia-test.yml index ea909cb420d..25424f80d6b 100644 --- a/.github/workflows/sepolia-test.yml +++ b/.github/workflows/sepolia-test.yml @@ -1,7 +1,7 @@ name: Run public testnet test on: schedule: - - cron: '12 10 * * 0-5' + - cron: '00 08 * * 1-5' concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -12,6 +12,10 @@ env: GIT_COMMIT: ${{ github.sha }} AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + # SEQ_PUBLISHER_PRIVATE_KEY: ${{ secrets.SEPOLIA_SEQ_PRIVATE_KEY }} + # PROVER_PUBLISHER_PRIVATE_KEY: ${{ secrets.SEPOLIA_PROVER_PRIVATE_KEY }} + # ETHEREUM_HOST: 'https://sepolia.infura.io/v3/${{ secrets.SEPOLIA_API_KEY }}'; + # L1_CHAIN_ID: '11155111' # Sepolia Chain ID jobs: setup: @@ -20,14 +24,12 @@ jobs: username: ${{ github.event.pull_request.user.login || github.actor }} runner_type: builder-x86 secrets: inherit - if: ${{ github.event.workflow_run.conclusion == 'success' }} build: needs: setup runs-on: ${{ github.event.pull_request.user.login || github.actor }}-x86 outputs: e2e_list: ${{ steps.e2e_list.outputs.list }} - if: ${{ github.event.workflow_run.conclusion == 'success' }} steps: - uses: actions/checkout@v4 with: @@ -54,7 +56,6 @@ jobs: fail-fast: false matrix: test: ${{ fromJson( needs.build.outputs.e2e_list )}} - if: ${{ github.event.workflow_run.conclusion == 'success' }} steps: - uses: actions/checkout@v4 with: { ref: "${{ env.GIT_COMMIT }}" } From f48e4dc2c89dc29c5bb9819c53a628f60c05e038 Mon Sep 17 00:00:00 2001 From: PhilWindle Date: Sun, 25 Aug 2024 13:40:10 +0100 Subject: [PATCH 13/16] Comment --- .github/workflows/sepolia-test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/sepolia-test.yml b/.github/workflows/sepolia-test.yml index 25424f80d6b..3c563efed0a 100644 --- a/.github/workflows/sepolia-test.yml +++ b/.github/workflows/sepolia-test.yml @@ -12,6 +12,8 @@ env: GIT_COMMIT: ${{ github.sha }} AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + + # Uncomment the following to run against Sepolia # SEQ_PUBLISHER_PRIVATE_KEY: ${{ secrets.SEPOLIA_SEQ_PRIVATE_KEY }} # PROVER_PUBLISHER_PRIVATE_KEY: ${{ secrets.SEPOLIA_PROVER_PRIVATE_KEY }} # ETHEREUM_HOST: 'https://sepolia.infura.io/v3/${{ secrets.SEPOLIA_API_KEY }}'; From 0f36e36128b1618264f4d0ec8729bd92e4b90831 Mon Sep 17 00:00:00 2001 From: PhilWindle Date: Sun, 25 Aug 2024 14:53:37 +0100 Subject: [PATCH 14/16] Fixes --- yarn-project/end-to-end/Earthfile | 3 +++ .../e2e_public_testnet_transfer.test.ts | 0 2 files changed, 3 insertions(+) rename yarn-project/end-to-end/src/{public_testnet => public-testnet}/e2e_public_testnet_transfer.test.ts (100%) diff --git a/yarn-project/end-to-end/Earthfile b/yarn-project/end-to-end/Earthfile index 3f094fccbbb..38d58b341c8 100644 --- a/yarn-project/end-to-end/Earthfile +++ b/yarn-project/end-to-end/Earthfile @@ -184,6 +184,9 @@ e2e-static-calls: e2e-token-contract: DO +E2E_TEST --test=./src/e2e_token_contract +e2e-public-testnet: + DO +E2E_TEST --test=./src/public-testnet + flakey-e2e-tests: DO +E2E_TEST --test=./src/flakey --allow_fail=true 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 similarity index 100% rename from yarn-project/end-to-end/src/public_testnet/e2e_public_testnet_transfer.test.ts rename to yarn-project/end-to-end/src/public-testnet/e2e_public_testnet_transfer.test.ts From 4f7732670885ac333562fb0b564d364178d6869d Mon Sep 17 00:00:00 2001 From: PhilWindle Date: Sun, 25 Aug 2024 15:19:15 +0100 Subject: [PATCH 15/16] Reverted previous changes --- yarn-project/end-to-end/src/fixtures/snapshot_manager.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 2420a97d783..e35d3157f77 100644 --- a/yarn-project/end-to-end/src/fixtures/snapshot_manager.ts +++ b/yarn-project/end-to-end/src/fixtures/snapshot_manager.ts @@ -254,9 +254,9 @@ export async function createAndSyncProverNode( dataDirectory: undefined, proverId: new Fr(42), realProofs: false, - proverAgentConcurrency: 1, + proverAgentConcurrency: 2, publisherPrivateKey: proverNodePrivateKey, - proverNodeMaxPendingJobs: 1, + proverNodeMaxPendingJobs: 100, }; const proverNode = await createProverNode(proverConfig, { aztecNodeTxProvider: aztecNode, From 811641d72cbfe88e3a8e96e5330053cd446cf8c8 Mon Sep 17 00:00:00 2001 From: PhilWindle Date: Mon, 26 Aug 2024 17:57:32 +0100 Subject: [PATCH 16/16] Review changes --- .github/workflows/sepolia-test.yml | 3 +-- .../src/public-testnet/e2e_public_testnet_transfer.test.ts | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/sepolia-test.yml b/.github/workflows/sepolia-test.yml index 3c563efed0a..b93a3b615b2 100644 --- a/.github/workflows/sepolia-test.yml +++ b/.github/workflows/sepolia-test.yml @@ -35,8 +35,7 @@ jobs: steps: - uses: actions/checkout@v4 with: - #ref: "${{ env.GIT_COMMIT }}" - ref: pw/new-test-2 + ref: "${{ env.GIT_COMMIT }}" - uses: ./.github/ci-setup-action with: 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 37584569b10..fb9affae54d 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 @@ -32,7 +32,7 @@ describe(`deploys and transfers a private only token`, () => { const chain = chainId == sepolia.id ? sepolia : foundry; // Not the best way of doing this. ({ logger, pxe, teardown, config, aztecNode } = await setup( 0, - { skipProtocolContracts: true, stateLoad: undefined, salt: 1 }, + { skipProtocolContracts: true, stateLoad: undefined }, {}, false, false,