BlockstreamResearch / simplicity

Simplicity is a blockchain programming language designed as an alternative to Bitcoin script.
MIT License
306 stars 44 forks source link

Not WASM compatible #206

Closed uncomputable closed 6 months ago

uncomputable commented 12 months ago

The current C code cannot be compiled for WASM, which prevents Simplicity to be run in the browser. rust-simplicity depends on C FFI, so it has the same problem. For comparison, libsecp can be compiled.

We have to remove incompatible standard library headers. So far it looks like these headers cause problems:

uncomputable commented 12 months ago

I was able to replace stdio.h with stddef.h in #207. Assertions are still a problem. Maybe we can define our own assertions like libsecp. We still have to tell the compiler that certain paths are unreachable, or it will fire errors.

apoelstra commented 12 months ago

Standard assertions don't cause paths to be unreachable. It should be fine to replace C assertions with our own.

The bigger issue will be eliminating calls to malloc which is far easier in libsecp than in simplicity.

roconnor-blockstream commented 12 months ago

the use of stdio.h is probably a holdover from when I was using the FILE interface. Please make a PR to replace it with stddef.h

roconnor-blockstream commented 12 months ago

As far as the C FFI goes, jets are not allowed to do malloc, so there should be no problem with compling the jets to WASM?

apoelstra commented 12 months ago

Great observation @roconnor-blockstream. Depending how stupid our compiler is, we may need to do some preprocessor hacking to just cut out all the non-jet C code. (I think right now we build the entire C/ tree of the simplicity lib.)

roconnor-blockstream commented 10 months ago

I intended to have the C Makefile produce a static library for the jets, but I didn't have any actual consumers for such an artefact so I haven't bothered implementing it.

uncomputable commented 10 months ago

I added a separate jet target to the Makefile: #215

uncomputable commented 6 months ago

Fixed by #222