Open mr-tron opened 9 months ago
LGTM
Python wrapper from disintar team (running via docker or require to install a lot of C libraries). Also not so friendly.
pip install tonpy
on any system, no need of any external packages. Very friendly (but good to have for golang)
We compile ton sources to each system and each python version: https://pypi.org/project/tonpy/#files
@mr-tron, how is it going?
Why are you think I am making it? I am waiting somebody who makes this task.
Hi. I would like to do this task. But what API for BoC and Cells should be used? The API from tonkeeper/tongo?
@mr-tron I think this script can be useful https://github.com/ton-blockchain/ton/blob/master/assembly/wasm/fift-func-wasm-build-ubuntu.sh
Hi. I would like to do this task. But what API for BoC and Cells should be used? The API from tonkeeper/tongo?
doesn't matter. tongo or tonutils-go. parameters to wasm are serialized to base64 BoCs
An update!
As @mr-tron mentioned the lack of threads support in wazero, I started by updating build scripts to cover that. But I faced some other road blocks:
TON code base uses c++ exceptions. However, wazero runtime still does not support them. There has been some efforts [1] to implement it, but not in the mainstream yet.
The main TON repo uses emscripten for porting to WASM and build options specifically target web/js [2]. For instance, the WASM builds are dependent on nodefs for filesystem api [3].
Since we want to target golang we may have to rely on WASI [4]. Emscripten support for WASI is no complete and wasi-sdk does not support c++ exceptions.
Therefore, I think accomplishing this task mostly involve contributions to upstream tools and the workload goes beyond the time and budget considered.
What do you think?
[1] https://github.com/tetratelabs/wazero/compare/main...jerbob92:wazero:feature/implement-emscripten-cpp-exceptions [2] https://github.com/ton-blockchain/ton/blob/200508cf8fca3ce5aa8d566105e32aea38601e93/emulator/CMakeLists.txt#L58 [3] https://github.com/ton-blockchain/ton/blob/200508cf8fca3ce5aa8d566105e32aea38601e93/crypto/CMakeLists.txt#L402 [4] https://wasi.dev
Thank you for your investigation. I hoped what it can be easily. Maybe I will try it by myself later. I saw this post few days ago - https://agniva.me/wasi/2023/12/09/whisper-wasi.html But didn't have enough time to check. Looks like very similar task.
Without exception handling support, the first throw
instruction will abrupt the process. As I compared, the use of throw
in Whisper is minimal. You do not face it in the common case and with proper input. On the other hand, in TON exceptions are used extensively. For instance, TVM errors are translated into C++ exceptions.
However, there is a chance we can handle this using host-provided functions, similar to the case with JS (where emscripten provides them automatically in the wrapper.) I have some more time to try this.
I guess TON use of filesystem API is minimal and we can handle it similar to [1]. If so, it should be doable.
Summary
Make Dockerfile and script for compiling funcfiftlib and tvm_emulator to wasm binaries and golang wrapper via wazero (important!) for running basic library functions (compile funC code, runing TVM or emulator).
Context
At this moment we have 3 developer toolsets:
Problems:
References
https://github.com/tonkeeper/tongo/blob/master/tvm/tvmExecutor.go - current bindings using C-shared library https://github.com/tact-lang/ton-wasm - wasm build without threads. https://github.com/ton-community/func-js - current js bindings
Estimate suggested reward
$1000