Skip to content

Commit

Permalink
Merge branch 'master' into completion_enabled_default
Browse files Browse the repository at this point in the history
  • Loading branch information
STetsing authored Dec 17, 2024
2 parents 6f13393 + a98f836 commit 205b4d2
Show file tree
Hide file tree
Showing 45 changed files with 1,013 additions and 172 deletions.
14 changes: 8 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ parameters:
orbs:
browser-tools: circleci/[email protected]
win: circleci/[email protected]
node: circleci/[email protected]
jobs:
build:
docker:
Expand Down Expand Up @@ -107,23 +108,25 @@ jobs:

test-remixdesktop-linux:
machine:
image: ubuntu-2004:current
image: ubuntu-2204:current
resource_class:
xlarge
working_directory: ~/remix-project
parallelism: 15
steps:
- run: ldd --version

- checkout
- attach_workspace:
at: .
- run: unzip ./persist/desktopbuild.zip
- node/install:
install-yarn: true
node-version: '20.2'
- run:
command: |
nvm install 20.2
nvm use 20.2
node -v
npm install --global yarn node-gyp
yarn global add node-gyp@10.2.0
python -m pip install --upgrade pip
pip install setuptools
mkdir apps/remixdesktop/build
Expand All @@ -136,13 +139,11 @@ jobs:
- run:
name: "Run tests"
command: |
nvm use 20.2
cd apps/remixdesktop/
./run_ci_test.sh
- run:
name: "Run isogit tests"
command: |
nvm use 20.2
cd apps/remixdesktop/
./run_git_ui_isogit_tests.sh
- store_test_results:
Expand Down Expand Up @@ -521,6 +522,7 @@ jobs:
ls -la dist/apps/remix-ide
nvm install 20.2
nvm use 20.2
/usr/sbin/softwareupdate --install-rosetta --agree-to-license
- restore_cache:
keys:
- remixdesktop-deps-mac-{{ checksum "apps/remixdesktop/yarn.lock" }}
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,8 @@ apps/remix-ide/src/assets/esbuild.wasm
apps/remixdesktop/build*
apps/remixdesktop/reports
apps/remixdesktop/logs/
apps/remixdesktop/bin/
apps/remixdesktop/circom-download
apps/remixdesktop/log_input_signals.txt
apps/remixdesktop/log_input_signals_new.txt
logs
2 changes: 1 addition & 1 deletion apps/circuit-compiler/src/app/actions/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ contract PlonkVerifier {
///////
// Computes the inverse of an array of values
// See https://vitalik.ca/general/2018/07/21/starks_part_3.html in section where explain fields operations
// See https://vitalik.eth.limo/general/2018/07/21/starks_part_3.html in section where explain fields operations
//////
function inverseArray(pVals, n) {
Expand Down
5 changes: 3 additions & 2 deletions apps/circuit-compiler/src/app/actions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ 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 isElectron from 'is-electron'

export const compileCircuit = async (plugin: CircomPluginClient, appState: AppState) => {
try {
Expand All @@ -28,7 +29,7 @@ export const computeWitness = async (plugin: CircomPluginClient, appState: AppSt
const wtns = await snarkjs.wtns.exportJson(witness)
const wtnsJson = wtns.map(wtn => wtn.toString())
const fileName = extractNameFromKey(appState.filePath)
const writePath = extractParentFromKey(appState.filePath) + `/.bin/${fileName.replace('.circom', '.wtn.json')}`
const writePath = extractParentFromKey(appState.filePath) + `/.bin/${fileName.replace('.circom', '_js')}/${fileName.replace('.circom', '.wtn.json')}`

await plugin.call('fileManager', 'writeFile', writePath, JSON.stringify(wtnsJson, null, 2))
plugin._paq.push(['trackEvent', 'circuit-compiler', 'computeWitness', 'wtns.exportJson', writePath])
Expand Down Expand Up @@ -116,7 +117,7 @@ export const generateProof = async (plugin: CircomPluginClient, appState: AppSta
const r1csBuffer = await plugin.call('fileManager', 'readFile', r1csPath, { encoding: null })
// @ts-ignore
const r1cs = new Uint8Array(r1csBuffer)
const wtnsPath = r1csPath.replace('.r1cs', '.wtn')
const wtnsPath = isElectron() ? extractParentFromKey(appState.filePath) + "/.bin/" + fileName.replace('.circom', '_js') + "/" + fileName.replace('.circom', '.wtn') : r1csPath.replace('.r1cs', '.wtn')
// @ts-ignore
const wtnsBuffer = await plugin.call('fileManager', 'readFile', wtnsPath, { encoding: null })
// @ts-ignore
Expand Down
29 changes: 26 additions & 3 deletions apps/circuit-compiler/src/app/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ function App() {

useEffect(() => {
plugin.internalEvents.on('circom_activated', () => {
(async () => {
const downloadList = await plugin.getCompilerDownloadList()

dispatch({ type: 'SET_VERSION_DOWNLOAD_LIST', payload: downloadList })
})();
// @ts-ignore
plugin.on('locale', 'localeChanged', (locale: any) => {
setLocale(locale)
Expand All @@ -47,6 +52,7 @@ function App() {
signalInputs = (signalInputs || []).filter(input => input)
dispatch({ type: 'SET_SIGNAL_INPUTS', payload: signalInputs })
dispatch({ type: 'SET_COMPILER_STATUS', payload: 'idle' })
dispatch({ type: 'SET_COMPILER_FEEDBACK', payload: null })
})
plugin.internalEvents.on('circuit_compiling_errored', compilerErrored)

Expand All @@ -56,7 +62,16 @@ function App() {
dispatch({ type: 'SET_COMPILER_STATUS', payload: 'idle' })
dispatch({ type: 'SET_COMPUTE_FEEDBACK', payload: null })
})
plugin.internalEvents.on('circuit_computing_witness_errored', compilerErrored)
plugin.internalEvents.on('circuit_computing_witness_errored', (err) => {
dispatch({ type: 'SET_COMPILER_STATUS', payload: 'idle' })
try {
const report = JSON.parse(err.message)

dispatch({ type: 'SET_COMPUTE_FEEDBACK', payload: report })
} catch (e) {
dispatch({ type: 'SET_COMPUTE_FEEDBACK', payload: err.message })
}
})

// parsing events
plugin.internalEvents.on('circuit_parsing_done', (_, filePathToId) => {
Expand All @@ -73,6 +88,13 @@ function App() {
dispatch({ type: 'SET_COMPILER_STATUS', payload: 'warning' })
dispatch({ type: 'SET_COMPILER_FEEDBACK', payload: report })
})
plugin.internalEvents.on('download_success', (version) => {
dispatch({ type: 'REMOVE_VERSION_FROM_DOWNLOAD_LIST', payload: version })
dispatch({ type: 'SET_COMPILER_FEEDBACK', payload: null })
})
plugin.internalEvents.on('download_failed', (error) => {
dispatch({ type: 'SET_COMPILER_FEEDBACK', payload: 'Download failed! Please check your internet connection. ' + error.message })
})
}, [])

useEffect(() => {
Expand Down Expand Up @@ -120,9 +142,10 @@ function App() {
try {
const report = JSON.parse(err.message)

dispatch({ type: 'SET_COMPUTE_FEEDBACK', payload: report })
dispatch({ type: 'SET_COMPILER_FEEDBACK', payload: report })
} catch (e) {
dispatch({ type: 'SET_COMPUTE_FEEDBACK', payload: err.message })
if (process.platform === 'win32' && err.message.includes('3221225781')) return dispatch({ type: 'SET_COMPILER_FEEDBACK', payload: 'The compiler failed to start because of some missing dependencies. Please install or repair the Microsoft Visual C++ Redistributable package to resolve this issue.' })
dispatch({ type: 'SET_COMPILER_FEEDBACK', payload: err.message })
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export function Configurations ({primeValue, setPrimeValue, versionValue}: Confi
<option value="vesta">vesta</option>
</>
</RenderIf>
<RenderIf condition={versionValue === '2.1.8'}>
<RenderIf condition={versionValue === '2.1.8' || versionValue === 'latest'}>
<>
<option value="bn128">bn128</option>
<option value="bls12381">bls12381</option>
Expand Down
2 changes: 1 addition & 1 deletion apps/circuit-compiler/src/app/components/container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export function Container () {
>
<span className="far fa-file-certificate border-0 p-0 ml-2" onClick={() => showCompilerLicense()}></span>
</CustomTooltip>
<VersionList setVersion={handleVersionSelect} versionList={circuitApp.appState.versionList} currentVersion={circuitApp.appState.version} />
<VersionList setVersion={handleVersionSelect} versionList={circuitApp.appState.versionList} currentVersion={circuitApp.appState.version} downloadList={circuitApp.appState.versionDownloadList} />
<CompileOptions setCircuitAutoCompile={handleCircuitAutoCompile} setCircuitHideWarnings={handleCircuitHideWarnings} autoCompile={circuitApp.appState.autoCompile} hideWarnings={circuitApp.appState.hideWarnings} />
<Toggler title='circuit.advancedConfigurations' dataId=''>
<Configurations setPrimeValue={handlePrimeChange} primeValue={circuitApp.appState.primeValue} versionValue={circuitApp.appState.version} />
Expand Down
2 changes: 1 addition & 1 deletion apps/circuit-compiler/src/app/components/generateProof.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function GenerateProof () {
className="btn btn-secondary btn-block d-block w-100 text-break mb-1 mt-1"
onClick={() => generateProof(circuitApp.plugin, circuitApp.appState, circuitApp.dispatch)}
disabled={(status === "compiling") || (status === "computing") || (status === "proving") || (status === "exporting")}
data-id="compute_witness_btn"
data-id="generateProofBtn"
>
<RenderIf condition={status === 'proving'}>
<i className="fas fa-sync fa-spin mr-2" aria-hidden="true"></i>
Expand Down
112 changes: 91 additions & 21 deletions apps/circuit-compiler/src/app/components/versions.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,96 @@
import { RenderIf } from "@remix-ui/helper";
import { AppState } from "../types";
import { AppState } from "../types"
import { Dropdown } from "react-bootstrap"
import React, { Ref } from "react"
import isElectron from 'is-electron'

export function VersionList ({ currentVersion, versionList, setVersion }: { versionList: AppState['versionList'], currentVersion: string, setVersion: (version: string) => void }) {
export function VersionList ({ currentVersion, versionList, downloadList, setVersion }: { versionList: AppState['versionList'], currentVersion: string, setVersion: (version: string) => void , downloadList: string[]}) {
const versionListKeys = Object.keys(versionList)

return (
<select
value={currentVersion}
onChange={(e) => setVersion(e.target.value)}
className="custom-select"
>
<RenderIf condition={versionListKeys.length > 0}>
<>
{
versionListKeys.map((version, index) => (
<option value={version} key={index}>
{ versionList[version].name }
</option>
))
}
</>
</RenderIf>
</select>
<Dropdown>
<Dropdown.Toggle as={CircomVersionMenuToggle} id="circomVersionList" className="btn btn-light btn-block w-100 d-inline-block border border-dark form-control">
<div style={{ flexGrow: 1, overflow: 'hidden', display:'flex', justifyContent:'left' }}>
{ versionList[currentVersion].name }
</div>
</Dropdown.Toggle>

<Dropdown.Menu as={CircomVersionMenu} className="w-100 custom-dropdown-items overflow-hidden">
{
versionListKeys.reverse().map((version, index) => (
<Dropdown.Item key={index} onClick={() => {
setVersion(version)
}}>
<div className='d-flex w-100 justify-content-between'>
<div>
<span className={`fas fa-check text-success mr-2 ${currentVersion === version ? 'visible' : 'invisible'}`}></span>
<span>
{ isElectron() ? versionList[version].name.replace('wasm', '') : versionList[version].name }
</span>
</div>
{ isElectron() ? downloadList.includes(version) ? <div className='far fa-arrow-circle-down'></div> : <div className='fas fa-arrow-circle-down text-success ml-auto'></div> : null }
</div>
</Dropdown.Item>
))
}
</Dropdown.Menu>
</Dropdown>
)
}

const CircomVersionMenuToggle = React.forwardRef(
(
{
children,
onClick,
className = ''
}: {
children: React.ReactNode
onClick: (e) => void
className: string
},
ref: Ref<HTMLButtonElement>
) => (
<button
ref={ref}
onClick={(e) => {
e.preventDefault()
onClick(e)
}}
className={className.replace('dropdown-toggle', '')}
>
<div className="d-flex">
{children}
<div>
<i className="fad fa-sort-circle"></i>
</div>
</div>
</button>
)
)

const CircomVersionMenu = React.forwardRef(
(
{
children,
style,
'data-id': dataId,
className,
'aria-labelledby': labeledBy
}: {
'children': React.ReactNode
'style'?: React.CSSProperties
'data-id'?: string
'className': string
'aria-labelledby'?: string
},
ref: Ref<HTMLDivElement>
) => {
const height = window.innerHeight * 0.6
return (
<div ref={ref} style={style} className={className} aria-labelledby={labeledBy} data-id={dataId}>
<ul className="list-unstyled mb-0" style={{ maxHeight: height + 'px',overflowY:'auto' }}>
{children}
</ul>
</div>
)
}
)
23 changes: 23 additions & 0 deletions apps/circuit-compiler/src/app/reducers/state.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
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,
versionDownloadList: [],
filePath: "",
filePathToId: {},
status: "idle",
Expand Down Expand Up @@ -157,6 +168,18 @@ export const appReducer = (state = appInitialState, action: Actions): AppState =
zKey: action.payload
}

case 'SET_VERSION_DOWNLOAD_LIST':
return {
...state,
versionDownloadList: action.payload
}

case 'REMOVE_VERSION_FROM_DOWNLOAD_LIST':
return {
...state,
versionDownloadList: state.versionDownloadList.filter(version => version !== action.payload)
}

default:
throw new Error()
}
Expand Down
Loading

0 comments on commit 205b4d2

Please sign in to comment.