polkadot-fellows / RFCs

Proposals for change to standards administered by the Fellowship.
https://polkadot-fellows.github.io/RFCs/
Creative Commons Zero v1.0 Universal
109 stars 47 forks source link

Research: FRAME alternative based on WASM components #51

Open olanod opened 7 months ago

olanod commented 7 months ago

Here's a topic I've had in mind for quite some time that could evolve into an RFC:


Substrate uses WebAssembly MVP version for its high performance, language agnosticism, security, and to support easy upgradability and interoperability of blockchains. It has proven to be a very successful format that keeps evolving(slowly) and we could leverage some of its newer features.

This initial verison of WASM due to its limited functionality requires Substrate to define custom low level interfaces between the host client and the runtime, the WebAssebly System Interface(WASI) preview served as an experiment on how WASM can run in different contexts outside of the web browser interfacing with a host environment using a well defined interface, an outcome of said experiment is the component model, it allows separately-compiled components to work as interoperable WASM libraries that enable cross-language composition. Interfaces are now defined with WIT, a language to define contracts between components using higher level type definitions.

Retrofitting this concept into FRAME and the Substrate client would be challenging, instead we can explore using the component model as a new alternative way to write runtime code. Some of the possibilities to explore that the CM could open up: