Open
Conversation
SpaceManiac
reviewed
May 20, 2025
Contributor
There was a problem hiding this comment.
Big binary file. Is there an alternative way to obtain it? Or at least instructions on how it's built?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This example statically links an FFI version of https://docs.midnight.network/develop/how-midnight-works/impact
The library is included in object form, which is composed of wasm object files: https://github.com/WebAssembly/tool-conventions/blob/main/Linking.md , generated by the rust compiler for
wasm32-unknown-unknownand with a crate-type ofstaticlib.NOTE: there are some non-wasm objects included too, but I think those are unused and are just included in case you link to C libraries.
The library is also built with the rust standard library, which is kind of unfortunate since it makes linking harder. For example, I couldn't make the example work with
#[no_std]neither (which is kind of annoying since then we are linking the std twice, although in different versions).The other consequence of this is that the library is quite big. Normally there are ways of trimming this, but I'm not aware of any tool that works with wasm object files though. This doesn't necessarily matter for the final binary though, since unused symbols should be removed on link time, and the proof size/time shouldn't depend on unused code.
Future work
Dynamic loading
I think it would be interesting to have the same example but with a dynamically loaded lib. This would probably require a cdylib (a .wasm) instead of a
staticlib. The problem is that then the memory can't be shared, so it can't be persisted easily in the utxo.Instead I think the dynamic module has to be instantiated as some form of anonymous utxo? Or we need to serialize the state back and forth and have some sort of channel abstraction to send things back.
Bindgen?
Build the static library here
I'll add the code somewhere later I guess. The thing is that it can't be compiled without access to the private repos. In general the approach should work with opaque blobs though, but it would be nice to version control the bindings too.