返回介绍

WebAssembly OpenEthereum VM Design

发布于 2023-06-28 21:14:12 字数 1960 浏览 0 评论 0 收藏 0

Choosing which VM to run.

OpenEthereum client currently supports 2 VM types - EVM and WebAssembly, with EVM being default. OpenEthereum can choose to run WebAssembly VM for the specific contract if and only if BOTH are true:

  • WebAssembly is activated on the chain (wasmActivationTransition is present in json chain specification file).
  • The contract’s code starts with 4 bytes Wasm magic (00 61 73 6d, i.e. same as ‘\0asm’).

Running the code

If OpenEthereum chooses WebAssembly VM to run the contract, it’s bytecode should satisfy the constraints of contract’s ABI. If it doesn’t satisfy all constraints such a contract will be rejected and the error returned.

Before the execution of the Wasm contract it’s code will be instrumented with the following modifications:

Each of the steps above can result in error described in the correspondng links, and OpenEthereum MUST stop execution and return the error in this case.

Then OpenEthereum instantiates the module according to the WebAssembly specification. This instantiation code can also result in a trap, in this case OpenEthereum MUST finish execution of the bytecode with the error.

If the instantiation code produced no trap, OpenEthereum executes exported function with a name call according to WebAssembly Execution specification.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文