wasmi: Cannot compile a Wasm module from a called host function using the same `Engine`

The issue is quite similar to #567 But instead of calling a WASM function we try to

  • create another WASM module using the same Engine or
  • wrap Func::wrap host function for while preinstantiating already created WASM module
         lock                                 deadlock
host ------------> WASM #1 ------------> host ------------> create WASM module or wrap `Func::wrap` host function for already created WASM module

Would it be possible to fix this?

About this issue

Commits related to this issue

Most upvoted comments

@Robbepop fair enough. All your arguments sound reasonable indeed. Thanks for your kind support. Waiting for the proper fix 😃

No, unfortunately #694 only provided the foundation for this feature to (maybe) be effective. Implementation needed to confirm.

Sorry for the confusion. Indeed my messages were a bit misleading.

Am I right to understand that all “static” states of instance will be in the Store?

Yes, as per the Wasm specification the Store is the owner of all instantiated Wasm related state. An instance only stores references into its associated Store. The Store even owns all Wasm instances associated to it.

Thank you @Robbepop for your swift reply.

Per your comment, I’d like to add more context for our use case.

A little bit background on us, we’re from RadixDLT and we’ve integrated wasmi v11.0 into RadixEngine/Scrypto about one year ago, and we’ve got this problem when attempting to upgrade to v23.0.

In RadixEngine, we execute user-provided WASM code dynamically. In order to efficiently execute them, we cache compiled WASM modules. With the new wasmi architecture, where wasmi module is coupled with engine for performance reason, the idea is broken, because we’re not allowed to either

  • A) Add more modules to the engine (in host function during callback)
  • or B) create new instance of existing module (with separate Store for state isolation).

I believe this is applicable for many other blockchain projects as well.

Sincerely hope you can help prioritise this.