diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index da14afa..9c740b4 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -53,4 +53,4 @@ jobs: 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 && yarn multiple-pxe" + run: script -e -c "yarn deploy && yarn deploy-account && yarn fees && yarn multiple-pxe && yarn profile" diff --git a/README.md b/README.md index b1772a4..e9bda61 100644 --- a/README.md +++ b/README.md @@ -93,6 +93,20 @@ yarn codegen :warning: Tests and scripts set up and run the Private Execution Environment (PXE) and store PXE data in the `./store` directory. If you restart the sandbox, you will need to delete the `./store` directory to avoid errors. +## Transaction Profiling + +**Make sure the sandbox is running before profiling.** + +```bash +aztec start --sandbox +``` + +Then run an example contract deployment profile with: + +```bash +yarn profile +``` + ## 🧪 **Test** **Make sure the sandbox is running before running tests.** @@ -121,6 +135,7 @@ You can find a handful of scripts in the `./scripts` folder. - `./scripts/deploy.ts` is an example of how to deploy a contract. - `./scripts/fees.ts` is an example of how to pay for a contract deployment using various fee payment methods. - `./scripts/multiple_pxe.ts` is an example of how to deploy a contract from one PXE instance and interact with it from another. +- `./scripts/profile_deploy.ts` shows how to profile a transaction and print the results. ## ❗ **Error Resolution** diff --git a/package.json b/package.json index 0b74fd5..729db3b 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "deploy-account": "node --loader ts-node/esm scripts/deploy_account.ts", "multiple-pxe": "node --loader ts-node/esm scripts/multiple_pxe.ts", "get-block": "node --loader ts-node/esm scripts/get_block.ts", + "profile": "node --loader ts-node/esm scripts/profile_deploy.ts", "test": "yarn test:js && yarn test:nr", "test:js": "rm -rf store/pxe && NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --no-cache --runInBand --config jest.integration.config.json", "test:nr": "aztec test", diff --git a/scripts/profile_deploy.ts b/scripts/profile_deploy.ts new file mode 100644 index 0000000..bd1270d --- /dev/null +++ b/scripts/profile_deploy.ts @@ -0,0 +1,28 @@ +import { EasyPrivateVotingContract } from "../src/artifacts/EasyPrivateVoting.js" +import { createLogger, PXE, Logger, SponsoredFeePaymentMethod, Fr } from "@aztec/aztec.js"; +import { setupPXE } from "../src/utils/setup_pxe.js"; +import { getSponsoredFPCInstance } from "../src/utils/sponsored_fpc.js"; +import { SponsoredFPCContract } from "@aztec/noir-contracts.js/SponsoredFPC"; +import { deploySchnorrAccount } from "../src/utils/deploy_account.js"; + +async function main() { + + let pxe: PXE; + let logger: Logger; + + logger = createLogger('aztec:aztec-starter'); + + pxe = await setupPXE(); + + const sponsoredFPC = await getSponsoredFPCInstance(); + await pxe.registerContract({ instance: sponsoredFPC, artifact: SponsoredFPCContract.artifact }); + + let accountManager = await deploySchnorrAccount(pxe); + const wallet = await accountManager.getWallet(); + const address = accountManager.getAddress(); + + const profileTx = await EasyPrivateVotingContract.deploy(wallet, address).profile({ profileMode: "full"}); + console.dir(profileTx, { depth: 2 }); +} + +main(); \ No newline at end of file