zkmopro / mopro

Making client-side proving on mobile simple.
https://zkmopro.org
Apache License 2.0
131 stars 35 forks source link

wasmer 4.x support #159

Closed chancehudson closed 5 months ago

chancehudson commented 5 months ago

This PR bumps the wasmer version from 2.x to 4.x. This relies on updates to the circom-compat repo to support this version (implemented in the fork here).

Related #151

vivianjeng commented 5 months ago

There is a good implementation example here https://github.com/l-adic/circom-compat but for iOS we still need to patch the wasmer like https://github.com/wasmerio/wasmer/commit/09c7070

I haven't tried either if we patched the wasmer it works for iOS or if it can be published in testflight https://github.com/zkmopro/mopro/issues/107

vivianjeng commented 5 months ago

You can also fork the latest wasmer in zkmopro and patch these lines

chancehudson commented 5 months ago

@vivianjeng I think this is ready for review now. I removed the singleton pattern that was caching the wasm executor because of changes in wasmer@4. There's an in memory Store that tracks execution of the wasm and needs to be mutable so it can't be in a static singleton.

The new wasmer also relies more on async functions so tests are async.

vivianjeng commented 5 months ago

I tried to run it on iOS Now it can be run if the device is connected to xcode but it cannot be run if the device is disconnected to xcode (you download the app, stop xcode, and open the app again and run)

Previously we use dylib feature to fix this but I tried to use dylib, it throws

error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/install_name_tool: input file: /Users/zhengyawen/Documents/GitHub/vimwitch/mopro/mopro-example-app/target/aarch64-apple-ios/release/multiplier2.dylib is not a Mach-O file

Not sure if the wasmer is wrong but in wasmer v4, there is no dylib feature

I saw there is also a solution like https://github.com/oliveeyay/SwiftWasmer https://github.com/wasmerio/wasmer/issues/4343 I am not sure if it works in our case

Do you know if the dylib feature can be fixed? Is it possible that it can be run when disconnected to xcode?

chancehudson commented 5 months ago

Closing in favor of #179