Skip to content

Commit b108db5

Browse files
authored
Merge pull request #101 from AztecProtocol/jc/profile
add profiling
2 parents 9178173 + c350206 commit b108db5

File tree

4 files changed

+45
-1
lines changed

4 files changed

+45
-1
lines changed

.github/workflows/tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,4 @@ jobs:
5353
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"
5454

5555
- name: Run scripts
56-
run: script -e -c "yarn deploy && yarn deploy-account && yarn fees && yarn multiple-pxe"
56+
run: script -e -c "yarn deploy && yarn deploy-account && yarn fees && yarn multiple-pxe && yarn profile"

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,20 @@ yarn codegen
9393

9494
: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.
9595

96+
## Transaction Profiling
97+
98+
**Make sure the sandbox is running before profiling.**
99+
100+
```bash
101+
aztec start --sandbox
102+
```
103+
104+
Then run an example contract deployment profile with:
105+
106+
```bash
107+
yarn profile
108+
```
109+
96110
## 🧪 **Test**
97111

98112
**Make sure the sandbox is running before running tests.**
@@ -121,6 +135,7 @@ You can find a handful of scripts in the `./scripts` folder.
121135
- `./scripts/deploy.ts` is an example of how to deploy a contract.
122136
- `./scripts/fees.ts` is an example of how to pay for a contract deployment using various fee payment methods.
123137
- `./scripts/multiple_pxe.ts` is an example of how to deploy a contract from one PXE instance and interact with it from another.
138+
- `./scripts/profile_deploy.ts` shows how to profile a transaction and print the results.
124139

125140
## **Error Resolution**
126141

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"deploy-account": "node --loader ts-node/esm scripts/deploy_account.ts",
1818
"multiple-pxe": "node --loader ts-node/esm scripts/multiple_pxe.ts",
1919
"get-block": "node --loader ts-node/esm scripts/get_block.ts",
20+
"profile": "node --loader ts-node/esm scripts/profile_deploy.ts",
2021
"test": "yarn test:js && yarn test:nr",
2122
"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",
2223
"test:nr": "aztec test",

scripts/profile_deploy.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { EasyPrivateVotingContract } from "../src/artifacts/EasyPrivateVoting.js"
2+
import { createLogger, PXE, Logger, SponsoredFeePaymentMethod, Fr } from "@aztec/aztec.js";
3+
import { setupPXE } from "../src/utils/setup_pxe.js";
4+
import { getSponsoredFPCInstance } from "../src/utils/sponsored_fpc.js";
5+
import { SponsoredFPCContract } from "@aztec/noir-contracts.js/SponsoredFPC";
6+
import { deploySchnorrAccount } from "../src/utils/deploy_account.js";
7+
8+
async function main() {
9+
10+
let pxe: PXE;
11+
let logger: Logger;
12+
13+
logger = createLogger('aztec:aztec-starter');
14+
15+
pxe = await setupPXE();
16+
17+
const sponsoredFPC = await getSponsoredFPCInstance();
18+
await pxe.registerContract({ instance: sponsoredFPC, artifact: SponsoredFPCContract.artifact });
19+
20+
let accountManager = await deploySchnorrAccount(pxe);
21+
const wallet = await accountManager.getWallet();
22+
const address = accountManager.getAddress();
23+
24+
const profileTx = await EasyPrivateVotingContract.deploy(wallet, address).profile({ profileMode: "full"});
25+
console.dir(profileTx, { depth: 2 });
26+
}
27+
28+
main();

0 commit comments

Comments
 (0)