Giter Site home page Giter Site logo

duanbing / wavm-1 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from xuperchain/wavm

0.0 0.0 0.0 1.33 MB

A high performance XuperChain WASM Virtual Machine based on WAVM

License: Other

Makefile 0.01% Shell 0.10% CMake 0.30% Dockerfile 0.01% C++ 12.24% WebAssembly 86.66% C 0.52% Assembly 0.10% Go 0.07%

wavm-1's Introduction

WAVM for XuperChain

This is a XuperChain WASM Virtual Machine based on WAVM/WAVM, most of the changes compared to the original repo are that we add gas metering to the wasm code and provide a golang wrapper. All the changes are not invasive to the original WAVM.

C/C++ code compiled with emscripten can run on WAVM without any other resolvers. For other languages it doesn't support yet.

Quick start

Requirements:

  • GCC 5.x
  • LLVM 8.0.0 (recommended)
  • XuperUnion v3.1

Standalone

If you try to test the new fetures like gas metering, just do as the original repository tells you : Building WAVM

we also provide a more unix-like way to build:

  1. install llvm and clang by here, assume your installation directory is ${llvm_install_dir}
  2. build
cd ${source-to-wavm}
CXX=${llvm_install_dir}/bin/clang++ CC=${llvm_install_dir}/bin/clang LLVMDIR=${llvm_install_dir}/lib/cmake/llvm make

Then run this command, you will get the gas used as the debug output.

./output/wavm-run -d ../Example/hello.wast

XuperChain

XuperChain is pluggable cause almost all the component included is pluggable, so is smart contract virtual machine. There are three steps to make it work.

  1. Compile WAVM.
cd ${source-to-wavm}
CXX=${llvm_install_dir}/bin/clang++ CC=${llvm_install_dir}/bin/clang LLVMDIR=${llvm_install_dir}/lib/cmake/llvm make
  1. cd ${source-to-wavm}, run make to build the plugin, copy it to the plugins directory, then add or update plugins.conf with
   "wasm":[{
   "subtype":"wavm",
   "path": "plugins/vm/wavm.so",
   "version": "1.0.0",
   "ondemand": false
 }]
  1. Add the configure to xchain.yaml:
wasm:
  driver: wavm
  external: true

external means it should be loaded as a plugin. Be careful that shim depends on xuperunion(which should be compiled by enabling GO111MODULE=on without -mod=vendor, remove the export GOFLAGS=-mod=vendor from xuperchain's Makefile), so make sure that shim requires the same version of xuperunion who load this plugin,

or an error as below maybe occur:

Warn: plugin open failed!" module=pluginmgr pluginname=wasm 
err="plugin.Open(\"plugins/wavm\"): plugin was built with a different version of package github.com/xuperchain/xuperunion/..."

FAQ

  1. libWAVM.so: cannot open shared object file: No such file or directory"

libWAVM.so is in the ${source-to-wavm}/WAVM/output by default. so if you intend to deploy wavm.so to other server, you can copy the libWAVM.so to any directory and set environment LD_LIBRARY_PATH to this directory.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.