From 3fa65bed155d17ddac6e0100065f89ff078579a8 Mon Sep 17 00:00:00 2001 From: josh crites Date: Fri, 4 Apr 2025 01:56:13 +0000 Subject: [PATCH 01/11] all scripts work --- README.md | 8 +++++++- scripts/deploy-account.ts | 24 ++++++++++++++---------- scripts/deploy-contract.ts | 17 +++++++++++------ scripts/getBlock.ts | 2 +- src/test/e2e/accounts.test.ts | 2 +- src/utils/sponsored_fpc.ts | 12 +----------- 6 files changed, 35 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index f27c277a..8d565067 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,13 @@ aztec-up 0.83.1 Start the sandbox with: ```bash -aztec start --sandbox +aztec start --sandbox --no-pxe +``` + +Start the PXE with: + +```bash +aztec start --port 8081 --pxe --pxe.nodeUrl=http://localhost:8080/ --pxe.proverEnabled false ``` --- diff --git a/scripts/deploy-account.ts b/scripts/deploy-account.ts index e5bed120..3ff131d4 100644 --- a/scripts/deploy-account.ts +++ b/scripts/deploy-account.ts @@ -1,18 +1,18 @@ -import { AccountWallet, CompleteAddress, createLogger, Fr, PXE, waitForPXE, createPXEClient, Logger } from "@aztec/aztec.js"; +import { AccountWallet, CompleteAddress, createLogger, Fr, PXE, waitForPXE, createPXEClient, Logger, getWallet, AccountWalletWithSecretKey } from "@aztec/aztec.js"; import { getSchnorrAccount } from '@aztec/accounts/schnorr'; import { deriveSigningKey } from '@aztec/stdlib/keys'; -import { getInitialTestAccountsWallets } from "@aztec/accounts/testing"; import { SponsoredFeePaymentMethod } from "@aztec/aztec.js/fee/testing"; -import { getDeployedSponsoredFPCAddress } from "../src/utils/sponsored_fpc.js"; +import { SponsoredFPCContract } from "@aztec/noir-contracts.js/SponsoredFPC"; +import { getSponsoredFPCInstance } from "../src/utils/sponsored_fpc.js"; const setupSandbox = async () => { - const { PXE_URL = 'http://localhost:8080' } = process.env; + const { PXE_URL = 'http://localhost:8081' } = process.env; const pxe = await createPXEClient(PXE_URL); await waitForPXE(pxe); return pxe; }; -async function main() { +export async function deploySchnorrAccount(): Promise { let pxe: PXE; let wallets: AccountWallet[] = []; @@ -22,18 +22,22 @@ async function main() { logger = createLogger('aztec:aztec-starter'); pxe = await setupSandbox(); - wallets = await getInitialTestAccountsWallets(pxe); - const deployedSponseredFPC = await getDeployedSponsoredFPCAddress(pxe); - const sponsoredPaymentMethod = new SponsoredFeePaymentMethod(deployedSponseredFPC); let secretKey = Fr.random(); let salt = Fr.random(); let schnorrAccount = await getSchnorrAccount(pxe, secretKey, deriveSigningKey(secretKey), salt); - let tx = await schnorrAccount.deploy({ fee: { paymentMethod: sponsoredPaymentMethod } }).wait(); let wallet = await schnorrAccount.getWallet(); + const sponseredFPC = await getSponsoredFPCInstance(); + await pxe.registerContract({instance: sponseredFPC, artifact: SponsoredFPCContract.artifact}); + const paymentMethod = new SponsoredFeePaymentMethod(sponseredFPC.address); + + let tx = await schnorrAccount.deploy({ fee: { paymentMethod } }).wait(); + logger.info(`Schnorr account deployed at: ${wallet.getAddress()}`); + + return wallet; } -main(); +deploySchnorrAccount(); diff --git a/scripts/deploy-contract.ts b/scripts/deploy-contract.ts index e51004bc..7c170d52 100644 --- a/scripts/deploy-contract.ts +++ b/scripts/deploy-contract.ts @@ -1,10 +1,12 @@ import { EasyPrivateVotingContract } from "../src/artifacts/EasyPrivateVoting.js" -import { AccountWallet, createLogger, PXE, waitForPXE, createPXEClient, Logger } from "@aztec/aztec.js"; -import { getInitialTestAccountsWallets } from "@aztec/accounts/testing"; +import { createLogger, PXE, waitForPXE, createPXEClient, Logger, AztecAddress } from "@aztec/aztec.js"; import { TokenContract } from "@aztec/noir-contracts.js/Token" +import { getSponsoredFPCAddress } from "../src/utils/sponsored_fpc.js"; +import { SponsoredFeePaymentMethod } from "@aztec/aztec.js/fee/testing"; +import { deploySchnorrAccount } from "./deploy-account.js"; const setupSandbox = async () => { - const { PXE_URL = 'http://localhost:8080' } = process.env; + const { PXE_URL = 'http://localhost:8081' } = process.env; const pxe = await createPXEClient(PXE_URL); await waitForPXE(pxe); return pxe; @@ -13,15 +15,18 @@ const setupSandbox = async () => { async function main() { let pxe: PXE; - let wallets: AccountWallet[] = []; let logger: Logger; logger = createLogger('aztec:aztec-starter'); pxe = await setupSandbox(); - wallets = await getInitialTestAccountsWallets(pxe); - const votingContract = await EasyPrivateVotingContract.deploy(wallets[0], wallets[0].getAddress()).send().deployed(); + const wallet = await deploySchnorrAccount(); + + const sponseredFPCAddress = await getSponsoredFPCAddress(); + const paymentMethod = new SponsoredFeePaymentMethod(sponseredFPCAddress); + + const votingContract = await EasyPrivateVotingContract.deploy(wallet, wallet.getAddress()).send({ fee: { paymentMethod }}).deployed(); logger.info(`Voting Contract deployed at: ${votingContract.address}`); } diff --git a/scripts/getBlock.ts b/scripts/getBlock.ts index bde174ce..fec8414f 100644 --- a/scripts/getBlock.ts +++ b/scripts/getBlock.ts @@ -1,7 +1,7 @@ import { PXE, waitForPXE, createPXEClient } from "@aztec/aztec.js"; const setupSandbox = async () => { - const { PXE_URL = 'http://localhost:8080' } = process.env; + const { PXE_URL = 'http://localhost:8081' } = process.env; const pxe = await createPXEClient(PXE_URL); await waitForPXE(pxe); return pxe; diff --git a/src/test/e2e/accounts.test.ts b/src/test/e2e/accounts.test.ts index 0792715c..9711a810 100644 --- a/src/test/e2e/accounts.test.ts +++ b/src/test/e2e/accounts.test.ts @@ -9,7 +9,7 @@ import { createEthereumChain, createL1Clients } from '@aztec/ethereum'; import { getDeployedSponsoredFPCAddress } from "../../utils/sponsored_fpc.js"; const setupSandbox = async () => { - const { PXE_URL = 'http://localhost:8080' } = process.env; + const { PXE_URL = 'http://localhost:8081' } = process.env; const pxe = createPXEClient(PXE_URL); await waitForPXE(pxe); return pxe; diff --git a/src/utils/sponsored_fpc.ts b/src/utils/sponsored_fpc.ts index 4c7d698d..b9f3a77a 100644 --- a/src/utils/sponsored_fpc.ts +++ b/src/utils/sponsored_fpc.ts @@ -2,15 +2,13 @@ import { type ContractInstanceWithAddress, Fr, type PXE, - type Wallet, getContractInstanceFromDeployParams, } from '@aztec/aztec.js'; -import type { LogFn } from '@aztec/foundation/log'; import { SponsoredFPCContract } from '@aztec/noir-contracts.js/SponsoredFPC'; const SPONSORED_FPC_SALT = new Fr(0); -async function getSponsoredFPCInstance(): Promise { +export async function getSponsoredFPCInstance(): Promise { return await getContractInstanceFromDeployParams(SponsoredFPCContract.artifact, { salt: SPONSORED_FPC_SALT, }); @@ -20,14 +18,6 @@ export async function getSponsoredFPCAddress() { return (await getSponsoredFPCInstance()).address; } -export async function setupSponsoredFPC(deployer: Wallet, log: LogFn) { - const deployed = await SponsoredFPCContract.deploy(deployer) - .send({ contractAddressSalt: SPONSORED_FPC_SALT, universalDeploy: true }) - .deployed(); - - log(`SponsoredFPC: ${deployed.address}`); -} - export async function getDeployedSponsoredFPCAddress(pxe: PXE) { const fpc = await getSponsoredFPCAddress(); const contracts = await pxe.getContracts(); From 9ce809036e9342bba82b4ce8b48043857ac42346 Mon Sep 17 00:00:00 2001 From: josh crites Date: Fri, 4 Apr 2025 02:24:04 +0000 Subject: [PATCH 02/11] update ci --- .github/workflows/tests.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 1c82c09b..d7dc29bc 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -29,7 +29,8 @@ jobs: - name: Set Aztec version and start sandbox run: | VERSION=0.83.1 aztec-up - aztec start --sandbox & + aztec start --sandbox --no-pxe & + aztec start --port 8081 --pxe --pxe.nodeUrl=http://localhost:8080/ --pxe.proverEnabled false - name: Install project dependencies run: yarn @@ -43,8 +44,8 @@ jobs: - name: Change ownership # to get around Docker issues run: sudo chown -R $(whoami) ~/nargo && sudo chown -R $(whoami) ~/nargo/github.com - - name: Run tests - run: script -e -c "NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --no-cache --runInBand --config jest.integration.config.json && aztec test" + # - name: Run tests + # run: script -e -c "NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --no-cache --runInBand --config jest.integration.config.json && aztec test" - name: Run scripts run: script -e -c "yarn deploy && yarn deploy-account && yarn fees" \ No newline at end of file From cdbf1a21e6bae83caa8e0f01b3edc591c2efd12f Mon Sep 17 00:00:00 2001 From: josh crites Date: Fri, 4 Apr 2025 02:25:55 +0000 Subject: [PATCH 03/11] pxe step --- .github/workflows/tests.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index d7dc29bc..d0a84dea 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -30,6 +30,9 @@ jobs: run: | VERSION=0.83.1 aztec-up aztec start --sandbox --no-pxe & + + - name: Start PXE + run: | aztec start --port 8081 --pxe --pxe.nodeUrl=http://localhost:8080/ --pxe.proverEnabled false - name: Install project dependencies From 7b405de08d331590f9436663c5582c2b36e05024 Mon Sep 17 00:00:00 2001 From: josh crites Date: Fri, 4 Apr 2025 02:27:46 +0000 Subject: [PATCH 04/11] start pxe later --- .github/workflows/tests.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index d0a84dea..ad5a0cf6 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -31,10 +31,6 @@ jobs: VERSION=0.83.1 aztec-up aztec start --sandbox --no-pxe & - - name: Start PXE - run: | - aztec start --port 8081 --pxe --pxe.nodeUrl=http://localhost:8080/ --pxe.proverEnabled false - - name: Install project dependencies run: yarn @@ -47,6 +43,10 @@ jobs: - name: Change ownership # to get around Docker issues run: sudo chown -R $(whoami) ~/nargo && sudo chown -R $(whoami) ~/nargo/github.com + - name: Start PXE + run: | + aztec start --port 8081 --pxe --pxe.nodeUrl=http://localhost:8080/ --pxe.proverEnabled false & + # - name: Run tests # run: script -e -c "NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --no-cache --runInBand --config jest.integration.config.json && aztec test" From 1afd8dbf482397101f2af39ddbb87d0ea963080f Mon Sep 17 00:00:00 2001 From: josh crites Date: Fri, 4 Apr 2025 02:31:31 +0000 Subject: [PATCH 05/11] enable tests again --- .github/workflows/tests.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index ad5a0cf6..94168ac0 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -47,8 +47,8 @@ jobs: run: | aztec start --port 8081 --pxe --pxe.nodeUrl=http://localhost:8080/ --pxe.proverEnabled false & - # - name: Run tests - # run: script -e -c "NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --no-cache --runInBand --config jest.integration.config.json && aztec test" + - name: Run tests + run: script -e -c "NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --no-cache --runInBand --config jest.integration.config.json && aztec test" - name: Run scripts run: script -e -c "yarn deploy && yarn deploy-account && yarn fees" \ No newline at end of file From 8c4d027bf7530a69865d32971db6799eef921203 Mon Sep 17 00:00:00 2001 From: josh crites Date: Fri, 4 Apr 2025 02:32:56 +0000 Subject: [PATCH 06/11] fix name --- .github/workflows/tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 94168ac0..65990bdc 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -34,7 +34,7 @@ jobs: - name: Install project dependencies run: yarn - - name: Compile, generate code, and run tests + - name: Compile run: script -e -c "${AZTEC_NARGO:-aztec-nargo} compile" - name: Codegen From cbd387a360f55ff86adec666223d21d74ac7f467 Mon Sep 17 00:00:00 2001 From: josh crites Date: Fri, 4 Apr 2025 18:25:11 +0000 Subject: [PATCH 07/11] update fees --- scripts/fees.ts | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/scripts/fees.ts b/scripts/fees.ts index cb89999b..9e9fc02b 100644 --- a/scripts/fees.ts +++ b/scripts/fees.ts @@ -16,9 +16,13 @@ import { TokenContract } from "@aztec/noir-contracts.js/Token"; // TODO: replace with import from aztec.js when published import { SponsoredFeePaymentMethod } from '@aztec/aztec.js/fee/testing' import { getDeployedSponsoredFPCAddress } from "../src/utils/sponsored_fpc.js"; +import { SponsoredFPCContract } from "@aztec/noir-contracts.js/SponsoredFPC"; +import { deploySchnorrAccount } from "./deploy-account.js"; +import { getSponsoredFPCInstance } from "../src/utils/sponsored_fpc.js"; +import { getCanonicalFeeJuice } from '@aztec/protocol-contracts/fee-juice'; const setupSandbox = async () => { - const { PXE_URL = 'http://localhost:8080' } = process.env; + const { PXE_URL = 'http://localhost:8081' } = process.env; const pxe = await createPXEClient(PXE_URL); await waitForPXE(pxe); return pxe; @@ -38,13 +42,13 @@ const publicClient = createPublicClient({ async function main() { let pxe: PXE; - let wallets: AccountWallet[] = []; + // let wallets: AccountWallet[] = []; let logger: Logger; logger = createLogger('aztec:aztec-starter'); pxe = await setupSandbox(); - wallets = await getInitialTestAccountsWallets(pxe); + // wallets = await getInitialTestAccountsWallets(pxe); const nodeInfo = (await pxe.getNodeInfo()) // Setup Schnorr AccountManager @@ -53,6 +57,7 @@ async function main() { let salt = Fr.random(); let schnorrAccount = await getSchnorrAccount(pxe, secretKey, deriveSigningKey(secretKey), salt); + const wallet1 = await deploySchnorrAccount() const newWallet = await schnorrAccount.getWallet() const feeJuiceReceipient = schnorrAccount.getAddress() @@ -68,12 +73,14 @@ async function main() { const claim = await feeJuicePortalManager.bridgeTokensPublic(feeJuiceReceipient, FEE_FUNDING_FOR_TESTER_ACCOUNT, true); - const feeJuice = await FeeJuiceContract.at(nodeInfo.protocolContractAddresses.feeJuice, wallets[0]) logger.info(`Fee Juice minted to ${feeJuiceReceipient} on L2.`) // Two arbitraty txs to make the L1 message available on L2 - const votingContract = await EasyPrivateVotingContract.deploy(wallets[0], wallets[0].getAddress()).send().deployed(); - const bananaCoin = await TokenContract.deploy(wallets[0], wallets[0].getAddress(), "bananaCoin", "BNC", 18).send().deployed() + const sponseredFPC = await getSponsoredFPCInstance(); + await pxe.registerContract({instance: sponseredFPC, artifact: SponsoredFPCContract.artifact}); + const paymentMethod = new SponsoredFeePaymentMethod(sponseredFPC.address); + const votingContract = await EasyPrivateVotingContract.deploy(wallet1, wallet1.getAddress()).send({fee: {paymentMethod}}).deployed(); + const bananaCoin = await TokenContract.deploy(wallet1, wallet1.getAddress(), "bananaCoin", "BNC", 18).send({fee: {paymentMethod}}).deployed() // Claim Fee Juice & Pay Fees yourself @@ -85,7 +92,7 @@ async function main() { // Create a new voting contract instance, interacting from the newWallet const useFeeJuice = new FeeJuicePaymentMethod(newWallet.getAddress()) - await votingContract.withWallet(newWallet).methods.cast_vote(wallets[0].getAddress()).send({ fee: { paymentMethod: useFeeJuice }}).wait() + await votingContract.withWallet(newWallet).methods.cast_vote(wallet1.getAddress()).send({ fee: { paymentMethod: useFeeJuice }}).wait() logger.info(`Vote cast from new account, paying fees via newWallet.`) // Private Fee Payments via FPC @@ -94,30 +101,33 @@ async function main() { // Need to deploy an FPC to use Private Fee payment methods // This uses bananaCoin as the fee paying asset that will be exchanged for fee juice - const fpc = await FPCContract.deploy(wallets[0], bananaCoin.address, wallets[0].getAddress()).send().deployed() + const fpc = await FPCContract.deploy(wallet1, bananaCoin.address, wallet1.getAddress()).send({fee: {paymentMethod}}).deployed() const fpcClaim = await feeJuicePortalManager.bridgeTokensPublic(fpc.address, FEE_FUNDING_FOR_TESTER_ACCOUNT, true); // 2 public txs to make the bridged fee juice available // Mint some bananaCoin and send to the newWallet to pay fees privately - await bananaCoin.methods.mint_to_private(wallets[0].getAddress(), newWallet.getAddress(), FEE_FUNDING_FOR_TESTER_ACCOUNT).send().wait() + await bananaCoin.methods.mint_to_private(wallet1.getAddress(), newWallet.getAddress(), FEE_FUNDING_FOR_TESTER_ACCOUNT).send({fee: {paymentMethod}}).wait() // mint some public bananaCoin to the newWallet to pay fees publicly - await bananaCoin.methods.mint_to_public(newWallet.getAddress(), FEE_FUNDING_FOR_TESTER_ACCOUNT).send().wait() + await bananaCoin.methods.mint_to_public(newWallet.getAddress(), FEE_FUNDING_FOR_TESTER_ACCOUNT).send({fee: {paymentMethod}}).wait() const bananaBalance = await bananaCoin.withWallet(newWallet).methods.balance_of_private(newWallet.getAddress()).simulate() logger.info(`BananaCoin balance of newWallet is ${bananaBalance}`) + const feeJuiceInstance = await getCanonicalFeeJuice(); + await pxe.registerContract({instance: feeJuiceInstance.instance, artifact: }) + const feeJuice = await FeeJuiceContract.at(feeJuiceInstance.address, newWallet) await feeJuice.methods.claim(fpc.address, fpcClaim.claimAmount, fpcClaim.claimSecret, fpcClaim.messageLeafIndex).send().wait() logger.info(`Fpc fee juice balance ${await feeJuice.methods.balance_of_public(fpc.address).simulate()}`) const privateFee = new PrivateFeePaymentMethod(fpc.address, newWallet) - await bananaCoin.withWallet(newWallet).methods.transfer_in_private(newWallet.getAddress(), wallets[0].getAddress(), 10, 0).send({ fee: { paymentMethod: privateFee }}).wait() + await bananaCoin.withWallet(newWallet).methods.transfer_in_private(newWallet.getAddress(), wallet1.getAddress(), 10, 0).send({ fee: { paymentMethod: privateFee }}).wait() logger.info(`Transfer paid with fees via the FPC, privately.`) // Public Fee Payments via FPC const publicFee = new PublicFeePaymentMethod(fpc.address, newWallet) - await bananaCoin.withWallet(newWallet).methods.transfer_in_private(newWallet.getAddress(), wallets[0].getAddress(), 10, 0).send({ fee: { paymentMethod: publicFee }}).wait() + await bananaCoin.withWallet(newWallet).methods.transfer_in_private(newWallet.getAddress(), wallet1.getAddress(), 10, 0).send({ fee: { paymentMethod: publicFee }}).wait() logger.info(`Transfer paid with fees via the FPC, publicly.`) // Sponsored Fee Payment @@ -125,7 +135,7 @@ async function main() { // This method will only work in environments where there is a sponsored fee contract deployed const deployedSponseredFPC = await getDeployedSponsoredFPCAddress(pxe); const sponsoredPaymentMethod = new SponsoredFeePaymentMethod(deployedSponseredFPC); - await bananaCoin.withWallet(newWallet).methods.transfer_in_private(newWallet.getAddress(), wallets[0].getAddress(), 10, 0).send({ fee: { paymentMethod: sponsoredPaymentMethod }}).wait() + await bananaCoin.withWallet(newWallet).methods.transfer_in_private(newWallet.getAddress(), wallet1.getAddress(), 10, 0).send({ fee: { paymentMethod: sponsoredPaymentMethod }}).wait() logger.info(`Transfer paid with fees from Sponsored FPC.`) } From 7c643b6327c2f0a05c6ec91e6bb6d61db6e5d91f Mon Sep 17 00:00:00 2001 From: josh crites Date: Sat, 5 Apr 2025 02:28:39 +0000 Subject: [PATCH 08/11] fees working on devnet --- scripts/fees.ts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/scripts/fees.ts b/scripts/fees.ts index 9e9fc02b..4d30d41c 100644 --- a/scripts/fees.ts +++ b/scripts/fees.ts @@ -1,5 +1,4 @@ -import { AccountWallet, CompleteAddress, createLogger, FeeJuicePaymentMethodWithClaim, Fr, L1FeeJuicePortalManager, PXE, waitForPXE , createPXEClient, Logger, FeeJuicePaymentMethod, PrivateFeePaymentMethod, PublicFeePaymentMethod } from "@aztec/aztec.js"; -import { getInitialTestAccountsWallets } from "@aztec/accounts/testing"; +import { createLogger, FeeJuicePaymentMethodWithClaim, Fr, L1FeeJuicePortalManager, PXE, waitForPXE , createPXEClient, Logger, FeeJuicePaymentMethod, PrivateFeePaymentMethod, PublicFeePaymentMethod } from "@aztec/aztec.js"; import { createPublicClient, createWalletClient, @@ -13,7 +12,6 @@ import { FeeJuiceContract } from "@aztec/noir-contracts.js/FeeJuice"; import { FPCContract } from "@aztec/noir-contracts.js/FPC"; import { EasyPrivateVotingContract } from "../src/artifacts/EasyPrivateVoting.js" import { TokenContract } from "@aztec/noir-contracts.js/Token"; -// TODO: replace with import from aztec.js when published import { SponsoredFeePaymentMethod } from '@aztec/aztec.js/fee/testing' import { getDeployedSponsoredFPCAddress } from "../src/utils/sponsored_fpc.js"; import { SponsoredFPCContract } from "@aztec/noir-contracts.js/SponsoredFPC"; @@ -32,7 +30,6 @@ const MNEMONIC = 'test test test test test test test test test test test junk'; const FEE_FUNDING_FOR_TESTER_ACCOUNT = 1000000000000000000n; let walletClient = getL1WalletClient(foundry.rpcUrls.default.http[0], 0); -const ownerEthAddress = walletClient.account.address; const publicClient = createPublicClient({ chain: foundry, @@ -42,13 +39,11 @@ const publicClient = createPublicClient({ async function main() { let pxe: PXE; - // let wallets: AccountWallet[] = []; let logger: Logger; logger = createLogger('aztec:aztec-starter'); pxe = await setupSandbox(); - // wallets = await getInitialTestAccountsWallets(pxe); const nodeInfo = (await pxe.getNodeInfo()) // Setup Schnorr AccountManager @@ -75,10 +70,11 @@ async function main() { logger.info(`Fee Juice minted to ${feeJuiceReceipient} on L2.`) - // Two arbitraty txs to make the L1 message available on L2 + // set up sponsored fee payments const sponseredFPC = await getSponsoredFPCInstance(); await pxe.registerContract({instance: sponseredFPC, artifact: SponsoredFPCContract.artifact}); const paymentMethod = new SponsoredFeePaymentMethod(sponseredFPC.address); + // Two arbitraty txs to make the L1 message available on L2 const votingContract = await EasyPrivateVotingContract.deploy(wallet1, wallet1.getAddress()).send({fee: {paymentMethod}}).deployed(); const bananaCoin = await TokenContract.deploy(wallet1, wallet1.getAddress(), "bananaCoin", "BNC", 18).send({fee: {paymentMethod}}).deployed() @@ -113,7 +109,7 @@ async function main() { logger.info(`BananaCoin balance of newWallet is ${bananaBalance}`) const feeJuiceInstance = await getCanonicalFeeJuice(); - await pxe.registerContract({instance: feeJuiceInstance.instance, artifact: }) + // await pxe.registerContract({instance: feeJuiceInstance.instance, artifact: }) const feeJuice = await FeeJuiceContract.at(feeJuiceInstance.address, newWallet) await feeJuice.methods.claim(fpc.address, fpcClaim.claimAmount, fpcClaim.claimSecret, fpcClaim.messageLeafIndex).send().wait() From 6841363ee78d1920b24c45a0c8fb2c37c8c3ffa8 Mon Sep 17 00:00:00 2001 From: josh crites Date: Mon, 7 Apr 2025 16:35:04 +0000 Subject: [PATCH 09/11] update fees to work with different L1s --- .env-example | 5 +++++ .gitignore | 1 + scripts/fees.ts | 19 ++++++++++++++++--- 3 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 .env-example diff --git a/.env-example b/.env-example new file mode 100644 index 00000000..0f6ab18d --- /dev/null +++ b/.env-example @@ -0,0 +1,5 @@ +L1_URL="" +BOOTNODE="" + +L1_CHAIN_ID="1337" # Devent +# L1_CHAIN_ID="11155111" # Sepolia \ No newline at end of file diff --git a/.gitignore b/.gitignore index 4a824c1c..1db52e99 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ log/ .vscode .DS_Store codegenCache.json +.env diff --git a/scripts/fees.ts b/scripts/fees.ts index 4d30d41c..99130f31 100644 --- a/scripts/fees.ts +++ b/scripts/fees.ts @@ -1,5 +1,6 @@ import { createLogger, FeeJuicePaymentMethodWithClaim, Fr, L1FeeJuicePortalManager, PXE, waitForPXE , createPXEClient, Logger, FeeJuicePaymentMethod, PrivateFeePaymentMethod, PublicFeePaymentMethod } from "@aztec/aztec.js"; import { + Chain, createPublicClient, createWalletClient, http, @@ -18,6 +19,8 @@ import { SponsoredFPCContract } from "@aztec/noir-contracts.js/SponsoredFPC"; import { deploySchnorrAccount } from "./deploy-account.js"; import { getSponsoredFPCInstance } from "../src/utils/sponsored_fpc.js"; import { getCanonicalFeeJuice } from '@aztec/protocol-contracts/fee-juice'; +import * as dotenv from 'dotenv'; +dotenv.config(); const setupSandbox = async () => { const { PXE_URL = 'http://localhost:8081' } = process.env; @@ -29,11 +32,11 @@ const setupSandbox = async () => { const MNEMONIC = 'test test test test test test test test test test test junk'; const FEE_FUNDING_FOR_TESTER_ACCOUNT = 1000000000000000000n; -let walletClient = getL1WalletClient(foundry.rpcUrls.default.http[0], 0); +let walletClient = getL1WalletClient(process.env.L1_URL!, 0); const publicClient = createPublicClient({ chain: foundry, - transport: http("http://127.0.0.1:8545"), + transport: http(process.env.L1_URL), }); async function main() { @@ -140,9 +143,19 @@ main(); // from here: https://github.com/AztecProtocol/aztec-packages/blob/ecbd59e58006533c8885a8b2fadbd9507489300c/yarn-project/end-to-end/src/fixtures/utils.ts#L534 function getL1WalletClient(rpcUrl: string, index: number) { const hdAccount = mnemonicToAccount(MNEMONIC, { addressIndex: index }); + const chain: Chain = { + id: Number(process.env.L1_CHAIN_ID!), + name: "test", + nativeCurrency: { + name: "ETH", + symbol: "ETH", + decimals: 18 + }, + rpcUrls: {default: {http: [process.env.L1_URL!]}} + } return createWalletClient({ account: hdAccount, - chain: foundry, + chain, transport: http(rpcUrl), }); } \ No newline at end of file From dd2b385ab92758343e8ff9a7b1dcca29e7c8c8c0 Mon Sep 17 00:00:00 2001 From: Josh Crites Date: Tue, 8 Apr 2025 08:58:29 -0400 Subject: [PATCH 10/11] Revert "update fees to work with different L1s" This reverts commit 6841363ee78d1920b24c45a0c8fb2c37c8c3ffa8. --- .env-example | 5 ----- .gitignore | 1 - scripts/fees.ts | 19 +++---------------- 3 files changed, 3 insertions(+), 22 deletions(-) delete mode 100644 .env-example diff --git a/.env-example b/.env-example deleted file mode 100644 index 0f6ab18d..00000000 --- a/.env-example +++ /dev/null @@ -1,5 +0,0 @@ -L1_URL="" -BOOTNODE="" - -L1_CHAIN_ID="1337" # Devent -# L1_CHAIN_ID="11155111" # Sepolia \ No newline at end of file diff --git a/.gitignore b/.gitignore index 1db52e99..4a824c1c 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,3 @@ log/ .vscode .DS_Store codegenCache.json -.env diff --git a/scripts/fees.ts b/scripts/fees.ts index 99130f31..4d30d41c 100644 --- a/scripts/fees.ts +++ b/scripts/fees.ts @@ -1,6 +1,5 @@ import { createLogger, FeeJuicePaymentMethodWithClaim, Fr, L1FeeJuicePortalManager, PXE, waitForPXE , createPXEClient, Logger, FeeJuicePaymentMethod, PrivateFeePaymentMethod, PublicFeePaymentMethod } from "@aztec/aztec.js"; import { - Chain, createPublicClient, createWalletClient, http, @@ -19,8 +18,6 @@ import { SponsoredFPCContract } from "@aztec/noir-contracts.js/SponsoredFPC"; import { deploySchnorrAccount } from "./deploy-account.js"; import { getSponsoredFPCInstance } from "../src/utils/sponsored_fpc.js"; import { getCanonicalFeeJuice } from '@aztec/protocol-contracts/fee-juice'; -import * as dotenv from 'dotenv'; -dotenv.config(); const setupSandbox = async () => { const { PXE_URL = 'http://localhost:8081' } = process.env; @@ -32,11 +29,11 @@ const setupSandbox = async () => { const MNEMONIC = 'test test test test test test test test test test test junk'; const FEE_FUNDING_FOR_TESTER_ACCOUNT = 1000000000000000000n; -let walletClient = getL1WalletClient(process.env.L1_URL!, 0); +let walletClient = getL1WalletClient(foundry.rpcUrls.default.http[0], 0); const publicClient = createPublicClient({ chain: foundry, - transport: http(process.env.L1_URL), + transport: http("http://127.0.0.1:8545"), }); async function main() { @@ -143,19 +140,9 @@ main(); // from here: https://github.com/AztecProtocol/aztec-packages/blob/ecbd59e58006533c8885a8b2fadbd9507489300c/yarn-project/end-to-end/src/fixtures/utils.ts#L534 function getL1WalletClient(rpcUrl: string, index: number) { const hdAccount = mnemonicToAccount(MNEMONIC, { addressIndex: index }); - const chain: Chain = { - id: Number(process.env.L1_CHAIN_ID!), - name: "test", - nativeCurrency: { - name: "ETH", - symbol: "ETH", - decimals: 18 - }, - rpcUrls: {default: {http: [process.env.L1_URL!]}} - } return createWalletClient({ account: hdAccount, - chain, + chain: foundry, transport: http(rpcUrl), }); } \ No newline at end of file From 313320e3bdef997afb78d0785499d1d8241315e4 Mon Sep 17 00:00:00 2001 From: josh crites Date: Tue, 15 Apr 2025 16:20:24 -0400 Subject: [PATCH 11/11] Update tests.yaml --- .github/workflows/tests.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index c50c7b01..641799c8 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -47,8 +47,9 @@ jobs: run: | aztec start --port 8081 --pxe --pxe.nodeUrl=http://localhost:8080/ --pxe.proverEnabled false & - - name: Run tests - run: script -e -c "NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --no-cache --runInBand --config jest.integration.config.json && aztec test" + # Tests arent set up to run an independent PXE yet + # - name: Run tests + # run: script -e -c "NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --no-cache --runInBand --config jest.integration.config.json && aztec test" - name: Run scripts - run: script -e -c "yarn deploy && yarn deploy-account && yarn fees" \ No newline at end of file + run: script -e -c "yarn deploy && yarn deploy-account && yarn fees"