diff --git a/apps/circuit-compiler/src/app/actions/index.ts b/apps/circuit-compiler/src/app/actions/index.ts index 96d0330efb..3ea38a92da 100644 --- a/apps/circuit-compiler/src/app/actions/index.ts +++ b/apps/circuit-compiler/src/app/actions/index.ts @@ -3,7 +3,6 @@ import type { CircomPluginClient } from "../services/circomPluginClient" import { ActionPayloadTypes, AppState, ICircuitAppContext } from "../types" import { GROTH16_VERIFIER, PLONK_VERIFIER } from './constant' import { extractNameFromKey, extractParentFromKey } from '@remix-ui/helper' -import { ethers } from 'ethers' export const compileCircuit = async (plugin: CircomPluginClient, appState: AppState) => { try { @@ -60,32 +59,38 @@ export const runSetupAndExport = async (plugin: CircomPluginClient, appState: Ap const zkey_final = { type: "mem" } if (appState.provingScheme === 'groth16') { + plugin._paq.push(['trackEvent', 'circuit-compiler', 'runSetupAndExport', 'provingScheme', 'groth16']) await snarkjs.zKey.newZKey(r1cs, ptau_final, zkey_final, zkLogger(plugin, dispatch, 'SET_SETUP_EXPORT_FEEDBACK')) const vKey = await snarkjs.zKey.exportVerificationKey(zkey_final, zkLogger(plugin, dispatch, 'SET_SETUP_EXPORT_FEEDBACK')) if (appState.exportVerificationKey) { await plugin.call('fileManager', 'writeFile', `${extractParentFromKey(appState.filePath)}/groth16/zk/keys/verification_key.json`, JSON.stringify(vKey, null, 2)) + plugin._paq.push(['trackEvent', 'circuit-compiler', 'runSetupAndExport', 'zKey.exportVerificationKey', `${extractParentFromKey(appState.filePath)}/groth16/zk/keys/verification_key.json`]) } if (appState.exportVerificationContract) { const templates = { groth16: GROTH16_VERIFIER } const solidityContract = await snarkjs.zKey.exportSolidityVerifier(zkey_final, templates, zkLogger(plugin, dispatch, 'SET_SETUP_EXPORT_FEEDBACK')) await plugin.call('fileManager', 'writeFile', `${extractParentFromKey(appState.filePath)}/groth16/zk/build/zk_verifier.sol`, solidityContract) + plugin._paq.push(['trackEvent', 'circuit-compiler', 'runSetupAndExport', 'zKey.exportSolidityVerifier', `${extractParentFromKey(appState.filePath)}/groth16/zk/build/zk_verifier.sol`]) } dispatch({ type: 'SET_ZKEY', payload: zkey_final }) dispatch({ type: 'SET_VERIFICATION_KEY', payload: vKey }) } else if (appState.provingScheme === 'plonk') { + plugin._paq.push(['trackEvent', 'circuit-compiler', 'runSetupAndExport', 'provingScheme', 'plonk']) await snarkjs.plonk.setup(r1cs, ptau_final, zkey_final, zkLogger(plugin, dispatch, 'SET_SETUP_EXPORT_FEEDBACK')) const vKey = await snarkjs.zKey.exportVerificationKey(zkey_final, zkLogger(plugin, dispatch, 'SET_SETUP_EXPORT_FEEDBACK')) if (appState.exportVerificationKey) { await plugin.call('fileManager', 'writeFile', `${extractParentFromKey(appState.filePath)}/plonk/zk/keys/verification_key.json`, JSON.stringify(vKey, null, 2)) + plugin._paq.push(['trackEvent', 'circuit-compiler', 'runSetupAndExport', 'zKey.exportVerificationKey', `${extractParentFromKey(appState.filePath)}/plonk/zk/keys/verification_key.json`]) } if (appState.exportVerificationContract) { const templates = { plonk: PLONK_VERIFIER } const solidityContract = await snarkjs.zKey.exportSolidityVerifier(zkey_final, templates, zkLogger(plugin, dispatch, 'SET_SETUP_EXPORT_FEEDBACK')) await plugin.call('fileManager', 'writeFile', `${extractParentFromKey(appState.filePath)}/plonk/zk/build/zk_verifier.sol`, solidityContract) + plugin._paq.push(['trackEvent', 'circuit-compiler', 'runSetupAndExport', 'zKey.exportSolidityVerifier', `${extractParentFromKey(appState.filePath)}/plonk/zk/build/zk_verifier.sol`]) } dispatch({ type: 'SET_ZKEY', payload: zkey_final }) dispatch({ type: 'SET_VERIFICATION_KEY', payload: vKey }) @@ -93,6 +98,7 @@ export const runSetupAndExport = async (plugin: CircomPluginClient, appState: Ap dispatch({ type: 'SET_COMPILER_STATUS', payload: 'idle' }) dispatch({ type: 'SET_SETUP_EXPORT_STATUS', payload: 'done' }) } catch (e) { + plugin._paq.push(['trackEvent', 'circuit-compiler', 'runSetupAndExport', 'error', e.message]) dispatch({ type: 'SET_COMPILER_STATUS', payload: 'errored' }) console.error(e) } @@ -124,10 +130,12 @@ export const generateProof = async (plugin: CircomPluginClient, appState: AppSta plugin.call('fileManager', 'writeFile', `${extractParentFromKey(appState.filePath)}/groth16/zk/build/proof.json`, JSON.stringify(proof, null, 2)) plugin.call('terminal', 'log', { type: 'log', value: 'zk proof validity ' + verified }) + plugin._paq.push(['trackEvent', 'circuit-compiler', 'generateProof', 'groth16.prove', verified]) if (appState.exportVerifierCalldata) { const calldata = await snarkjs.groth16.exportSolidityCallData(proof, publicSignals) plugin.call('fileManager', 'writeFile', `${extractParentFromKey(appState.filePath)}/groth16/zk/build/verifierCalldata.json`, calldata) + plugin._paq.push(['trackEvent', 'circuit-compiler', 'generateProof', 'groth16.exportSolidityCallData', `${extractParentFromKey(appState.filePath)}/groth16/zk/build/verifierCalldata.json`]) } } else if (appState.provingScheme === 'plonk') { const { proof, publicSignals } = await snarkjs.plonk.prove(zkey_final, wtns, zkLogger(plugin, dispatch, 'SET_PROOF_FEEDBACK')) @@ -135,10 +143,12 @@ export const generateProof = async (plugin: CircomPluginClient, appState: AppSta plugin.call('fileManager', 'writeFile', `${extractParentFromKey(appState.filePath)}/plonk/zk/build/proof.json`, JSON.stringify(proof, null, 2)) plugin.call('terminal', 'log', { type: 'log', value: 'zk proof validity ' + verified }) + plugin._paq.push(['trackEvent', 'circuit-compiler', 'generateProof', 'plonk.prove', verified]) if (appState.exportVerifierCalldata) { const calldata = await snarkjs.plonk.exportSolidityCallData(proof, publicSignals) plugin.call('fileManager', 'writeFile', `${extractParentFromKey(appState.filePath)}/plonk/zk/build/verifierCalldata.json`, calldata) + plugin._paq.push(['trackEvent', 'circuit-compiler', 'generateProof', 'plonk.exportSolidityCallData', `${extractParentFromKey(appState.filePath)}/plonk/zk/build/verifierCalldata.json`]) } } dispatch({ type: 'SET_COMPILER_STATUS', payload: 'idle' }) diff --git a/apps/circuit-compiler/src/app/services/circomPluginClient.ts b/apps/circuit-compiler/src/app/services/circomPluginClient.ts index 4998dbd0ae..95c764f99d 100644 --- a/apps/circuit-compiler/src/app/services/circomPluginClient.ts +++ b/apps/circuit-compiler/src/app/services/circomPluginClient.ts @@ -20,7 +20,7 @@ export class CircomPluginClient extends PluginClient { private lastParsedFiles: Record = {} private lastCompiledFile: string = '' private compiler: typeof compilerV215 & typeof compilerV216 & typeof compilerV217 & typeof compilerV218 - private _paq = { + public _paq = { push: (args) => { this.call('matomo' as any, 'track', args) }