@@ -10,12 +10,41 @@ import { getPXEConfig } from "@aztec/pxe/config";
1010import { TestWallet } from "@aztec/test-wallet/server" ;
1111import { AztecAddress } from "@aztec/aztec.js/addresses" ;
1212import { rm } from "node:fs/promises" ;
13+ import { join } from "node:path" ;
14+ import { mkdir , writeFile } from "node:fs/promises" ;
15+ import { serializePrivateExecutionSteps } from "@aztec/stdlib/kernel" ;
16+ import type {
17+ ContractFunctionInteraction ,
18+ DeployMethod ,
19+ DeployOptions ,
20+ SendInteractionOptions ,
21+ } from "@aztec/aztec.js/contracts" ;
1322
1423const sponsoredFPC = await getSponsoredFPCInstance ( ) ;
1524const sponsoredPaymentMethod = new SponsoredFeePaymentMethod (
1625 sponsoredFPC . address
1726) ;
1827
28+ async function captureProfile (
29+ interaction : ContractFunctionInteraction | DeployMethod ,
30+ opts : SendInteractionOptions | DeployOptions ,
31+ label : string
32+ ) {
33+ const result = await interaction . profile ( {
34+ ...opts ,
35+ profileMode : "full" ,
36+ skipProofGeneration : true ,
37+ } ) ;
38+ const ivcFolder = process . env . CAPTURE_IVC_FOLDER ?? "ivc" ;
39+ const resultsDirectory = join ( ivcFolder , label ) ;
40+ await mkdir ( resultsDirectory , { recursive : true } ) ;
41+ const ivcInputsPath = join ( resultsDirectory , "ivc-inputs.msgpack" ) ;
42+ await writeFile (
43+ ivcInputsPath ,
44+ serializePrivateExecutionSteps ( result . executionSteps )
45+ ) ;
46+ }
47+
1948export const setupSandbox = async ( ) : Promise < TestWallet > => {
2049 try {
2150 const nodeUrl = "http://localhost:8080" ;
@@ -49,31 +78,37 @@ async function main() {
4978 . deployed ( ) ;
5079 const accounts = await testWallet . getAccounts ( ) ;
5180
52- const valueNotEqual = await ValueNotEqualContract . deploy (
81+ const deploymentOptions = {
82+ from : accounts [ 0 ] . item ,
83+ fee : { paymentMethod : sponsoredPaymentMethod } ,
84+ } ;
85+
86+ const deploymentInteraction = await ValueNotEqualContract . deploy (
5387 testWallet ,
5488 10 ,
5589 accounts [ 0 ] . item
56- )
57- . send ( {
58- from : accounts [ 0 ] . item ,
59- fee : { paymentMethod : sponsoredPaymentMethod } ,
60- } )
90+ ) ;
91+
92+ await captureProfile ( deploymentInteraction , deploymentOptions , "deployment" ) ;
93+
94+ const valueNotEqual = await deploymentInteraction
95+ . send ( deploymentOptions )
6196 . deployed ( ) ;
6297
63- const tx = await valueNotEqual . methods
64- . increment (
65- accounts [ 0 ] . item ,
66- data . vkAsFields as unknown as FieldLike [ ] ,
67- data . proofAsFields as unknown as FieldLike [ ] ,
68- data . publicInputs as unknown as FieldLike [ ]
69- )
70- . send ( {
71- from : accounts [ 0 ] . item ,
72- fee : { paymentMethod : sponsoredPaymentMethod } ,
73- } )
74- . wait ( ) ;
98+ const opts = {
99+ from : accounts [ 0 ] . item ,
100+ fee : { paymentMethod : sponsoredPaymentMethod } ,
101+ } ;
102+
103+ const interaction = await valueNotEqual . methods . increment (
104+ accounts [ 0 ] . item ,
105+ data . vkAsFields as unknown as FieldLike [ ] ,
106+ data . proofAsFields as unknown as FieldLike [ ] ,
107+ data . publicInputs as unknown as FieldLike [ ]
108+ ) ;
109+
110+ await captureProfile ( interaction , opts , "recursion" ) ;
75111
76- console . log ( `Tx hash: ${ tx . txHash . toString ( ) } ` ) ;
77112 const counterValue = await valueNotEqual . methods
78113 . get_counter ( accounts [ 0 ] . item )
79114 . simulate ( { from : accounts [ 0 ] . item } ) ;
0 commit comments