From 85b0a7d90d0522932ddc484146f4d69dd8e23359 Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Wed, 18 Sep 2024 14:30:15 +0100 Subject: [PATCH] circom-desktop --- .gitignore | 1 + apps/circuit-compiler/src/app/app.tsx | 1 - .../src/app/components/container.tsx | 1 + apps/circuit-compiler/src/app/reducers/state.ts | 14 ++++++++++++-- .../src/app/services/circomPluginClient.ts | 16 ++++++++++------ apps/remixdesktop/log_input_signals.txt | 2 -- .../src/plugins/circomElectronBasePlugin.ts | 1 + 7 files changed, 25 insertions(+), 11 deletions(-) delete mode 100644 apps/remixdesktop/log_input_signals.txt diff --git a/.gitignore b/.gitignore index a562abbcfa..17f1c7bef7 100644 --- a/.gitignore +++ b/.gitignore @@ -70,4 +70,5 @@ apps/remixdesktop/reports apps/remixdesktop/logs/ apps/remixdesktop/bin/ apps/remixdesktop/circom-download +apps/remixdesktop/log_input_signals.txt logs diff --git a/apps/circuit-compiler/src/app/app.tsx b/apps/circuit-compiler/src/app/app.tsx index aae738303d..674e7bbceb 100644 --- a/apps/circuit-compiler/src/app/app.tsx +++ b/apps/circuit-compiler/src/app/app.tsx @@ -80,7 +80,6 @@ function App() { dispatch({ type: 'SET_COMPILER_FEEDBACK', payload: report }) }) plugin.internalEvents.on('download_success', (version) => { - dispatch({ type: 'SET_COMPILER_VERSION', payload: version }) dispatch({ type: 'REMOVE_VERSION_FROM_DOWNLOAD_LIST', payload: version }) dispatch({ type: 'SET_COMPILER_FEEDBACK', payload: null }) }) diff --git a/apps/circuit-compiler/src/app/components/container.tsx b/apps/circuit-compiler/src/app/components/container.tsx index 4acd5bfdbf..c1034576f7 100644 --- a/apps/circuit-compiler/src/app/components/container.tsx +++ b/apps/circuit-compiler/src/app/components/container.tsx @@ -31,6 +31,7 @@ export function Container () { const handleVersionSelect = (version: string) => { circuitApp.plugin.compilerVersion = version + circuitApp.dispatch({ type: 'SET_COMPILER_VERSION', payload: version }) } const handleOpenErrorLocation = async (location: string, startRange: string) => { diff --git a/apps/circuit-compiler/src/app/reducers/state.ts b/apps/circuit-compiler/src/app/reducers/state.ts index dd07927e23..1c31942a50 100644 --- a/apps/circuit-compiler/src/app/reducers/state.ts +++ b/apps/circuit-compiler/src/app/reducers/state.ts @@ -1,10 +1,20 @@ import { PTAU_LIST } from '../actions/constant' import { Actions, AppState } from '../types' import { compiler_list } from 'circom_wasm' +import isElectron from 'is-electron' + +const VersionList = isElectron() ? { ...compiler_list.wasm_builds, + "latest": { + "name": "latest", + "version": "latest", + "repo": "", + "build_source": "" + } +} : compiler_list.wasm_builds export const appInitialState: AppState = { - version: compiler_list.latest, - versionList: compiler_list.wasm_builds, + version: isElectron() ? "latest" : compiler_list.latest, + versionList: VersionList, versionDownloadList: [], filePath: "", filePathToId: {}, diff --git a/apps/circuit-compiler/src/app/services/circomPluginClient.ts b/apps/circuit-compiler/src/app/services/circomPluginClient.ts index 4e2d2359c6..5a10655fa0 100644 --- a/apps/circuit-compiler/src/app/services/circomPluginClient.ts +++ b/apps/circuit-compiler/src/app/services/circomPluginClient.ts @@ -14,7 +14,7 @@ import isElectron from 'is-electron' export class CircomPluginClient extends PluginClient { public internalEvents: EventManager private _compilationConfig: CompilationConfig = { - version: "2.1.8", + version: isElectron() ? "latest" : "2.1.8", prime: "bn128" } private lastCompiledCircuitPath: string = '' @@ -44,11 +44,12 @@ export class CircomPluginClient extends PluginClient { } set compilerVersion (version: string) { - if (!compiler_list.versions.includes(version)) throw new Error("Unsupported compiler version") + if (!compiler_list.versions.includes(version) && version !== "latest") throw new Error("Unsupported compiler version") this._compilationConfig.version = version if (isElectron()) { + const versionToInstall = version === 'latest' ? 'latest' : `v${version}` // @ts-ignore - this.call('circom', 'install', `v${version}`).then(() => { + this.call('circom', 'install', versionToInstall).then(() => { this.internalEvents.emit('download_success', version) }).catch((e) => { this.internalEvents.emit('download_failed') @@ -151,8 +152,9 @@ export class CircomPluginClient extends PluginClient { // @ts-ignore this.call('terminal', 'log', { type: 'log', value: 'Compiling ' + path }) const { version, prime } = this._compilationConfig + const versionToInstall = version === 'latest' ? 'latest' : `v${version}` // @ts-ignore - const { stdout, stderr } = await this.call('circom', 'run', path, `v${version}`, { prime: prime, wasm: "", inputs: "" }) + const { stdout, stderr } = await this.call('circom', 'run', path, versionToInstall, { prime: prime, wasm: "", inputs: "" }) const fileName = extractNameFromKey(path) this.lastCompiledCircuitPath = extractParentFromKey(path) + "/.bin/" + fileName.replace('.circom', '_js') + "/" + fileName.replace('circom', 'wasm') @@ -234,8 +236,9 @@ export class CircomPluginClient extends PluginClient { // @ts-ignore this.call('terminal', 'log', { type: 'log', value: 'Generating R1CS for ' + path }) const { version, prime } = this._compilationConfig + const versionToInstall = version === 'latest' ? 'latest' : `v${version}` // @ts-ignore - await this.call('circom', 'run', path, `v${version}`, { + await this.call('circom', 'run', path, versionToInstall, { prime: prime, r1cs: "" }) @@ -479,8 +482,9 @@ export class CircomPluginClient extends PluginClient { if (!isElectron()) return [] else { return await Promise.all(compiler_list.versions.map(async (version) => { + const versionToInstall = version === 'latest' ? 'latest' : `v${version}` // @ts-ignore - const exists = await this.call('circom', 'isVersionInstalled', `v${version}`) + const exists = await this.call('circom', 'isVersionInstalled', versionToInstall) if (!exists) return version })) diff --git a/apps/remixdesktop/log_input_signals.txt b/apps/remixdesktop/log_input_signals.txt deleted file mode 100644 index 11f5f685f9..0000000000 --- a/apps/remixdesktop/log_input_signals.txt +++ /dev/null @@ -1,2 +0,0 @@ -main.a 1 -main.b 1 diff --git a/apps/remixdesktop/src/plugins/circomElectronBasePlugin.ts b/apps/remixdesktop/src/plugins/circomElectronBasePlugin.ts index b1cf460b12..45de74a87a 100644 --- a/apps/remixdesktop/src/plugins/circomElectronBasePlugin.ts +++ b/apps/remixdesktop/src/plugins/circomElectronBasePlugin.ts @@ -56,6 +56,7 @@ class CircomElectronPluginClient extends ElectronBasePluginClient { const depPath = path.join(wd, '.deps/https/raw.githubusercontent.com/iden3/') const outputDir = extractParentFromKey(filePath) + '/.bin' + this.call('terminal' as any, 'logHtml', `Compiling ${filePath} with circom compiler (${version})`) return await circomCli.run(`${filePath} -l ${depPath} -o ${outputDir}`, version, options) }